Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
6752ade
refactor: DNS
nekohasekai Mar 16, 2025
6bd0a37
refactor: Outbound domain resolver
nekohasekai Jan 12, 2025
c37b747
Add TLS fragment support
nekohasekai Jan 26, 2025
a1b717e
Add certificate store
nekohasekai Jan 8, 2025
e429db2
documentation: Refactor DNS
nekohasekai Jan 25, 2025
b4d9e74
documentation: Outbound domain resolver
nekohasekai Jan 29, 2025
791d958
documentation: TLS fragment
nekohasekai Jan 30, 2025
0597a0a
documentation: Certificate store
nekohasekai Jan 30, 2025
a228491
documentation: Remove outdated icons
nekohasekai Jan 30, 2025
16e541f
Build legacy binaries with latest Go
nekohasekai Feb 12, 2025
99c5fde
Add Tailscale endpoint
nekohasekai Apr 6, 2025
eb7caa2
Remove single quotes of raw Moziila certs
xchacha20-poly1305 Feb 12, 2025
5f1b064
Add back port hopping to hysteria 1
nekohasekai Feb 16, 2025
942a45d
Fix toolchain version
nekohasekai Feb 18, 2025
8689358
Improve resolve action
nekohasekai Feb 20, 2025
a66454f
Get darwin local DNS server from libresolv
nekohasekai Feb 20, 2025
686e210
Add fallback local DNS server for iOS
nekohasekai Feb 20, 2025
52561db
Migrate to stdlib ECH support
nekohasekai Feb 22, 2025
4cb528c
Add AnyTLS protocol
anytls Feb 20, 2025
097d298
documentation: Fix AnyTLS doc
nekohasekai Feb 22, 2025
6d410cc
Fix Outbound deadlock
alireza0 Feb 23, 2025
c10ef77
documentation: Fix typo
libtry486 Feb 23, 2025
5bb58c4
documentation: Minor fixes
Feb 20, 2025
6071b56
Add MinIdleSession option to AnyTLS outbound
anytls Feb 24, 2025
324b437
documentation: Fix missing hosts DNS server
nekohasekai Feb 24, 2025
1295212
Fix DNS fallback
nekohasekai Feb 25, 2025
79c8141
Fix parsing legacy DNS options
TargetLocked Feb 25, 2025
d004f3c
documentation: Fix typo
BedrockDigger Feb 25, 2025
7040d8d
Update sing-anytls
anytls Feb 25, 2025
a1e6f4e
Fix missing AnyTLS display name
Zephyruso Feb 25, 2025
6e4d92b
Fix domain resolver on direct outbound
nekohasekai Feb 26, 2025
2ddc119
Move predefined DNS server to rule action
nekohasekai Feb 26, 2025
17cd4ef
Fix anytls dialer usage
nekohasekai Feb 27, 2025
e930339
documentation: Fix missing `ip_accept_any` DNS rule option
nekohasekai Mar 6, 2025
a36bd4c
Fix UDP DNS server crash
nekohasekai Mar 6, 2025
d53dae1
Fix hosts DNS server
k9982874 Mar 10, 2025
22185ff
Update sing-anytls
anytls Mar 10, 2025
7c32636
documentation: Fix typo
Restia-Ashbell Mar 10, 2025
825a9cd
Fix http3 DNS server connecting to wrong address
nekohasekai Mar 13, 2025
c22ea80
Fix DNS lookup context pollution
nekohasekai Mar 13, 2025
c81cb83
Make `domain_resolver` optional when only one DNS server is configured
nekohasekai Mar 15, 2025
e5d9f40
option: Fix marshal legacy DNS options
nekohasekai Mar 15, 2025
c14a04f
Add ntp protocol sniffing
k9982874 Mar 15, 2025
cf1c7c3
Add wildcard-sni support for shadow-tls inbound
nekohasekai Mar 16, 2025
29ecb71
Fix unhandled DNS loop
nekohasekai Mar 17, 2025
866b726
Remove map usage in options
nekohasekai Mar 18, 2025
452ca55
Add wildcard name support for predefined records
nekohasekai Mar 18, 2025
f292280
Add netns support
nekohasekai Mar 18, 2025
d81fdd8
Explicitly reject detour to empty direct outbounds
nekohasekai Mar 20, 2025
d3bb8c5
Update gVisor to 20250319.0
nekohasekai Mar 24, 2025
38d79fa
Fail when default DNS server not found
nekohasekai Mar 24, 2025
7216d7c
Fix missing `with_tailscale` in Dockerfile
Mar 26, 2025
a048092
Update anytls
anytls Mar 27, 2025
2c5e277
Fix DNS over QUIC stream close
dyhkwong Mar 27, 2025
1db007c
Fix Tailscale dialer
nekohasekai Mar 28, 2025
be27a43
Allow direct outbounds without `domain_resolver`
nekohasekai Apr 1, 2025
6daafc3
Fix fetch ECH configs
Apr 6, 2025
62418e8
Fix UDP DNS server crash
iikira Apr 6, 2025
ad03f8a
release: Skip override version for iOS
nekohasekai Apr 8, 2025
6504309
Fix DNS dialer
nekohasekai Apr 8, 2025
057ecd2
Update anytls
anytls Apr 9, 2025
1a836e2
Improve local DNS server
nekohasekai Apr 12, 2025
eb30c72
Fix missing handling of legacy `domain_strategy` options
nekohasekai Apr 17, 2025
8d0a758
documentation: Try to make the play review happy
nekohasekai Apr 17, 2025
e8e5aa2
Fix callback deletion in UDP transport
caelansar Apr 19, 2025
dc6ffbf
documentation: Minor fixes
Apr 19, 2025
772f436
Fix fetch ECH configs
nekohasekai Apr 22, 2025
63980c4
Fix DNS lookup
nekohasekai Apr 25, 2025
86362ed
clash-api: Add more meta api
nekohasekai Apr 25, 2025
c7d76c1
Fix wireguard `listen_port`
nekohasekai Apr 26, 2025
6388c2e
Report invalid DNS address early
xchacha20-poly1305 Apr 26, 2025
b4f126e
documentation: Fix anytls padding scheme description
nekohasekai Apr 28, 2025
7615988
Handle EDNS version downgrade
nekohasekai Apr 30, 2025
d5838a1
Update utls to v1.7.0
nekohasekai May 3, 2025
f07a91a
Update quic-go to v0.51.0
nekohasekai May 5, 2025
0e4def2
Add control options for listeners
nekohasekai May 5, 2025
8387642
Update protobuf and grpc
nekohasekai May 5, 2025
262aaae
Update certmagic and providers
nekohasekai May 5, 2025
16c4e56
Update minor dependencies
nekohasekai May 5, 2025
0c79479
Fix set edns0 client subnet
nekohasekai May 7, 2025
c7ccff7
release: Update Go to 1.24.3
nekohasekai Apr 3, 2025
3222b62
documentation: Bump version
nekohasekai Apr 28, 2025
9c8a2c9
Add balancer outbound
VeroFess May 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/setup_legacy_go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

