Skip to content

Commit 0ac46f4

Browse files
committed
test sing-box 1.3-b12
1 parent f6d60e9 commit 0ac46f4

4 files changed

Lines changed: 11 additions & 48 deletions

File tree

buildScript/lib/core/get_source_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if [ ! -z $ENV_NB4A ]; then
2-
export COMMIT_SING_BOX_EXTRA="b80bbaf5c70acb992ba1c9a3d5e165992eefe131"
2+
export COMMIT_SING_BOX_EXTRA="d663cfa6b9f721d306ec3972460b61bb2c935685"
33
fi
44

55
if [ ! -z $ENV_SING_BOX_EXTRA ]; then

libcore/box.go

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,25 @@ import (
77
"io"
88
"libcore/device"
99
"log"
10-
"net/http"
11-
"reflect"
1210
"runtime"
1311
"runtime/debug"
1412
"strings"
1513
"time"
16-
"unsafe"
1714

1815
"github.com/matsuridayo/sing-box-extra/boxbox"
1916
_ "github.com/matsuridayo/sing-box-extra/distro/all"
2017

21-
"github.com/matsuridayo/libneko/neko_common"
2218
"github.com/matsuridayo/libneko/protect_server"
2319
"github.com/matsuridayo/libneko/speedtest"
2420
"github.com/matsuridayo/sing-box-extra/boxapi"
2521

2622
"github.com/sagernet/sing-box/common/dialer/conntrack"
27-
sblog "github.com/sagernet/sing-box/log"
2823
"github.com/sagernet/sing-box/option"
2924
"github.com/sagernet/sing-box/outbound"
3025
)
3126

3227
var mainInstance *BoxInstance
3328

