mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-08-03 12:25:17 +03:00
Compare commits
5 Commits
v1.13.14-e
...
v1.13.14-e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff11f007ec | ||
|
|
dc4170ad6b | ||
|
|
03f2be2ee6 | ||
|
|
6941854ce2 | ||
|
|
09d2dca3c3 |
19
Dockerfile
19
Dockerfile
@@ -1,18 +1,23 @@
|
|||||||
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
|
FROM --platform=$BUILDPLATFORM golang:1.26 AS builder
|
||||||
LABEL maintainer="shtorm-7"
|
LABEL maintainer="shtorm-7"
|
||||||
COPY . /go/src/github.com/sagernet/sing-box
|
COPY . /go/src/github.com/sagernet/sing-box
|
||||||
WORKDIR /go/src/github.com/sagernet/sing-box
|
WORKDIR /go/src/github.com/sagernet/sing-box
|
||||||
ARG TARGETOS TARGETARCH
|
ARG TARGETOS TARGETARCH
|
||||||
ARG GOPROXY=""
|
ARG GOPROXY=""
|
||||||
ENV GOPROXY ${GOPROXY}
|
ARG CRONET_GO_PATH=/go/src/github.com/sagernet/sing-box/cronet-go
|
||||||
ENV CGO_ENABLED=0
|
ENV GOPROXY=${GOPROXY}
|
||||||
|
ENV CGO_ENABLED=1
|
||||||
ENV GOOS=$TARGETOS
|
ENV GOOS=$TARGETOS
|
||||||
ENV GOARCH=$TARGETARCH
|
ENV GOARCH=$TARGETARCH
|
||||||
|
ENV CRONET_GO_PATH=${CRONET_GO_PATH}
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& apk add git build-base \
|
&& git config --global --add safe.directory /go/src/github.com/sagernet/sing-box \
|
||||||
&& export COMMIT=$(git rev-parse --short HEAD) \
|
&& export GOTOOLCHAIN=local \
|
||||||
&& export VERSION=$(go run ./cmd/internal/read_tag) \
|
&& export CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \
|
||||||
&& export TAGS=$(cat release/DEFAULT_BUILD_TAGS_OTHERS) \
|
&& eval "$(CGO_ENABLED=0 GOOS= GOARCH= go run -C "$CRONET_GO_PATH" ./cmd/build-naive --target=$GOOS/$GOARCH --libc=musl env --export)" \
|
||||||
|
&& export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-z,notext -Wl,-z,execstack" \
|
||||||
|
&& export VERSION=$(CGO_ENABLED=0 GOOS= GOARCH= go run ./cmd/internal/read_tag) \
|
||||||
|
&& export TAGS=$(cat release/DEFAULT_BUILD_TAGS_DOCKER) \
|
||||||
&& export LDFLAGS_SHARED=$(cat release/LDFLAGS) \
|
&& export LDFLAGS_SHARED=$(cat release/LDFLAGS) \
|
||||||
&& go build -v -trimpath -tags "$TAGS" \
|
&& go build -v -trimpath -tags "$TAGS" \
|
||||||
-o /go/bin/sing-box \
|
-o /go/bin/sing-box \
|
||||||
|
|||||||
@@ -168,9 +168,9 @@ func (e *RealityClientConfig) ClientHandshake(ctx context.Context, conn net.Conn
|
|||||||
}
|
}
|
||||||
binary.BigEndian.PutUint64(hello.SessionId, uint64(nowTime.Unix()))
|
binary.BigEndian.PutUint64(hello.SessionId, uint64(nowTime.Unix()))
|
||||||
|
|
||||||
hello.SessionId[0] = 1
|
hello.SessionId[0] = 26
|
||||||
hello.SessionId[1] = 8
|
hello.SessionId[1] = 7
|
||||||
hello.SessionId[2] = 1
|
hello.SessionId[2] = 11
|
||||||
binary.BigEndian.PutUint32(hello.SessionId[4:], uint32(time.Now().Unix()))
|
binary.BigEndian.PutUint32(hello.SessionId[4:], uint32(time.Now().Unix()))
|
||||||
copy(hello.SessionId[8:], e.shortID[:])
|
copy(hello.SessionId[8:], e.shortID[:])
|
||||||
if debug.Enabled {
|
if debug.Enabled {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type FallbackOutboundOptions struct {
|
|||||||
|
|
||||||
type GroupCommonOption struct {
|
type GroupCommonOption struct {
|
||||||
Outbounds []string `json:"outbounds"`
|
Outbounds []string `json:"outbounds"`
|
||||||
Providers []string `json:"providers"`
|
Providers badoption.Listable[string] `json:"providers,omitempty"`
|
||||||
Exclude *badoption.Regexp `json:"exclude,omitempty"`
|
Exclude *badoption.Regexp `json:"exclude,omitempty"`
|
||||||
Include *badoption.Regexp `json:"include,omitempty"`
|
Include *badoption.Regexp `json:"include,omitempty"`
|
||||||
UseAllProviders bool `json:"use_all_providers,omitempty"`
|
UseAllProviders bool `json:"use_all_providers,omitempty"`
|
||||||
|
|||||||
@@ -102,10 +102,9 @@ func (n *Inbound) Start(stage adapter.StartStage) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *Inbound) Close() error {
|
func (n *Inbound) Close() error {
|
||||||
|
err := common.Close(&n.listener)
|
||||||
n.proxy.Shutdown()
|
n.proxy.Shutdown()
|
||||||
return common.Close(
|
return err
|
||||||
&n.listener,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Inbound) UpdateUsers(users []option.MTProxyUser) {
|
func (h *Inbound) UpdateUsers(users []option.MTProxyUser) {
|
||||||
|
|||||||
@@ -94,18 +94,7 @@ func (u *clientPacketConn) writePacketToServer(buffer *buf.Buffer, source M.Sock
|
|||||||
common.Must(binary.Write(header, binary.BigEndian, source.Port))
|
common.Must(binary.Write(header, binary.BigEndian, source.Port))
|
||||||
common.Must(binary.Write(header, binary.BigEndian, uint8(len(appName))))
|
common.Must(binary.Write(header, binary.BigEndian, uint8(len(appName))))
|
||||||
common.Must1(header.WriteString(appName))
|
common.Must1(header.WriteString(appName))
|
||||||
_, err := u.writer.Write(header.Bytes())
|
return u.writeChunks(header.Bytes(), buffer.Bytes())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = u.writer.Write(buffer.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if u.flusher != nil {
|
|
||||||
u.flusher.Flush()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -195,16 +184,5 @@ func (u *serverPacketConn) writePacketToClient(buffer *buf.Buffer, source M.Sock
|
|||||||
common.Must1(header.Write(sourceAddress[:]))
|
common.Must1(header.Write(sourceAddress[:]))
|
||||||
common.Must(binary.Write(header, binary.BigEndian, source.Port))
|
common.Must(binary.Write(header, binary.BigEndian, source.Port))
|
||||||
common.Must(header.WriteZeroN(16 + 2))
|
common.Must(header.WriteZeroN(16 + 2))
|
||||||
_, err := u.writer.Write(header.Bytes())
|
return u.writeChunks(header.Bytes(), buffer.Bytes())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = u.writer.Write(buffer.Bytes())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if u.flusher != nil {
|
|
||||||
u.flusher.Flush()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ type httpConn struct {
|
|||||||
localAddr net.Addr
|
localAddr net.Addr
|
||||||
deadline *time.Timer
|
deadline *time.Timer
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
|
closed bool
|
||||||
|
|
||||||
|
mtx sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpConn) setup(body io.ReadCloser, err error) {
|
func (h *httpConn) setup(body io.ReadCloser, err error) {
|
||||||
@@ -93,6 +96,9 @@ func (h *httpConn) waitCreated() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpConn) Close() error {
|
func (h *httpConn) Close() error {
|
||||||
|
h.mtx.Lock()
|
||||||
|
h.closed = true
|
||||||
|
h.mtx.Unlock()
|
||||||
h.setup(nil, net.ErrClosed)
|
h.setup(nil, net.ErrClosed)
|
||||||
if closer, ok := h.writer.(io.Closer); ok {
|
if closer, ok := h.writer.(io.Closer); ok {
|
||||||
_ = closer.Close()
|
_ = closer.Close()
|
||||||
@@ -117,11 +123,28 @@ func (h *httpConn) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpConn) writeFlush(p []byte) (n int, err error) {
|
func (h *httpConn) writeFlush(p []byte) (n int, err error) {
|
||||||
n, err = h.writer.Write(p)
|
err = h.writeChunks(p)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return len(p), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *httpConn) writeChunks(chunks ...[]byte) error {
|
||||||
|
h.mtx.Lock()
|
||||||
|
defer h.mtx.Unlock()
|
||||||
|
if h.closed {
|
||||||
|
return net.ErrClosed
|
||||||
|
}
|
||||||
|
for _, chunk := range chunks {
|
||||||
|
if _, err := h.writer.Write(chunk); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
if h.flusher != nil {
|
if h.flusher != nil {
|
||||||
h.flusher.Flush()
|
h.flusher.Flush()
|
||||||
}
|
}
|
||||||
return n, err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpConn) RemoteAddr() net.Addr {
|
func (h *httpConn) RemoteAddr() net.Addr {
|
||||||
|
|||||||
Reference in New Issue
Block a user