VERSION="1.23.6"

mkdir -p $HOME/go
cd $HOME/go
wget "https://dl.google.com/go/go${VERSION}.linux-amd64.tar.gz"
tar -xzf "go${VERSION}.linux-amd64.tar.gz"
mv go go_legacy
cd go_legacy

# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
# this patch file only works on golang1.23.x
# that means after golang1.24 release it must be changed
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.23/
# revert:
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"

curl https://github.com/MetaCubeX/go/commit/9ac42137ef6730e8b7daca016ece831297a1d75b.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/21290de8a4c91408de7c2b5b68757b1e90af49dd.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/6a31d3fa8e47ddabc10bd97bff10d9a85f4cfb76.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/69e2eed6dd0f6d815ebf15797761c13f31213dd6.diff | patch --verbose -p 1
43 changes: 27 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: Check input version
if: github.event_name == 'workflow_dispatch'
run: |-
Expand Down Expand Up @@ -94,7 +94,6 @@ jobs:
- { os: windows, arch: arm64 }

- { os: darwin, arch: amd64 }
- { os: darwin, arch: amd64, legacy_go: true }
- { os: darwin, arch: arm64 }

- { os: android, arch: arm64, ndk: "aarch64-linux-android21" }
Expand All @@ -106,16 +105,28 @@ jobs:
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
fetch-depth: 0
- name: Setup Go
if: matrix.legacy_go
uses: actions/setup-go@v5
with:
go-version: ~1.20
- name: Setup Go
if: ${{ ! matrix.legacy_go }}
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: Cache Legacy Go
if: matrix.require_legacy_go
id: cache-legacy-go
uses: actions/cache@v4
with:
path: |
~/go/go_legacy
key: go_legacy_1236
- name: Setup Legacy Go
if: matrix.legacy_go && steps.cache-legacy-go.outputs.cache-hit != 'true'
run: |-
.github/setup_legacy_go.sh
- name: Setup Legacy Go 2
if: matrix.legacy_go
run: |-
echo "PATH=$HOME/go/go_legacy/bin:$PATH" >> $GITHUB_ENV
echo "GOROOT=$HOME/go/go_legacy" >> $GITHUB_ENV
- name: Setup Android NDK
if: matrix.os == 'android'
uses: nttld/setup-ndk@v1
Expand All @@ -129,10 +140,7 @@ jobs:
- name: Set build tags
run: |
set -xeuo pipefail
TAGS='with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_reality_server,with_acme,with_clash_api'
if [ ! '${{ matrix.legacy_go }}' = 'true' ]; then
TAGS="${TAGS},with_ech"
fi
TAGS='with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale'
echo "BUILD_TAGS=${TAGS}" >> "${GITHUB_ENV}"
- name: Build
if: matrix.os != 'android'
Expand Down Expand Up @@ -286,7 +294,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: Setup Android NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
Expand Down Expand Up @@ -366,7 +374,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: Setup Android NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
Expand Down Expand Up @@ -464,7 +472,7 @@ jobs:
if: matrix.if
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: Setup Xcode stable
if: matrix.if && github.ref == 'refs/heads/main-next'
run: |-
Expand Down Expand Up @@ -541,10 +549,13 @@ jobs:
MACOS_PROJECT_VERSION=$(go run -v ./cmd/internal/app_store_connect next_macos_project_version)
echo "MACOS_PROJECT_VERSION=$MACOS_PROJECT_VERSION"
echo "MACOS_PROJECT_VERSION=$MACOS_PROJECT_VERSION" >> "$GITHUB_ENV"
- name: Update version
if: matrix.if && matrix.name != 'iOS'
run: |-
go run -v ./cmd/internal/update_apple_version --ci
- name: Build
if: matrix.if
run: |-
go run -v ./cmd/internal/update_apple_version --ci
cd clients/apple
xcodebuild archive \
-scheme "${{ matrix.scheme }}" \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: Check input version
if: github.event_name == 'workflow_dispatch'
run: |-
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.24
go-version: ^1.24.3
- name: Setup Android NDK
if: matrix.os == 'android'
uses: nttld/setup-ndk@v1
Expand All @@ -80,10 +80,7 @@ jobs:
- name: Set build tags
run: |
set -xeuo pipefail
TAGS='with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_reality_server,with_acme,with_clash_api'
if [ ! '${{ matrix.legacy_go }}' = 'true' ]; then
TAGS="${TAGS},with_ech"
fi
TAGS='with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api'
echo "BUILD_TAGS=${TAGS}" >> "${GITHUB_ENV}"
- name: Build
run: |
Expand Down
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ run:
- with_quic
- with_dhcp
- with_wireguard
- with_ech
- with_utls
- with_reality_server
- with_acme
- with_clash_api

