Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
1d100c6
refactor: DNS
nekohasekai Mar 16, 2025
414bc98
refactor: Outbound domain resolver
nekohasekai Jan 12, 2025
357b4c2
Add TLS fragment support
nekohasekai Jan 26, 2025
ef8ebec
Add certificate store
nekohasekai Jan 8, 2025
46e863b
documentation: Refactor DNS
nekohasekai Jan 25, 2025
eef4612
documentation: Outbound domain resolver
nekohasekai Jan 29, 2025
bcdd324
documentation: TLS fragment
nekohasekai Jan 30, 2025
8fd9eb9
documentation: Certificate store
nekohasekai Jan 30, 2025
226f4a3
documentation: Remove outdated icons
nekohasekai Jan 30, 2025
1abc342
Build legacy binaries with latest Go
nekohasekai Feb 12, 2025
d1097c2
Add Tailscale endpoint
nekohasekai Apr 6, 2025
161e18b
Remove single quotes of raw Moziila certs
xchacha20-poly1305 Feb 12, 2025
a08ebe8
Add back port hopping to hysteria 1
nekohasekai Feb 16, 2025
fccd3f9
Improve resolve action
nekohasekai Feb 20, 2025
7ef6b84
Get darwin local DNS server from libresolv
nekohasekai Feb 20, 2025
bbce1fe
Add fallback local DNS server for iOS
nekohasekai Feb 20, 2025
040abba
Migrate to stdlib ECH support
nekohasekai Feb 22, 2025
d48a81f
Add AnyTLS protocol
anytls Feb 20, 2025
caa44e0
documentation: Fix AnyTLS doc
nekohasekai Feb 22, 2025
96434bd
Fix Outbound deadlock
alireza0 Feb 23, 2025
b720472
documentation: Fix typo
libtry486 Feb 23, 2025
06327cc
documentation: Minor fixes
Feb 20, 2025
79edcb5
Add MinIdleSession option to AnyTLS outbound
anytls Feb 24, 2025
fd20fe4
documentation: Fix missing hosts DNS server
nekohasekai Feb 24, 2025
270cf99
Fix DNS fallback
nekohasekai Feb 25, 2025
771d9b4
Fix parsing legacy DNS options
TargetLocked Feb 25, 2025
7bd83f1
documentation: Fix typo
BedrockDigger Feb 25, 2025
ecae486
Update sing-anytls
anytls Feb 25, 2025
dcc7648
Fix missing AnyTLS display name
Zephyruso Feb 25, 2025
632e071
Fix domain resolver on direct outbound
nekohasekai Feb 26, 2025
073cb6f
Move predefined DNS server to rule action
nekohasekai Feb 26, 2025
fa45f2e
Fix anytls dialer usage
nekohasekai Feb 27, 2025
b94a46f
documentation: Fix missing `ip_accept_any` DNS rule option
nekohasekai Mar 6, 2025
d999f44
Fix UDP DNS server crash
nekohasekai Mar 6, 2025
2e2ba4e
Fix hosts DNS server
k9982874 Mar 10, 2025
2e287fa
Update sing-anytls
anytls Mar 10, 2025
63580f0
documentation: Fix typo
Restia-Ashbell Mar 10, 2025
b876dd9
Fix http3 DNS server connecting to wrong address
nekohasekai Mar 13, 2025
f2f959b
Fix DNS lookup context pollution
nekohasekai Mar 13, 2025
3bfbf3e
Make `domain_resolver` optional when only one DNS server is configured
nekohasekai Mar 15, 2025
9833c23
option: Fix marshal legacy DNS options
nekohasekai Mar 15, 2025
0974764
Add ntp protocol sniffing
k9982874 Mar 15, 2025
16e4401
Add wildcard-sni support for shadow-tls inbound
nekohasekai Mar 16, 2025
9ff02d7
Fix unhandled DNS loop
nekohasekai Mar 17, 2025
77b7c8d
Remove map usage in options
nekohasekai Mar 18, 2025
c7abc49
Add wildcard name support for predefined records
nekohasekai Mar 18, 2025
2224eee
Add netns support
nekohasekai Mar 18, 2025
73bab53
Explicitly reject detour to empty direct outbounds
nekohasekai Mar 20, 2025
f899e6c
Update gVisor to 20250319.0
nekohasekai Mar 24, 2025
23f77da
Fail when default DNS server not found
nekohasekai Mar 24, 2025
a11cffc
Fix missing `with_tailscale` in Dockerfile
Mar 26, 2025
cc758a2
Update anytls
anytls Mar 27, 2025
6d3b24f
Fix DNS over QUIC stream close
dyhkwong Mar 27, 2025
223ea51
Fix Tailscale dialer
nekohasekai Mar 28, 2025
6ed53fb
Allow direct outbounds without `domain_resolver`
nekohasekai Apr 1, 2025
383b844
Fix fetch ECH configs
Apr 6, 2025
a268062
Fix UDP DNS server crash
iikira Apr 6, 2025
4a7494d
release: Skip override version for iOS
nekohasekai Apr 8, 2025
88d08e3
Fix DNS dialer
nekohasekai Apr 8, 2025
4d43653
Update anytls
anytls Apr 9, 2025
2011148
Improve local DNS server
nekohasekai Apr 12, 2025
221bba4
Fix missing handling of legacy `domain_strategy` options
nekohasekai Apr 17, 2025
ff23969
documentation: Try to make the play review happy
nekohasekai Apr 17, 2025
052d912
Fix callback deletion in UDP transport
caelansar Apr 19, 2025
bfec5f0
documentation: Minor fixes
Apr 19, 2025
1ca3a80
Fix fetch ECH configs
nekohasekai Apr 22, 2025
ac2bca3
Fix DNS lookup
nekohasekai Apr 25, 2025
1fdd0f6
clash-api: Add more meta api
nekohasekai Apr 25, 2025
30e9a2b
Fix wireguard `listen_port`
nekohasekai Apr 26, 2025
c0e7f2c
Report invalid DNS address early
xchacha20-poly1305 Apr 26, 2025
2de381b
documentation: Fix anytls padding scheme description
nekohasekai Apr 28, 2025
56717b5
Handle EDNS version downgrade
nekohasekai Apr 30, 2025
3670371
Update utls to v1.7.2
nekohasekai May 3, 2025
f421c0e
Update quic-go to v0.51.0
nekohasekai May 5, 2025
eab7fb1
Add control options for listeners
nekohasekai May 5, 2025
47130b0
Update protobuf and grpc
nekohasekai May 5, 2025
a3123ab
Update certmagic and providers
nekohasekai May 5, 2025
deee506
Update minor dependencies
nekohasekai May 5, 2025
68322a2
Fix set edns0 client subnet
nekohasekai May 7, 2025
a68d72d
release: Update Go to 1.24.3
nekohasekai Apr 3, 2025
6500a95
Add TLS record fragment support
nekohasekai May 12, 2025
994c8cc
Add missing `accept_routes` option for Tailscale
nekohasekai May 12, 2025
e432d72
Fix TLS record fragment
Restia-Ashbell May 13, 2025
f2687a7
documentation: Bump version
nekohasekai Apr 28, 2025
78bb59f
Support `GET` method for doh
PuerNya May 15, 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