fix: panic in singbox

This commit is contained in:
Hiddify
2024-01-30 00:42:52 +01:00
parent 5fa28220b4
commit 5e8fbcbdcd
6 changed files with 14 additions and 12 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/hiddify/libcore/config"
"github.com/hiddify/libcore/global"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
"github.com/spf13/cobra"
)
@@ -33,6 +34,10 @@ func init() {
func runSingbox(configPath string) error {
options, err := readConfigAt(configPath)
if err != nil {
return err
}
options.Log = &option.LogOptions{}
options.Log.Disabled = false
options.Log.Level = "trace"
options.Log.Output = ""

View File

@@ -67,7 +67,7 @@ func DefaultConfigOptions() *ConfigOptions {
DirectDnsAddress: "1.1.1.1",
DirectDnsDomainStrategy: option.DomainStrategy(dns.DomainStrategyAsIS),
MixedPort: 2334,
LocalDnsPort: 6450,
LocalDnsPort: 16450,
MTU: 9000,
StrictRoute: true,
TUNStack: "mixed",
@@ -75,7 +75,7 @@ func DefaultConfigOptions() *ConfigOptions {
URLTestInterval: option.Duration(10 * time.Minute),
URLTestIdleTimeout: option.Duration(100 * time.Minute),
EnableClashApi: true,
ClashApiPort: 6756,
ClashApiPort: 16756,
EnableTun: true,
SetSystemProxy: true,
BypassLAN: false,

View File

@@ -62,6 +62,9 @@ func patchOutboundTLSTricks(base option.Outbound, configOpt ConfigOptions, obj o
if outtls, ok := obj["tls"].(map[string]interface{}); ok {
tlsTricks := tls.TLSTricks
if tlsTricks == nil {
tlsTricks = &option.TLSTricksOptions{}
}
tlsTricks.MixedCaseSNI = tlsTricks.MixedCaseSNI || configOpt.TLSTricks.EnableMixedSNICase
if configOpt.TLSTricks.EnablePadding {

View File

@@ -34,6 +34,7 @@ func setupOnce(api unsafe.Pointer) {
func setup(baseDir *C.char, workingDir *C.char, tempDir *C.char, statusPort C.longlong, debug bool) (CErr *C.char) {
defer config.DeferPanicToError("setup", func(err error) {
CErr = C.CString(err.Error())
fmt.Printf("Error: %+v\n", err)
})
Setup(C.GoString(baseDir), C.GoString(workingDir), C.GoString(tempDir))

4
go.mod
View File

@@ -3,7 +3,6 @@ module github.com/hiddify/libcore
go 1.21.5
require (
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb
github.com/hiddify/ray2sing v0.0.0-20240127015415-b0b85dcbf102
github.com/kardianos/service v1.2.2
github.com/sagernet/gomobile v0.1.1
@@ -19,7 +18,6 @@ require (
require (
berty.tech/go-libtor v1.0.385 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/akavel/rsrc v0.10.2 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/caddyserver/certmagic v0.20.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
@@ -105,6 +103,6 @@ require (
lukechampine.com/blake3 v1.2.1 // indirect
)
replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.7.9-0.20240127031116-46118867804b
replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.7.9-0.20240129222136-bef8c180eaef
replace github.com/sagernet/wireguard-go => github.com/hiddify/wireguard-go v0.0.0-20240125143346-481d18d77fe1

9
go.sum
View File

@@ -2,8 +2,6 @@ berty.tech/go-libtor v1.0.385 h1:RWK94C3hZj6Z2GdvePpHJLnWYobFr3bY/OdUJ5aoEXw=
berty.tech/go-libtor v1.0.385/go.mod h1:9swOOQVb+kmvuAlsgWUK/4c52pm69AdbJsxLzk+fJEw=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/caddyserver/certmagic v0.20.0 h1:bTw7LcEZAh9ucYCRXyCpIrSAGplplI0vGYJ4BpCQ/Fc=
@@ -51,10 +49,8 @@ github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a h1:fEBsGL/sjAuJrgah5X
github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb h1:PGufWXXDq9yaev6xX1YQauaO1MV90e6Mpoq1I7Lz/VM=
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb/go.mod h1:QiyDdbZLaJ/mZP4Zwc9g2QsfaEA4o7XvvgZegSci5/E=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240127031116-46118867804b h1:5w6woa/tQkXB9kpuIINZTck6pt8u0/4T+RqNOX0e+aI=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240127031116-46118867804b/go.mod h1:B74zKdMcH3ZEmCi2OUqJTvEXCNtNQjivUEQ20y/5XQM=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240129222136-bef8c180eaef h1:ligclNc3H9xwgaSwnIhxp63nEAvYJ8fNKi7+UTER31E=
github.com/hiddify/hiddify-sing-box v1.7.9-0.20240129222136-bef8c180eaef/go.mod h1:B74zKdMcH3ZEmCi2OUqJTvEXCNtNQjivUEQ20y/5XQM=
github.com/hiddify/ray2sing v0.0.0-20240127015415-b0b85dcbf102 h1:4vKmPE8AyvsBYuZmjGkPnsju8ZzVxEjC9I96uqxX5+o=
github.com/hiddify/ray2sing v0.0.0-20240127015415-b0b85dcbf102/go.mod h1:zYKnf7EoPqrk7JOMO9BApTXxfH0sva8AKfoFywN7uuA=
github.com/hiddify/wireguard-go v0.0.0-20240125143346-481d18d77fe1 h1:neOb+wzHbWLNZ2sHFEV4+GTuqORO7/MndQLFW8FjUY8=
@@ -239,7 +235,6 @@ golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190529164535-6a60838ec259/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=