Expand Down
7 changes: 4 additions & 3 deletions .goreleaser.fury.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ builds:
- -v
- -trimpath
ldflags:
- -X github.com/sagernet/sing-box/constant.Version={{ .Version }} -s -w -buildid=
- -X github.com/sagernet/sing-box/constant.Version={{ .Version }}
- -s
- -buildid=
tags:
- with_gvisor
- with_quic
- with_dhcp
- with_wireguard
- with_ech
- with_utls
- with_reality_server
- with_acme
- with_clash_api
- with_tailscale
env:
- CGO_ENABLED=0
targets:
Expand Down
12 changes: 6 additions & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ builds:
- with_quic
- with_dhcp
- with_wireguard
- with_ech
- with_utls
- with_reality_server
- with_acme
- with_clash_api
- with_tailscale
env:
- CGO_ENABLED=0
- GOTOOLCHAIN=local
targets:
- linux_386
- linux_amd64_v1
Expand All @@ -46,21 +46,21 @@ builds:
- with_dhcp
- with_wireguard
- with_utls
- with_reality_server
- with_acme
- with_clash_api
- with_tailscale
env:
- CGO_ENABLED=0
- GOROOT={{ .Env.GOPATH }}/go1.20.14
tool: "{{ .Env.GOPATH }}/go1.20.14/bin/go"
- GOROOT={{ .Env.GOPATH }}/go_legacy
tool: "{{ .Env.GOPATH }}/go_legacy/bin/go"
targets:
- windows_amd64_v1
- windows_386
- darwin_amd64_v1
- id: android
<<: *template
env:
- CGO_ENABLED=1
- GOTOOLCHAIN=local
overrides:
- goos: android
goarch: arm
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN set -ex \
&& export COMMIT=$(git rev-parse --short HEAD) \
&& export VERSION=$(go run ./cmd/internal/read_tag) \
&& go build -v -trimpath -tags \
"with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api" \
"with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale" \
-o /go/bin/sing-box \
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
./cmd/sing-box
Expand Down
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
NAME = sing-box
COMMIT = $(shell git rev-parse --short HEAD)
TAGS_GO120 = with_gvisor,with_dhcp,with_wireguard,with_reality_server,with_clash_api,with_quic,with_utls
TAGS_GO121 = with_ech
TAGS ?= $(TAGS_GO118),$(TAGS_GO120),$(TAGS_GO121)
TAGS_TEST ?= with_gvisor,with_quic,with_wireguard,with_grpc,with_ech,with_utls,with_reality_server
TAGS ?= with_gvisor,with_dhcp,with_wireguard,with_clash_api,with_quic,with_utls,with_tailscale
TAGS_TEST ?= with_gvisor,with_quic,with_wireguard,with_grpc,with_utls