34-
func init() {
35-
neko_common.GetProxyHttpClient = func() *http.Client {
36-
if mainInstance == nil {
37-
return nil
38-
}
39-
return boxapi.GetProxyHttpClient(mainInstance.Box)
40-
}
41-
}
42-
4329
func VersionBox() string {
4430
version := []string{
4531
"sing-box-extra: " + boxbox.Version(),
@@ -110,13 +96,7 @@ func NewSingBoxInstance(config string) (b *BoxInstance, err error) {
11096
}
11197

11298
// fuck your sing-box platformFormatter
113-
logFactory_ := reflect.Indirect(reflect.ValueOf(instance)).FieldByName("logFactory")
114-
logFactory_ = reflect.NewAt(logFactory_.Type(), unsafe.Pointer(logFactory_.UnsafeAddr())).Elem() // get unexported logFactory
115-
logFactory_ = logFactory_.Elem().Elem() // get struct
116-
platformFormatter_ := logFactory_.FieldByName("platformFormatter")
117-
platformFormatter_ = reflect.NewAt(platformFormatter_.Type(), unsafe.Pointer(platformFormatter_.UnsafeAddr())) // get unexported Formatter
118-
platformFormatter := platformFormatter_.Interface().(*sblog.Formatter)
119-
platformFormatter.DisableColors = true
99+
instance.GetLogPlatformFormatter().DisableColors = true
120100

121101
// selector
122102
if proxy, ok := b.Router().Outbound("proxy"); ok {
@@ -158,25 +138,8 @@ func (b *BoxInstance) Close() (err error) {
158138
}
159139

160140
// close box
161-
t := time.NewTimer(time.Second * 2)
162-
c := make(chan struct{}, 1)
163-
disableSingBoxLog = true
164-
165-
go func(cancel context.CancelFunc, closer io.Closer) {
166-
cancel()
167-
closer.Close()
168-
c <- struct{}{}
169-
close(c)
170-
}(b.cancel, b.Box)
171-
172-
select {
173-
case <-t.C:
174-
log.Println("[Warning] sing-box close takes longer than expected.")
175-
case <-c:
176-
}
141+
b.CloseWithTimeout(b.cancel, time.Second*2, log.Println)
177142

178-
disableSingBoxLog = false
179-
t.Stop()
180143
return nil
181144
}
182145

@@ -215,9 +178,9 @@ func UrlTest(i *BoxInstance, link string, timeout int32) (latency int32, err err
215178
defer device.DeferPanicToError("box.UrlTest", func(err_ error) { err = err_ })
216179
if i == nil {
217180
// test current
218-
return speedtest.UrlTest(neko_common.GetProxyHttpClient(), link, timeout)
181+
return speedtest.UrlTest(boxapi.CreateProxyHttpClient(mainInstance.Box), link, timeout)
219182
}
220-
return speedtest.UrlTest(boxapi.GetProxyHttpClient(i.Box), link, timeout)
183+
return speedtest.UrlTest(boxapi.CreateProxyHttpClient(i.Box), link, timeout)
221184
}
222185

223186
var protectCloser io.Closer

libcore/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/matsuridayo/libneko v1.0.0 // replaced
88
github.com/matsuridayo/sing-box-extra v1.0.0 // replaced
99
github.com/miekg/dns v1.1.54
10-
github.com/sagernet/sing v0.2.5-0.20230509045155-f60c80c56f21
10+
github.com/sagernet/sing v0.2.5-0.20230512033628-9be7806bab51
1111
github.com/sagernet/sing-box v1.0.0 // replaced
1212
// github.com/sagernet/sing-dns v1.0.0 // replaced
1313
github.com/sagernet/sing-tun v0.1.5-0.20230509102026-91df97aee204
@@ -63,7 +63,7 @@ require (
6363
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
6464
github.com/sagernet/sing-mux v0.0.0-20230425130511-b0a6ffd8406f // indirect
6565
github.com/sagernet/sing-shadowsocks v0.2.2-0.20230509053848-d83f8fe1194c // indirect
66-
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230510062121-18b8e5920cb2 // indirect
66+
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230512030659-23bb92c1eb97 // indirect
6767
github.com/sagernet/sing-shadowtls v0.1.2-0.20230417103049-4f682e05f19b // indirect
6868
github.com/sagernet/sing-vmess v0.1.5-0.20230417103030-8c3070ae3fb3 // indirect
6969
github.com/sagernet/smux v0.0.0-20230312102458-337ec2a5af37 // indirect

libcore/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@ github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byL
113113
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
114114
github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY=
115115
github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk=
116-
github.com/sagernet/sing v0.2.5-0.20230509045155-f60c80c56f21 h1:voT2nOCvukNfRLn9KxQYEYSu9/OZsCqEmD6tEFJAnBw=
117-
github.com/sagernet/sing v0.2.5-0.20230509045155-f60c80c56f21/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w=
116+
github.com/sagernet/sing v0.2.5-0.20230512033628-9be7806bab51 h1:ySJuouhl890pBZly51Hkb2mbDnz+qSQCLF5j+4IFHis=
117+
github.com/sagernet/sing v0.2.5-0.20230512033628-9be7806bab51/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w=
118118
github.com/sagernet/sing-dns v0.1.5-0.20230426113254-25d948c44223 h1:L4eMuM07iSHY3UCknFnuFuHoe5clZuF2Xnf2wwA6Lwc=
119119
github.com/sagernet/sing-dns v0.1.5-0.20230426113254-25d948c44223/go.mod h1:ZKuuqgsHRxDahYrzgSgy4vIAGGuKPlIf4hLcNzYzLkY=
120120
github.com/sagernet/sing-mux v0.0.0-20230425130511-b0a6ffd8406f h1:iEpOTgBTjt0vZJVXMTqYq13XyIu/337TWbq6WZ3CMWc=
121121
github.com/sagernet/sing-mux v0.0.0-20230425130511-b0a6ffd8406f/go.mod h1:pF+RnLvCAOhECrvauy6LYOpBakJ/vuaF1Wm4lPsWryI=
122122
github.com/sagernet/sing-shadowsocks v0.2.2-0.20230509053848-d83f8fe1194c h1:EiQ+i4gdPpSI8D2YUlOeBZA3R1ZGi0ShSLSXoSd/13A=
123123
github.com/sagernet/sing-shadowsocks v0.2.2-0.20230509053848-d83f8fe1194c/go.mod h1:UJjvQGw0lyYaDGIDvUraL16fwaAEH1WFw1Y6sUcMPog=
124-
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230510062121-18b8e5920cb2 h1:ORW4JxNuKAEPtKSGRMS+Qj8tnKqn074FPupLLOrG/UI=
125-
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230510062121-18b8e5920cb2/go.mod h1:i6Eoor37Cy4JKBcelMMFfUVBNjqRYuvcqOBjUI3Zw80=
124+
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230512030659-23bb92c1eb97 h1:Mc5dbIMFF3ph3JofkBv3loq1qdBLktER+LL0IpoLm5M=
125+
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230512030659-23bb92c1eb97/go.mod h1:i6Eoor37Cy4JKBcelMMFfUVBNjqRYuvcqOBjUI3Zw80=
126126
github.com/sagernet/sing-shadowtls v0.1.2-0.20230417103049-4f682e05f19b h1:ouW/6IDCrxkBe19YSbdCd7buHix7b+UZ6BM4Zz74XF4=
127127
github.com/sagernet/sing-shadowtls v0.1.2-0.20230417103049-4f682e05f19b/go.mod h1:oG8bPerYI6cZ74KquY3DvA7ynECyrILPBnce6wtBqeI=
128128
github.com/sagernet/sing-tun v0.1.5-0.20230509102026-91df97aee204 h1:V8eGGmvyjRtFDNmarASZGsTyyXz/gc/zStSxW/knc9E=

0 commit comments

Comments
 (0)