mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-08-25 03:27:35 +08:00
Compare commits
118 Commits
b7a622cac0
...
e8be848b6f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e8be848b6f | ||
![]() |
1f74074ff5 | ||
![]() |
e3735b6177 | ||
![]() |
4789846113 | ||
![]() |
ad94f94cfb | ||
![]() |
1f9de9f321 | ||
![]() |
344bbf9494 | ||
![]() |
b7e16e70ab | ||
![]() |
391153ecb8 | ||
![]() |
3d821db0b2 | ||
![]() |
344ecd3798 | ||
![]() |
a8a3f863cd | ||
![]() |
ea190ca428 | ||
![]() |
e65b78d1e4 | ||
![]() |
84f7d80da7 | ||
![]() |
2b57eb0b30 | ||
![]() |
9884f81298 | ||
![]() |
8493b4f1da | ||
![]() |
8f1a8add85 | ||
![]() |
85ee6bb266 | ||
![]() |
c4387f7c37 | ||
![]() |
dcb7a5caed | ||
![]() |
ae77cdeedd | ||
![]() |
ec05d4e5e3 | ||
![]() |
1f766d2b89 | ||
![]() |
a5a6c1f7d4 | ||
![]() |
cd43786279 | ||
![]() |
43a211db28 | ||
![]() |
d4f6bdf792 | ||
![]() |
99cf27bedd | ||
![]() |
0a14c5ab1f | ||
![]() |
533b31e1f6 | ||
![]() |
8ed6523872 | ||
![]() |
e5c162222d | ||
![]() |
88babbf3a7 | ||
![]() |
49a03e0b23 | ||
![]() |
9a8e9a34c0 | ||
![]() |
17551db7be | ||
![]() |
83201bb088 | ||
![]() |
f0f1942f1f | ||
![]() |
c7e318be61 | ||
![]() |
2a5e0d0c92 | ||
![]() |
956e485342 | ||
![]() |
23ede74e74 | ||
![]() |
03317e61dd | ||
![]() |
fc81bd9a5b | ||
![]() |
4d406cad84 | ||
![]() |
1f0282de9c | ||
![]() |
b097912418 | ||
![]() |
056c29e73a | ||
![]() |
7aa0a57e60 | ||
![]() |
2673e64bcb | ||
![]() |
3d3c1709d7 | ||
![]() |
9de29a590f | ||
![]() |
a5282b08ec | ||
![]() |
b26c2083bf | ||
![]() |
c1f4c691dc | ||
![]() |
c0ef6eb728 | ||
![]() |
074d61021f | ||
![]() |
246c9d4e40 | ||
![]() |
3e3466c8d7 | ||
![]() |
f73415a732 | ||
![]() |
ecabe9ffe1 | ||
![]() |
2dae1ee284 | ||
![]() |
2afb24d698 | ||
![]() |
ade83ee758 | ||
![]() |
ac9c300ca7 | ||
![]() |
e6eb3cec2b | ||
![]() |
601b79371b | ||
![]() |
56b957d30d | ||
![]() |
eb87b1a708 | ||
![]() |
c0a5561bd4 | ||
![]() |
4a3fe1d41c | ||
![]() |
4cbbcfb04d | ||
![]() |
b3ad4e0e39 | ||
![]() |
49f9c0011d | ||
![]() |
c8c165af87 | ||
![]() |
3f790ff8c9 | ||
![]() |
f2272ae1e7 | ||
![]() |
b40c264c0a | ||
![]() |
29fc8d6a86 | ||
![]() |
46ca27c926 | ||
![]() |
243a5dd477 | ||
![]() |
844e9f09a6 | ||
![]() |
9aa673f79e | ||
![]() |
5abd74ffe3 | ||
![]() |
68a32960bd | ||
![]() |
1e62e3e5d4 | ||
![]() |
40c03a9913 | ||
![]() |
2ea4029868 | ||
![]() |
66f5cdd014 | ||
![]() |
89da2b6355 | ||
![]() |
ee2b8498e6 | ||
![]() |
b1eaf537bd | ||
![]() |
63739c1621 | ||
![]() |
3c8ddee029 | ||
![]() |
23aad70045 | ||
![]() |
0d67b51267 | ||
![]() |
c02f939265 | ||
![]() |
36b84e25c2 | ||
![]() |
9fd4b0e9ae | ||
![]() |
e68cdcc98a | ||
![]() |
2691617c5e | ||
![]() |
04056a1357 | ||
![]() |
faac858e5d | ||
![]() |
a818c8abeb | ||
![]() |
15cbe9fc87 | ||
![]() |
e186f2d31e | ||
![]() |
e9323481a4 | ||
![]() |
a0a41ff2bb | ||
![]() |
549daf9d41 | ||
![]() |
fa370f7d04 | ||
![]() |
795cb17bfa | ||
![]() |
00d8add761 | ||
![]() |
36db31c55a | ||
![]() |
4dbbf59c82 | ||
![]() |
832eb4458d | ||
![]() |
2cf989d306 |
79
.github/workflows/build.yml
vendored
79
.github/workflows/build.yml
vendored
@ -437,24 +437,28 @@ jobs:
|
|||||||
platform: ios
|
platform: ios
|
||||||
scheme: SFI
|
scheme: SFI
|
||||||
destination: 'generic/platform=iOS'
|
destination: 'generic/platform=iOS'
|
||||||
|
archive: build/SFI.xcarchive
|
||||||
upload: SFI/Upload.plist
|
upload: SFI/Upload.plist
|
||||||
- name: macOS
|
- name: macOS
|
||||||
if: ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'app-store'|| inputs.build == 'macOS' }}
|
if: ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'app-store'|| inputs.build == 'macOS' }}
|
||||||
platform: macos
|
platform: macos
|
||||||
scheme: SFM
|
scheme: SFM
|
||||||
destination: 'generic/platform=macOS'
|
destination: 'generic/platform=macOS'
|
||||||
|
archive: build/SFM.xcarchive
|
||||||
upload: SFI/Upload.plist
|
upload: SFI/Upload.plist
|
||||||
- name: tvOS
|
- name: tvOS
|
||||||
if: ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'app-store'|| inputs.build == 'tvOS' }}
|
if: ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'app-store'|| inputs.build == 'tvOS' }}
|
||||||
platform: tvos
|
platform: tvos
|
||||||
scheme: SFT
|
scheme: SFT
|
||||||
destination: 'generic/platform=tvOS'
|
destination: 'generic/platform=tvOS'
|
||||||
|
archive: build/SFT.xcarchive
|
||||||
upload: SFI/Upload.plist
|
upload: SFI/Upload.plist
|
||||||
- name: macOS-standalone
|
- name: macOS-standalone
|
||||||
if: ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'macOS-standalone' }}
|
if: ${{ github.event_name != 'workflow_dispatch' || inputs.build == 'All' || inputs.build == 'Apple' || inputs.build == 'macOS-standalone' }}
|
||||||
platform: macos
|
platform: macos
|
||||||
scheme: SFM.System
|
scheme: SFM.System
|
||||||
destination: 'generic/platform=macOS'
|
destination: 'generic/platform=macOS'
|
||||||
|
archive: build/SFM.System.xcarchive
|
||||||
export: SFM.System/Export.plist
|
export: SFM.System/Export.plist
|
||||||
export_path: build/SFM.System
|
export_path: build/SFM.System
|
||||||
steps:
|
steps:
|
||||||
@ -472,11 +476,11 @@ jobs:
|
|||||||
- name: Setup Xcode stable
|
- name: Setup Xcode stable
|
||||||
if: matrix.if && github.ref == 'refs/heads/main-next'
|
if: matrix.if && github.ref == 'refs/heads/main-next'
|
||||||
run: |-
|
run: |-
|
||||||
sudo xcode-select -s /Applications/Xcode_16.2.app
|
sudo xcode-select -s /Applications/Xcode_16.4.app
|
||||||
- name: Setup Xcode beta
|
- name: Setup Xcode beta
|
||||||
if: matrix.if && github.ref == 'refs/heads/dev-next'
|
if: matrix.if && github.ref == 'refs/heads/dev-next'
|
||||||
run: |-
|
run: |-
|
||||||
sudo xcode-select -s /Applications/Xcode_16.2.app
|
sudo xcode-select -s /Applications/Xcode_16.4.app
|
||||||
- name: Set tag
|
- name: Set tag
|
||||||
if: matrix.if
|
if: matrix.if
|
||||||
run: |-
|
run: |-
|
||||||
@ -539,12 +543,6 @@ jobs:
|
|||||||
export PATH="$PATH:$(go env GOPATH)/bin"
|
export PATH="$PATH:$(go env GOPATH)/bin"
|
||||||
go run ./cmd/internal/build_libbox -target apple -platform ${{ matrix.platform }}
|
go run ./cmd/internal/build_libbox -target apple -platform ${{ matrix.platform }}
|
||||||
mv Libbox.xcframework clients/apple
|
mv Libbox.xcframework clients/apple
|
||||||
- name: Build library with tailscale
|
|
||||||
if: matrix.if && (matrix.name == 'iOS' || matrix.name == 'tvOS')
|
|
||||||
run: |-
|
|
||||||
export PATH="$PATH:$(go env GOPATH)/bin"
|
|
||||||
go run ./cmd/internal/build_libbox -target apple -platform ${{ matrix.platform }} -tailscale
|
|
||||||
mv Libbox.xcframework clients/apple/Libbox.WithTailscale.xcframework
|
|
||||||
- name: Update macOS version
|
- name: Update macOS version
|
||||||
if: matrix.if && matrix.name == 'macOS' && github.event_name == 'workflow_dispatch'
|
if: matrix.if && matrix.name == 'macOS' && github.event_name == 'workflow_dispatch'
|
||||||
run: |-
|
run: |-
|
||||||
@ -563,71 +561,18 @@ jobs:
|
|||||||
-scheme "${{ matrix.scheme }}" \
|
-scheme "${{ matrix.scheme }}" \
|
||||||
-configuration Release \
|
-configuration Release \
|
||||||
-destination "${{ matrix.destination }}" \
|
-destination "${{ matrix.destination }}" \
|
||||||
-archivePath "build/${{ matrix.scheme }}.xcarchive" \
|
-archivePath "${{ matrix.archive }}" \
|
||||||
-allowProvisioningUpdates \
|
-allowProvisioningUpdates \
|
||||||
-authenticationKeyPath $ASC_KEY_PATH \
|
-authenticationKeyPath $ASC_KEY_PATH \
|
||||||
-authenticationKeyID $ASC_KEY_ID \
|
-authenticationKeyID $ASC_KEY_ID \
|
||||||
-authenticationKeyIssuerID $ASC_KEY_ISSUER_ID
|
-authenticationKeyIssuerID $ASC_KEY_ISSUER_ID
|
||||||
- name: Build with Tailscale
|
|
||||||
if: matrix.if && (matrix.name == 'iOS' || matrix.name == 'tvOS')
|
|
||||||
run: |-
|
|
||||||
cd clients/apple
|
|
||||||
mv Libbox.xcframework Libbox.WithoutTailscale.xcframework
|
|
||||||
mv Libbox.WithTailscale.xcframework Libbox.xcframework
|
|
||||||
xcodebuild archive \
|
|
||||||
-scheme "${{ matrix.scheme }}" \
|
|
||||||
-configuration Release \
|
|
||||||
-destination "${{ matrix.destination }}" \
|
|
||||||
-archivePath "build/${{ matrix.scheme }}.WithTailscale.xcarchive" \
|
|
||||||
-allowProvisioningUpdates \
|
|
||||||
-authenticationKeyPath $ASC_KEY_PATH \
|
|
||||||
-authenticationKeyID $ASC_KEY_ID \
|
|
||||||
-authenticationKeyIssuerID $ASC_KEY_ISSUER_ID
|
|
||||||
- name: Export IPA
|
|
||||||
if: matrix.if && (matrix.name == 'iOS' || matrix.name == 'tvOS') && github.event_name == 'workflow_dispatch'
|
|
||||||
run: |-
|
|
||||||
pushd clients/apple
|
|
||||||
xcodebuild -exportArchive \
|
|
||||||
-archivePath "build/${{ matrix.scheme }}.xcarchive" \
|
|
||||||
-exportOptionsPlist SFI/Export.plist \
|
|
||||||
-exportPath "build/${{ matrix.scheme }}" \
|
|
||||||
-allowProvisioningUpdates \
|
|
||||||
-authenticationKeyPath $ASC_KEY_PATH \
|
|
||||||
-authenticationKeyID $ASC_KEY_ID \
|
|
||||||
-authenticationKeyIssuerID $ASC_KEY_ISSUER_ID
|
|
||||||
cp build/${{ matrix.scheme }}/sing-box.ipa .
|
|
||||||
popd
|
|
||||||
mkdir -p dist
|
|
||||||
cp clients/apple/sing-box.ipa "dist/${{ matrix.scheme }}-${{ needs.calculate_version.outputs.version }}.ipa"
|
|
||||||
- name: Export IPA with Tailscale
|
|
||||||
if: matrix.if && (matrix.name == 'iOS' || matrix.name == 'tvOS') && github.event_name == 'workflow_dispatch'
|
|
||||||
run: |-
|
|
||||||
pushd clients/apple
|
|
||||||
xcodebuild -exportArchive \
|
|
||||||
-archivePath "build/${{ matrix.scheme }}.WithTailscale.xcarchive" \
|
|
||||||
-exportOptionsPlist SFI/Export.plist \
|
|
||||||
-exportPath "build/${{ matrix.scheme }}.WithTailscale" \
|
|
||||||
-allowProvisioningUpdates \
|
|
||||||
-authenticationKeyPath $ASC_KEY_PATH \
|
|
||||||
-authenticationKeyID $ASC_KEY_ID \
|
|
||||||
-authenticationKeyIssuerID $ASC_KEY_ISSUER_ID
|
|
||||||
cp build/${{ matrix.scheme }}.WithTailscale/sing-box.ipa .
|
|
||||||
popd
|
|
||||||
mkdir -p dist
|
|
||||||
cp clients/apple/sing-box.ipa "dist/${{ matrix.scheme }}-${{ needs.calculate_version.outputs.version }}-WithTailscale.ipa"
|
|
||||||
- name: Upload IPA
|
|
||||||
if: matrix.if && (matrix.name == 'iOS' || matrix.name == 'tvOS') && github.event_name == 'workflow_dispatch'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: binary-${{ matrix.name }}-ipa
|
|
||||||
path: 'dist'
|
|
||||||
- name: Upload to App Store Connect
|
- name: Upload to App Store Connect
|
||||||
if: matrix.if && matrix.name != 'macOS-standalone' && github.event_name == 'workflow_dispatch'
|
if: matrix.if && matrix.name != 'macOS-standalone' && github.event_name == 'workflow_dispatch'
|
||||||
run: |-
|
run: |-
|
||||||
go run -v ./cmd/internal/app_store_connect cancel_app_store ${{ matrix.platform }}
|
go run -v ./cmd/internal/app_store_connect cancel_app_store ${{ matrix.platform }}
|
||||||
cd clients/apple
|
cd clients/apple
|
||||||
xcodebuild -exportArchive \
|
xcodebuild -exportArchive \
|
||||||
-archivePath "build/${{ matrix.scheme }}.xcarchive" \
|
-archivePath "${{ matrix.archive }}" \
|
||||||
-exportOptionsPlist ${{ matrix.upload }} \
|
-exportOptionsPlist ${{ matrix.upload }} \
|
||||||
-allowProvisioningUpdates \
|
-allowProvisioningUpdates \
|
||||||
-authenticationKeyPath $ASC_KEY_PATH \
|
-authenticationKeyPath $ASC_KEY_PATH \
|
||||||
@ -642,7 +587,7 @@ jobs:
|
|||||||
run: |-
|
run: |-
|
||||||
pushd clients/apple
|
pushd clients/apple
|
||||||
xcodebuild -exportArchive \
|
xcodebuild -exportArchive \
|
||||||
-archivePath "build/${{ matrix.scheme }}.xcarchive" \
|
-archivePath "${{ matrix.archive }}" \
|
||||||
-exportOptionsPlist ${{ matrix.export }} \
|
-exportOptionsPlist ${{ matrix.export }} \
|
||||||
-exportPath "${{ matrix.export_path }}"
|
-exportPath "${{ matrix.export_path }}"
|
||||||
brew install create-dmg
|
brew install create-dmg
|
||||||
@ -655,13 +600,13 @@ jobs:
|
|||||||
--skip-jenkins \
|
--skip-jenkins \
|
||||||
SFM.dmg "${{ matrix.export_path }}/SFM.app"
|
SFM.dmg "${{ matrix.export_path }}/SFM.app"
|
||||||
xcrun notarytool submit "SFM.dmg" --wait --keychain-profile "notarytool-password"
|
xcrun notarytool submit "SFM.dmg" --wait --keychain-profile "notarytool-password"
|
||||||
cd "build/${{ matrix.scheme }}.xcarchive"
|
cd "${{ matrix.archive }}"
|
||||||
zip -r SFM.dSYMs.zip dSYMs
|
zip -r SFM.dSYMs.zip dSYMs
|
||||||
popd
|
popd
|
||||||
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
cp clients/apple/SFM.dmg "dist/SFM-${VERSION}-universal.dmg"
|
cp clients/apple/SFM.dmg "dist/SFM-${VERSION}-universal.dmg"
|
||||||
cp "clients/apple/build/${{ matrix.scheme }}.xcarchive/SFM.dSYMs.zip" "dist/SFM-${VERSION}-universal.dSYMs.zip"
|
cp "clients/apple/${{ matrix.archive }}/SFM.dSYMs.zip" "dist/SFM-${VERSION}-universal.dSYMs.zip"
|
||||||
- name: Upload image
|
- name: Upload image
|
||||||
if: matrix.if && matrix.name == 'macOS-standalone' && github.event_name == 'workflow_dispatch'
|
if: matrix.if && matrix.name == 'macOS-standalone' && github.event_name == 'workflow_dispatch'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@ -670,7 +615,7 @@ jobs:
|
|||||||
path: 'dist'
|
path: 'dist'
|
||||||
upload:
|
upload:
|
||||||
name: Upload builds
|
name: Upload builds
|
||||||
if: always() && github.event_name == 'workflow_dispatch' && (inputs.build == 'All' || inputs.build == 'Binary' || inputs.build == 'Android' || inputs.build == 'Apple' || inputs.build == 'macOS-standalone')
|
if: "!failure() && github.event_name == 'workflow_dispatch' && (inputs.build == 'All' || inputs.build == 'Binary' || inputs.build == 'Android' || inputs.build == 'Apple' || inputs.build == 'macOS-standalone')"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- calculate_version
|
- calculate_version
|
||||||
|
@ -26,7 +26,7 @@ func init() {
|
|||||||
flag.BoolVar(&debugEnabled, "debug", false, "enable debug")
|
flag.BoolVar(&debugEnabled, "debug", false, "enable debug")
|
||||||
flag.StringVar(&target, "target", "android", "target platform")
|
flag.StringVar(&target, "target", "android", "target platform")
|
||||||
flag.StringVar(&platform, "platform", "", "specify platform")
|
flag.StringVar(&platform, "platform", "", "specify platform")
|
||||||
flag.BoolVar(&withTailscale, "tailscale", false, "build tailscale for iOS and tvOS")
|
flag.BoolVar(&withTailscale, "with-tailscale", false, "build tailscale for iOS and tvOS")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -154,7 +154,7 @@ func buildApple() {
|
|||||||
"-target", bindTarget,
|
"-target", bindTarget,
|
||||||
"-libname=box",
|
"-libname=box",
|
||||||
}
|
}
|
||||||
if withTailscale {
|
if !withTailscale {
|
||||||
args = append(args, "-tags-macos="+strings.Join(memcTags, ","))
|
args = append(args, "-tags-macos="+strings.Join(memcTags, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,13 @@ package tls
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
C "github.com/sagernet/sing-box/constant"
|
C "github.com/sagernet/sing-box/constant"
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
"github.com/sagernet/sing/common/logger"
|
||||||
|
|
||||||
"github.com/caddyserver/certmagic"
|
"github.com/caddyserver/certmagic"
|
||||||
"github.com/libdns/alidns"
|
"github.com/libdns/alidns"
|
||||||
@ -37,7 +37,38 @@ func (w *acmeWrapper) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startACME(ctx context.Context, options option.InboundACMEOptions) (*tls.Config, adapter.SimpleLifecycle, error) {
|
type acmeLogWriter struct {
|
||||||
|
logger logger.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *acmeLogWriter) Write(p []byte) (n int, err error) {
|
||||||
|
logLine := strings.ReplaceAll(string(p), " ", ": ")
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(logLine, "error: "):
|
||||||
|
w.logger.Error(logLine[7:])
|
||||||
|
case strings.HasPrefix(logLine, "warn: "):
|
||||||
|
w.logger.Warn(logLine[6:])
|
||||||
|
case strings.HasPrefix(logLine, "info: "):
|
||||||
|
w.logger.Info(logLine[6:])
|
||||||
|
case strings.HasPrefix(logLine, "debug: "):
|
||||||
|
w.logger.Debug(logLine[7:])
|
||||||
|
default:
|
||||||
|
w.logger.Debug(logLine)
|
||||||
|
}
|
||||||
|
return len(p), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *acmeLogWriter) Sync() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func encoderConfig() zapcore.EncoderConfig {
|
||||||
|
config := zap.NewProductionEncoderConfig()
|
||||||
|
config.TimeKey = zapcore.OmitKey
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
func startACME(ctx context.Context, logger logger.Logger, options option.InboundACMEOptions) (*tls.Config, adapter.SimpleLifecycle, error) {
|
||||||
var acmeServer string
|
var acmeServer string
|
||||||
switch options.Provider {
|
switch options.Provider {
|
||||||
case "", "letsencrypt":
|
case "", "letsencrypt":
|
||||||
@ -58,14 +89,15 @@ func startACME(ctx context.Context, options option.InboundACMEOptions) (*tls.Con
|
|||||||
} else {
|
} else {
|
||||||
storage = certmagic.Default.Storage
|
storage = certmagic.Default.Storage
|
||||||
}
|
}
|
||||||
|
zapLogger := zap.New(zapcore.NewCore(
|
||||||
|
zapcore.NewConsoleEncoder(encoderConfig()),
|
||||||
|
&acmeLogWriter{logger: logger},
|
||||||
|
zap.DebugLevel,
|
||||||
|
))
|
||||||
config := &certmagic.Config{
|
config := &certmagic.Config{
|
||||||
DefaultServerName: options.DefaultServerName,
|
DefaultServerName: options.DefaultServerName,
|
||||||
Storage: storage,
|
Storage: storage,
|
||||||
Logger: zap.New(zapcore.NewCore(
|
Logger: zapLogger,
|
||||||
zapcore.NewConsoleEncoder(zap.NewProductionEncoderConfig()),
|
|
||||||
os.Stderr,
|
|
||||||
zap.InfoLevel,
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
acmeConfig := certmagic.ACMEIssuer{
|
acmeConfig := certmagic.ACMEIssuer{
|
||||||
CA: acmeServer,
|
CA: acmeServer,
|
||||||
@ -75,7 +107,7 @@ func startACME(ctx context.Context, options option.InboundACMEOptions) (*tls.Con
|
|||||||
DisableTLSALPNChallenge: options.DisableTLSALPNChallenge,
|
DisableTLSALPNChallenge: options.DisableTLSALPNChallenge,
|
||||||
AltHTTPPort: int(options.AlternativeHTTPPort),
|
AltHTTPPort: int(options.AlternativeHTTPPort),
|
||||||
AltTLSALPNPort: int(options.AlternativeTLSPort),
|
AltTLSALPNPort: int(options.AlternativeTLSPort),
|
||||||
Logger: config.Logger,
|
Logger: zapLogger,
|
||||||
}
|
}
|
||||||
if dnsOptions := options.DNS01Challenge; dnsOptions != nil && dnsOptions.Provider != "" {
|
if dnsOptions := options.DNS01Challenge; dnsOptions != nil && dnsOptions.Provider != "" {
|
||||||
var solver certmagic.DNS01Solver
|
var solver certmagic.DNS01Solver
|
||||||
@ -103,6 +135,7 @@ func startACME(ctx context.Context, options option.InboundACMEOptions) (*tls.Con
|
|||||||
GetConfigForCert: func(certificate certmagic.Certificate) (*certmagic.Config, error) {
|
GetConfigForCert: func(certificate certmagic.Certificate) (*certmagic.Config, error) {
|
||||||
return config, nil
|
return config, nil
|
||||||
},
|
},
|
||||||
|
Logger: zapLogger,
|
||||||
})
|
})
|
||||||
config = certmagic.New(cache, *config)
|
config = certmagic.New(cache, *config)
|
||||||
var tlsConfig *tls.Config
|
var tlsConfig *tls.Config
|
||||||
|
@ -9,8 +9,9 @@ import (
|
|||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
"github.com/sagernet/sing/common/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func startACME(ctx context.Context, options option.InboundACMEOptions) (*tls.Config, adapter.SimpleLifecycle, error) {
|
func startACME(ctx context.Context, logger logger.Logger, options option.InboundACMEOptions) (*tls.Config, adapter.SimpleLifecycle, error) {
|
||||||
return nil, nil, E.New(`ACME is not included in this build, rebuild with -tags with_acme`)
|
return nil, nil, E.New(`ACME is not included in this build, rebuild with -tags with_acme`)
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func NewSTDServer(ctx context.Context, logger log.Logger, options option.Inbound
|
|||||||
var err error
|
var err error
|
||||||
if options.ACME != nil && len(options.ACME.Domain) > 0 {
|
if options.ACME != nil && len(options.ACME.Domain) > 0 {
|
||||||
//nolint:staticcheck
|
//nolint:staticcheck
|
||||||
tlsConfig, acmeService, err = startACME(ctx, common.PtrValueOrDefault(options.ACME))
|
tlsConfig, acmeService, err = startACME(ctx, logger, common.PtrValueOrDefault(options.ACME))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,7 @@ func NewHTTPSRaw(
|
|||||||
var transport *http.Transport
|
var transport *http.Transport
|
||||||
if tlsConfig != nil {
|
if tlsConfig != nil {
|
||||||
transport = &http.Transport{
|
transport = &http.Transport{
|
||||||
|
IdleConnTimeout: C.TCPKeepAliveInitial,
|
||||||
ForceAttemptHTTP2: true,
|
ForceAttemptHTTP2: true,
|
||||||
DialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
DialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
tcpConn, hErr := dialer.DialContext(ctx, network, serverAddr)
|
tcpConn, hErr := dialer.DialContext(ctx, network, serverAddr)
|
||||||
@ -138,6 +139,7 @@ func NewHTTPSRaw(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
transport = &http.Transport{
|
transport = &http.Transport{
|
||||||
|
IdleConnTimeout: C.TCPKeepAliveInitial,
|
||||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
return dialer.DialContext(ctx, network, serverAddr)
|
return dialer.DialContext(ctx, network, serverAddr)
|
||||||
},
|
},
|
||||||
|
@ -20,7 +20,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func dnsReadConfig(_ context.Context, _ string) *dnsConfig {
|
func dnsReadConfig(_ context.Context, _ string) *dnsConfig {
|
||||||
if C.res_init() != 0 {
|
var state C.res_state
|
||||||
|
if C.res_ninit(state) != 0 {
|
||||||
return &dnsConfig{
|
return &dnsConfig{
|
||||||
servers: defaultNS,
|
servers: defaultNS,
|
||||||
search: dnsDefaultSearch(),
|
search: dnsDefaultSearch(),
|
||||||
@ -33,10 +34,10 @@ func dnsReadConfig(_ context.Context, _ string) *dnsConfig {
|
|||||||
conf := &dnsConfig{
|
conf := &dnsConfig{
|
||||||
ndots: 1,
|
ndots: 1,
|
||||||
timeout: 5 * time.Second,
|
timeout: 5 * time.Second,
|
||||||
attempts: int(C._res.retry),
|
attempts: int(state.retry),
|
||||||
}
|
}
|
||||||
for i := 0; i < int(C._res.nscount); i++ {
|
for i := 0; i < int(state.nscount); i++ {
|
||||||
ns := C._res.nsaddr_list[i]
|
ns := state.nsaddr_list[i]
|
||||||
addr := C.inet_ntoa(ns.sin_addr)
|
addr := C.inet_ntoa(ns.sin_addr)
|
||||||
if addr == nil {
|
if addr == nil {
|
||||||
continue
|
continue
|
||||||
@ -44,7 +45,7 @@ func dnsReadConfig(_ context.Context, _ string) *dnsConfig {
|
|||||||
conf.servers = append(conf.servers, C.GoString(addr))
|
conf.servers = append(conf.servers, C.GoString(addr))
|
||||||
}
|
}
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
search := C._res.dnsrch[i]
|
search := state.dnsrch[i]
|
||||||
if search == nil {
|
if search == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
icon: material/alert-decagram
|
icon: material/alert-decagram
|
||||||
---
|
---
|
||||||
|
|
||||||
#### 1.12.0-beta.28
|
#### 1.12.0-beta.29
|
||||||
|
|
||||||
* Fixes and improvements
|
* Fixes and improvements
|
||||||
|
|
||||||
|
@ -19,21 +19,13 @@ platform-specific function implementation, such as TUN transparent proxy impleme
|
|||||||
## :material-download: Download
|
## :material-download: Download
|
||||||
|
|
||||||
* [App Store](https://apps.apple.com/app/sing-box-vt/id6673731168)
|
* [App Store](https://apps.apple.com/app/sing-box-vt/id6673731168)
|
||||||
* TestFlight (Beta) **1**
|
* TestFlight (Beta)
|
||||||
* [GitHub Releases](https://github.com/SagerNet/sing-box/releases) **2**
|
|
||||||
|
|
||||||
**1**:
|
|
||||||
|
|
||||||
TestFlight quota is only available to [sponsors](https://github.com/sponsors/nekohasekai)
|
TestFlight quota is only available to [sponsors](https://github.com/sponsors/nekohasekai)
|
||||||
(one-time sponsorships are accepted).
|
(one-time sponsorships are accepted).
|
||||||
Once you donate, you can get an invitation by join our Telegram group for sponsors from [@yet_another_sponsor_bot](https://t.me/yet_another_sponsor_bot)
|
Once you donate, you can get an invitation by join our Telegram group for sponsors from [@yet_another_sponsor_bot](https://t.me/yet_another_sponsor_bot)
|
||||||
or sending us your Apple ID [via email](mailto:contact@sagernet.org).
|
or sending us your Apple ID [via email](mailto:contact@sagernet.org).
|
||||||
|
|
||||||
**2**:
|
|
||||||
|
|
||||||
You can now download compiled IPAs for iOS and tvOS directly from GitHub releases,
|
|
||||||
but you need to purchase the **Apple Developer Program** to install them through AltStore or SideStore.
|
|
||||||
|
|
||||||
## :material-file-download: Download (macOS standalone version)
|
## :material-file-download: Download (macOS standalone version)
|
||||||
|
|
||||||
* [Homebrew Cask](https://formulae.brew.sh/cask/sfm)
|
* [Homebrew Cask](https://formulae.brew.sh/cask/sfm)
|
||||||
|
@ -25,7 +25,7 @@ icon: material/new-box
|
|||||||
|
|
||||||
| 类型 | 格式 |
|
| 类型 | 格式 |
|
||||||
|-------------|---------------------------|
|
|-------------|---------------------------|
|
||||||
| `wireguard` | [WireGuard](./wiregaurd/) |
|
| `wireguard` | [WireGuard](./wireguard/) |
|
||||||
| `tailscale` | [Tailscale](./tailscale/) |
|
| `tailscale` | [Tailscale](./tailscale/) |
|
||||||
|
|
||||||
#### tag
|
#### tag
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
{
|
{
|
||||||
"external_controller": "0.0.0.0:9090",
|
"external_controller": "0.0.0.0:9090",
|
||||||
"external_ui": "dashboard"
|
"external_ui": "dashboard"
|
||||||
// external_ui_download_detour: "direct"
|
// "external_ui_download_detour": "direct"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
{
|
{
|
||||||
"external_controller": "0.0.0.0:9090",
|
"external_controller": "0.0.0.0:9090",
|
||||||
"external_ui": "dashboard"
|
"external_ui": "dashboard"
|
||||||
// external_ui_download_detour: "direct"
|
// "external_ui_download_detour": "direct"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -94,18 +94,13 @@ flowchart TB
|
|||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"tag": "google",
|
"tag": "google",
|
||||||
"address": "tls://8.8.8.8"
|
"type": "tls",
|
||||||
|
"server": "8.8.8.8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tag": "local",
|
"tag": "local",
|
||||||
"address": "223.5.5.5",
|
"type": "udp",
|
||||||
"detour": "direct"
|
"server": "223.5.5.5"
|
||||||
}
|
|
||||||
],
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"outbound": "any",
|
|
||||||
"server": "local"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"strategy": "ipv4_only"
|
"strategy": "ipv4_only"
|
||||||
@ -115,7 +110,8 @@ flowchart TB
|
|||||||
"type": "tun",
|
"type": "tun",
|
||||||
"inet4_address": "172.19.0.1/30",
|
"inet4_address": "172.19.0.1/30",
|
||||||
"auto_route": true,
|
"auto_route": true,
|
||||||
"strict_route": false
|
// "auto_redirect": true, // On linux
|
||||||
|
"strict_route": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outbounds": [
|
"outbounds": [
|
||||||
@ -123,25 +119,23 @@ flowchart TB
|
|||||||
{
|
{
|
||||||
"type": "direct",
|
"type": "direct",
|
||||||
"tag": "direct"
|
"tag": "direct"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "dns",
|
|
||||||
"tag": "dns-out"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"route": {
|
"route": {
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"protocol": "dns",
|
"action": "sniff"
|
||||||
"outbound": "dns-out"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"geoip": [
|
"protocol": "dns",
|
||||||
"private"
|
"action": "hijack-dns"
|
||||||
],
|
},
|
||||||
|
{
|
||||||
|
"ip_is_private": true,
|
||||||
"outbound": "direct"
|
"outbound": "direct"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"default_domain_resolver": "local",
|
||||||
"auto_detect_interface": true
|
"auto_detect_interface": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,18 +149,13 @@ flowchart TB
|
|||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"tag": "google",
|
"tag": "google",
|
||||||
"address": "tls://8.8.8.8"
|
"type": "tls",
|
||||||
|
"server": "8.8.8.8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tag": "local",
|
"tag": "local",
|
||||||
"address": "223.5.5.5",
|
"type": "udp",
|
||||||
"detour": "direct"
|
"server": "223.5.5.5"
|
||||||
}
|
|
||||||
],
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"outbound": "any",
|
|
||||||
"server": "local"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -176,7 +165,8 @@ flowchart TB
|
|||||||
"inet4_address": "172.19.0.1/30",
|
"inet4_address": "172.19.0.1/30",
|
||||||
"inet6_address": "fdfe:dcba:9876::1/126",
|
"inet6_address": "fdfe:dcba:9876::1/126",
|
||||||
"auto_route": true,
|
"auto_route": true,
|
||||||
"strict_route": false
|
// "auto_redirect": true, // On linux
|
||||||
|
"strict_route": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outbounds": [
|
"outbounds": [
|
||||||
@ -184,25 +174,23 @@ flowchart TB
|
|||||||
{
|
{
|
||||||
"type": "direct",
|
"type": "direct",
|
||||||
"tag": "direct"
|
"tag": "direct"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "dns",
|
|
||||||
"tag": "dns-out"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"route": {
|
"route": {
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"protocol": "dns",
|
"action": "sniff"
|
||||||
"outbound": "dns-out"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"geoip": [
|
"protocol": "dns",
|
||||||
"private"
|
"action": "hijack-dns"
|
||||||
],
|
},
|
||||||
|
{
|
||||||
|
"ip_is_private": true,
|
||||||
"outbound": "direct"
|
"outbound": "direct"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"default_domain_resolver": "local",
|
||||||
"auto_detect_interface": true
|
"auto_detect_interface": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,23 +204,22 @@ flowchart TB
|
|||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"tag": "google",
|
"tag": "google",
|
||||||
"address": "tls://8.8.8.8"
|
"type": "tls",
|
||||||
|
"server": "8.8.8.8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tag": "local",
|
"tag": "local",
|
||||||
"address": "223.5.5.5",
|
"type": "udp",
|
||||||
"detour": "direct"
|
"server": "223.5.5.5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tag": "remote",
|
"tag": "remote",
|
||||||
"address": "fakeip"
|
"type": "fakeip",
|
||||||
|
"inet4_range": "198.18.0.0/15",
|
||||||
|
"inet6_range": "fc00::/18"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
|
||||||
"outbound": "any",
|
|
||||||
"server": "local"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"query_type": [
|
"query_type": [
|
||||||
"A",
|
"A",
|
||||||
@ -241,11 +228,6 @@ flowchart TB
|
|||||||
"server": "remote"
|
"server": "remote"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fakeip": {
|
|
||||||
"enabled": true,
|
|
||||||
"inet4_range": "198.18.0.0/15",
|
|
||||||
"inet6_range": "fc00::/18"
|
|
||||||
},
|
|
||||||
"independent_cache": true
|
"independent_cache": true
|
||||||
},
|
},
|
||||||
"inbounds": [
|
"inbounds": [
|
||||||
@ -254,6 +236,7 @@ flowchart TB
|
|||||||
"inet4_address": "172.19.0.1/30",
|
"inet4_address": "172.19.0.1/30",
|
||||||
"inet6_address": "fdfe:dcba:9876::1/126",
|
"inet6_address": "fdfe:dcba:9876::1/126",
|
||||||
"auto_route": true,
|
"auto_route": true,
|
||||||
|
// "auto_redirect": true, // On linux
|
||||||
"strict_route": true
|
"strict_route": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -262,25 +245,23 @@ flowchart TB
|
|||||||
{
|
{
|
||||||
"type": "direct",
|
"type": "direct",
|
||||||
"tag": "direct"
|
"tag": "direct"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "dns",
|
|
||||||
"tag": "dns-out"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"route": {
|
"route": {
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"protocol": "dns",
|
"action": "sniff"
|
||||||
"outbound": "dns-out"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"geoip": [
|
"protocol": "dns",
|
||||||
"private"
|
"action": "hijack-dns"
|
||||||
],
|
},
|
||||||
|
{
|
||||||
|
"ip_is_private": true,
|
||||||
"outbound": "direct"
|
"outbound": "direct"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"default_domain_resolver": "local",
|
||||||
"auto_detect_interface": true
|
"auto_detect_interface": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,54 +271,6 @@ flowchart TB
|
|||||||
|
|
||||||
=== ":material-dns: DNS rules"
|
=== ":material-dns: DNS rules"
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"dns": {
|
|
||||||
"servers": [
|
|
||||||
{
|
|
||||||
"tag": "google",
|
|
||||||
"address": "tls://8.8.8.8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tag": "local",
|
|
||||||
"address": "223.5.5.5",
|
|
||||||
"detour": "direct"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rules": [
|
|
||||||
{
|
|
||||||
"outbound": "any",
|
|
||||||
"server": "local"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"clash_mode": "Direct",
|
|
||||||
"server": "local"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"clash_mode": "Global",
|
|
||||||
"server": "google"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"rule_set": "geosite-geolocation-cn",
|
|
||||||
"server": "local"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"route": {
|
|
||||||
"rule_set": [
|
|
||||||
{
|
|
||||||
"type": "remote",
|
|
||||||
"tag": "geosite-geolocation-cn",
|
|
||||||
"format": "binary",
|
|
||||||
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
=== ":material-dns: DNS rules (Enhanced, but slower) (1.9.0+)"
|
|
||||||
|
|
||||||
=== ":material-shield-off: With DNS leaks"
|
=== ":material-shield-off: With DNS leaks"
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@ -346,35 +279,20 @@ flowchart TB
|
|||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"tag": "google",
|
"tag": "google",
|
||||||
"address": "tls://8.8.8.8"
|
"type": "tls",
|
||||||
|
"server": "8.8.8.8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tag": "local",
|
"tag": "local",
|
||||||
"address": "https://223.5.5.5/dns-query",
|
"type": "https",
|
||||||
"detour": "direct"
|
"server": "223.5.5.5"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
|
||||||
"outbound": "any",
|
|
||||||
"server": "local"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"clash_mode": "Direct",
|
|
||||||
"server": "local"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"clash_mode": "Global",
|
|
||||||
"server": "google"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"rule_set": "geosite-geolocation-cn",
|
"rule_set": "geosite-geolocation-cn",
|
||||||
"server": "local"
|
"server": "local"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"clash_mode": "Default",
|
|
||||||
"server": "google"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "logical",
|
"type": "logical",
|
||||||
"mode": "and",
|
"mode": "and",
|
||||||
@ -392,6 +310,7 @@ flowchart TB
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"route": {
|
"route": {
|
||||||
|
"default_domain_resolver": "local",
|
||||||
"rule_set": [
|
"rule_set": [
|
||||||
{
|
{
|
||||||
"type": "remote",
|
"type": "remote",
|
||||||
@ -425,35 +344,24 @@ flowchart TB
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
=== ":material-security: Without DNS leaks, but slower (1.9.0-alpha.2+)"
|
=== ":material-security: Without DNS leaks, but slower"
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"dns": {
|
"dns": {
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
"tag": "google",
|
"tag": "google",
|
||||||
"address": "tls://8.8.8.8"
|
"type": "tls",
|
||||||
|
"server": "8.8.8.8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tag": "local",
|
"tag": "local",
|
||||||
"address": "https://223.5.5.5/dns-query",
|
"type": "https",
|
||||||
"detour": "direct"
|
"server": "223.5.5.5"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
|
||||||
"outbound": "any",
|
|
||||||
"server": "local"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"clash_mode": "Direct",
|
|
||||||
"server": "local"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"clash_mode": "Global",
|
|
||||||
"server": "google"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"rule_set": "geosite-geolocation-cn",
|
"rule_set": "geosite-geolocation-cn",
|
||||||
"server": "local"
|
"server": "local"
|
||||||
@ -476,6 +384,7 @@ flowchart TB
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"route": {
|
"route": {
|
||||||
|
"default_domain_resolver": "local",
|
||||||
"rule_set": [
|
"rule_set": [
|
||||||
{
|
{
|
||||||
"type": "remote",
|
"type": "remote",
|
||||||
@ -517,14 +426,13 @@ flowchart TB
|
|||||||
{
|
{
|
||||||
"type": "direct",
|
"type": "direct",
|
||||||
"tag": "direct"
|
"tag": "direct"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "block",
|
|
||||||
"tag": "block"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"route": {
|
"route": {
|
||||||
"rules": [
|
"rules": [
|
||||||
|
{
|
||||||
|
"action": "sniff"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "logical",
|
"type": "logical",
|
||||||
"mode": "or",
|
"mode": "or",
|
||||||
@ -536,20 +444,12 @@ flowchart TB
|
|||||||
"port": 53
|
"port": 53
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outbound": "dns"
|
"action": "hijack-dns"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ip_is_private": true,
|
"ip_is_private": true,
|
||||||
"outbound": "direct"
|
"outbound": "direct"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"clash_mode": "Direct",
|
|
||||||
"outbound": "direct"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"clash_mode": "Global",
|
|
||||||
"outbound": "default"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "logical",
|
"type": "logical",
|
||||||
"mode": "or",
|
"mode": "or",
|
||||||
@ -565,12 +465,23 @@ flowchart TB
|
|||||||
"protocol": "stun"
|
"protocol": "stun"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outbound": "block"
|
"action": "reject"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule_set": [
|
"rule_set": "geosite-geolocation-cn",
|
||||||
"geoip-cn",
|
"outbound": "direct"
|
||||||
"geosite-geolocation-cn"
|
},
|
||||||
|
{
|
||||||
|
"type": "logical",
|
||||||
|
"mode": "and",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"rule_set": "geoip-cn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rule_set": "geosite-geolocation-!cn",
|
||||||
|
"invert": true
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"outbound": "direct"
|
"outbound": "direct"
|
||||||
}
|
}
|
||||||
@ -591,4 +502,4 @@ flowchart TB
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -205,6 +205,10 @@ func (h *inboundTransportHandler) NewConnectionEx(ctx context.Context, conn net.
|
|||||||
var metadata adapter.InboundContext
|
var metadata adapter.InboundContext
|
||||||
metadata.Source = source
|
metadata.Source = source
|
||||||
metadata.Destination = destination
|
metadata.Destination = destination
|
||||||
|
//nolint:staticcheck
|
||||||
|
metadata.InboundDetour = h.listener.ListenOptions().Detour
|
||||||
|
//nolint:staticcheck
|
||||||
|
metadata.InboundOptions = h.listener.ListenOptions().InboundOptions
|
||||||
h.logger.InfoContext(ctx, "inbound connection from ", metadata.Source)
|
h.logger.InfoContext(ctx, "inbound connection from ", metadata.Source)
|
||||||
(*Inbound)(h).NewConnectionEx(ctx, conn, metadata, onClose)
|
(*Inbound)(h).NewConnectionEx(ctx, conn, metadata, onClose)
|
||||||
}
|
}
|
||||||
|
@ -219,6 +219,10 @@ func (h *inboundTransportHandler) NewConnectionEx(ctx context.Context, conn net.
|
|||||||
var metadata adapter.InboundContext
|
var metadata adapter.InboundContext
|
||||||
metadata.Source = source
|
metadata.Source = source
|
||||||
metadata.Destination = destination
|
metadata.Destination = destination
|
||||||
|
//nolint:staticcheck
|
||||||
|
metadata.InboundDetour = h.listener.ListenOptions().Detour
|
||||||
|
//nolint:staticcheck
|
||||||
|
metadata.InboundOptions = h.listener.ListenOptions().InboundOptions
|
||||||
h.logger.InfoContext(ctx, "inbound connection from ", metadata.Source)
|
h.logger.InfoContext(ctx, "inbound connection from ", metadata.Source)
|
||||||
(*Inbound)(h).NewConnectionEx(ctx, conn, metadata, onClose)
|
(*Inbound)(h).NewConnectionEx(ctx, conn, metadata, onClose)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user