GOHOSTOS = $(shell go env GOHOSTOS)
GOHOSTARCH = $(shell go env GOHOSTARCH)
Expand All @@ -17,14 +15,12 @@ PREFIX ?= $(shell go env GOPATH)
.PHONY: test release docs build

build:
export GOTOOLCHAIN=local && \
go build $(MAIN_PARAMS) $(MAIN)

ci_build_go120:
go build $(PARAMS) $(MAIN)
go build $(PARAMS) -tags "$(TAGS_GO120)" $(MAIN)

ci_build:
go build $(PARAMS) $(MAIN)
export GOTOOLCHAIN=local && \
go build $(PARAMS) $(MAIN) && \
go build $(MAIN_PARAMS) $(MAIN)

generate_completions:
Expand Down Expand Up @@ -61,6 +57,9 @@ proto_install:
go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

update_certificates:
go run ./cmd/internal/update_certificates

release:
go run ./cmd/internal/build goreleaser release --clean --skip publish
mkdir dist/release
Expand Down Expand Up @@ -227,8 +226,8 @@ lib:
go run ./cmd/internal/build_libbox -target ios

lib_install:
go install -v github.com/sagernet/gomobile/cmd/[email protected].4
go install -v github.com/sagernet/gomobile/cmd/[email protected].4
go install -v github.com/sagernet/gomobile/cmd/[email protected].6
go install -v github.com/sagernet/gomobile/cmd/[email protected].6

docs:
venv/bin/mkdocs serve
Expand Down
21 changes: 21 additions & 0 deletions adapter/certificate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package adapter

import (
"context"
"crypto/x509"

"github.com/sagernet/sing/service"
)

type CertificateStore interface {
LifecycleService
Pool() *x509.CertPool
}

func RootPoolFromContext(ctx context.Context) *x509.CertPool {
store := service.FromContext[CertificateStore](ctx)
if store == nil {
return nil
}
return store.Pool()
}
Loading