Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 506a1c5

Browse files
committed
update core
1 parent 6be1fd0 commit 506a1c5

7 files changed

Lines changed: 76 additions & 59 deletions

File tree

buildScript/lib/core/get_source.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ popd
2222

2323
####
2424

25+
if [ ! -d "sing-quic" ]; then
26+
git clone --no-checkout https://github.com/MatsuriDayo/sing-quic.git
27+
fi
28+
pushd sing-quic
29+
git checkout "$COMMIT_SING_QUIC"
30+
31+
popd
32+
33+
####
34+
2535
if [ ! -d "libneko" ]; then
2636
git clone --no-checkout https://github.com/MatsuriDayo/libneko.git
2737
fi
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
export COMMIT_SING_BOX="cf36758f11b7c144e1211801753cc91f06ff2906"
1+
export COMMIT_SING_BOX="06557f6cef23160668122a17a818b378b5a216b5"
2+
export COMMIT_SING_QUIC="b49ce60d9b3622d5238fee96bfd3c5f6e3915b42"
23
export COMMIT_LIBNEKO="1c47a3af71990a7b2192e03292b4d246c308ef0b"

libcore/box.go

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"runtime/debug"
1212
"strings"
1313

14-
"github.com/matsuridayo/libneko/neko_log"
1514
"github.com/matsuridayo/libneko/protect_server"
1615
"github.com/matsuridayo/libneko/speedtest"
1716
"github.com/sagernet/sing-box/boxapi"
@@ -21,6 +20,8 @@ import (
2120
"github.com/sagernet/sing-box/constant"
2221
"github.com/sagernet/sing-box/option"
2322
"github.com/sagernet/sing-box/outbound"
23+
"github.com/sagernet/sing/common"
24+
"github.com/sagernet/sing/service"
2425
"github.com/sagernet/sing/service/pause"
2526
)
2627

@@ -79,15 +80,16 @@ func NewSingBoxInstance(config string) (b *BoxInstance, err error) {
7980
return nil, fmt.Errorf("decode config: %v", err)
8081
}
8182

82-
// create box
83+
// create box context
8384
ctx, cancel := context.WithCancel(context.Background())
84-
sleepManager := pause.ManagerFromContext(ctx)
85-
//sleepManager := pause.NewDefaultManager(ctx)
86-
ctx = pause.ContextWithManager(ctx, sleepManager)
85+
ctx = service.ContextWithDefaultRegistry(ctx)
86+
87+
// create box
8788
instance, err := box.New(box.Options{
8889
Options: options,
8990
Context: ctx,
9091
PlatformInterface: boxPlatformInterfaceInstance,
92+
PlatformLogWriter: boxPlatformLogWriter,
9193
})
9294
if err != nil {
9395
cancel()
@@ -97,16 +99,9 @@ func NewSingBoxInstance(config string) (b *BoxInstance, err error) {
9799
b = &BoxInstance{
98100
Box: instance,
99101
cancel: cancel,
100-
pauseManager: sleepManager,
102+
pauseManager: service.FromContext[pause.Manager](ctx),
101103
}
102104

103-
b.SetLogWritter(neko_log.LogWriter)
104-
105-
// fuck your sing-box platformFormatter
106-
pf := instance.GetLogPlatformFormatter()
107-
pf.DisableColors = true
108-
pf.DisableLineBreak = false
109-
110105
// selector
111106
if proxy, ok := b.Router().Outbound("proxy"); ok {
112107
if selector, ok := proxy.(*outbound.Selector); ok {
@@ -143,9 +138,7 @@ func (b *BoxInstance) Close() (err error) {
143138
}
144139

145140
// close box
146-
b.Close()
147-
// close box.Box
148-
b.Box.Close()
141+
common.Close(b.Box)
149142

150143
return nil
151144
}
@@ -164,10 +157,6 @@ func (b *BoxInstance) SetAsMain() {
164157
goServeProtect(true)
165158
}
166159

167-
func (b *BoxInstance) SetConnectionPoolEnabled(enable bool) {
168-
// TODO api
169-
}
170-
171160
func (b *BoxInstance) SetV2rayStats(outbounds string) {
172161
b.v2api = boxapi.NewSbV2rayServer(option.V2RayStatsServiceOptions{
173162
Enabled: true,

libcore/go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ go 1.20
55
require (
66
github.com/matsuridayo/libneko v1.0.0 // replaced
77
github.com/miekg/dns v1.1.59
8-
github.com/sagernet/sing v0.4.1
8+
github.com/sagernet/sing v0.4.3
99
github.com/sagernet/sing-box v1.0.0 // replaced
10-
github.com/sagernet/sing-dns v0.2.1-0.20240624030536-ca4a5f7afb65
11-
github.com/sagernet/sing-tun v0.3.2
10+
github.com/sagernet/sing-dns v0.2.3
11+
github.com/sagernet/sing-tun v0.3.3
1212
github.com/ulikunitz/xz v0.5.11
1313
golang.org/x/mobile v0.0.0-20231108233038-35478a0c49da
1414
)
@@ -44,6 +44,7 @@ require (
4444
github.com/libdns/cloudflare v0.1.1 // indirect
4545
github.com/libdns/libdns v0.2.2 // indirect
4646
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
47+
github.com/metacubex/tfo-go v0.0.0-20240821025650-e9be0afd5e7d // indirect
4748
github.com/mholt/acmez v1.2.0 // indirect
4849
github.com/onsi/ginkgo/v2 v2.9.7 // indirect
4950
github.com/ooni/go-libtor v1.1.8 // indirect
@@ -54,16 +55,15 @@ require (
5455
github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 // indirect
5556
github.com/sagernet/gvisor v0.0.0-20240428053021-e691de28565f // indirect
5657
github.com/sagernet/netlink v0.0.0-20240523065131-45e60152f9ba // indirect
57-
github.com/sagernet/quic-go v0.45.1-beta.2 // indirect
58+
github.com/sagernet/quic-go v0.47.0-beta.2 // indirect
5859
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
5960
github.com/sagernet/sing-mux v0.2.0 // indirect
60-
github.com/sagernet/sing-quic v0.2.0-beta.12 // indirect
61-
github.com/sagernet/sing-shadowsocks v0.2.6 // indirect
61+
github.com/sagernet/sing-quic v0.2.2 // indirect
62+
github.com/sagernet/sing-shadowsocks v0.2.7 // indirect
6263
github.com/sagernet/sing-shadowsocks2 v0.2.0 // indirect
6364
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
64-
github.com/sagernet/sing-vmess v0.1.8 // indirect
65+
github.com/sagernet/sing-vmess v0.1.12 // indirect
6566
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
66-
github.com/sagernet/tfo-go v0.0.0-20231209031829-7b5343ac1dc6 // indirect
6767
github.com/sagernet/utls v1.5.4 // indirect
6868
github.com/sagernet/wireguard-go v0.0.0-20231215174105-89dec3b2f3e8 // indirect
6969
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 // indirect
@@ -79,23 +79,23 @@ require (
7979
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
8080
golang.org/x/mod v0.18.0 // indirect
8181
golang.org/x/net v0.25.0 // indirect
82-
golang.org/x/sync v0.7.0 // indirect
83-
golang.org/x/sys v0.21.0 // indirect
84-
golang.org/x/text v0.16.0 // indirect
82+
golang.org/x/sync v0.8.0 // indirect
83+
golang.org/x/sys v0.25.0 // indirect
84+
golang.org/x/text v0.18.0 // indirect
8585
golang.org/x/time v0.5.0 // indirect
8686
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
8787
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 // indirect
8888
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
8989
google.golang.org/grpc v1.63.2 // indirect
9090
google.golang.org/protobuf v1.33.0 // indirect
91-
lukechampine.com/blake3 v1.2.1 // indirect
91+
lukechampine.com/blake3 v1.3.0 // indirect
9292
)
9393

9494
replace github.com/matsuridayo/libneko => ../../libneko
9595

9696
replace github.com/sagernet/sing-box => ../../sing-box
9797

98-
// replace github.com/sagernet/sing-quic => ../../sing-quic
98+
replace github.com/sagernet/sing-quic => ../../sing-quic
9999

100100
// replace github.com/sagernet/sing => ../../sing
101101

libcore/go.sum

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ github.com/libdns/libdns v0.2.2 h1:O6ws7bAfRPaBsgAYt8MDe2HcNBGC29hkZ9MX2eUSX3s=
6565
github.com/libdns/libdns v0.2.2/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ=
6666
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
6767
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
68+
github.com/metacubex/tfo-go v0.0.0-20240821025650-e9be0afd5e7d h1:j9LtzkYstLFoNvXW824QQeN7Y26uPL5249kzWKbzO9U=
69+
github.com/metacubex/tfo-go v0.0.0-20240821025650-e9be0afd5e7d/go.mod h1:c7bVFM9f5+VzeZ/6Kg77T/jrg1Xp8QpqlSHvG/aXVts=
6870
github.com/mholt/acmez v1.2.0 h1:1hhLxSgY5FvH5HCnGUuwbKY2VQVo8IU7rxXKSnZ7F30=
6971
github.com/mholt/acmez v1.2.0/go.mod h1:VT9YwH1xgNX1kmYY89gY8xPJC84BFAisjo8Egigt4kE=
7072
github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs=
@@ -93,33 +95,29 @@ github.com/sagernet/gvisor v0.0.0-20240428053021-e691de28565f h1:NkhuupzH5ch7b/Y
9395
github.com/sagernet/gvisor v0.0.0-20240428053021-e691de28565f/go.mod h1:KXmw+ouSJNOsuRpg4wgwwCQuunrGz4yoAqQjsLjc6N0=
9496
github.com/sagernet/netlink v0.0.0-20240523065131-45e60152f9ba h1:EY5AS7CCtfmARNv2zXUOrsEMPFDGYxaw65JzA2p51Vk=
9597
github.com/sagernet/netlink v0.0.0-20240523065131-45e60152f9ba/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
96-
github.com/sagernet/quic-go v0.45.1-beta.2 h1:zkEeCbhdFFkrxKcuIRBtXNKci/1t2J/39QSG/sPvlmc=
97-
github.com/sagernet/quic-go v0.45.1-beta.2/go.mod h1:+N3FqM9DAzOWfe64uxXuBejVJwX7DeW7BslzLO6N/xI=
98+
github.com/sagernet/quic-go v0.47.0-beta.2 h1:1tCGWFOSaXIeuQaHrwOMJIYvlupjTcaVInGQw5ArULU=
99+
github.com/sagernet/quic-go v0.47.0-beta.2/go.mod h1:bLVKvElSEMNv7pu7SZHscW02TYigzQ5lQu3Nh4wNh8Q=
98100
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byLGkEnIYp6grlXfo1QYUfiYFGjewIdc=
99101
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
100102
github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
101-
github.com/sagernet/sing v0.4.1 h1:zVlpE+7k7AFoC2pv6ReqLf0PIHjihL/jsBl5k05PQFk=
102-
github.com/sagernet/sing v0.4.1/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls=
103-
github.com/sagernet/sing-dns v0.2.1-0.20240624030536-ca4a5f7afb65 h1:lcCe7E1csuyUA3RCvpFcIYOy6FIifDthKaCrUjLG4xA=
104-
github.com/sagernet/sing-dns v0.2.1-0.20240624030536-ca4a5f7afb65/go.mod h1:dArgyPZmK8+zDBVRMjV3r12zHgnTara0ahrWwSe/eQE=
103+
github.com/sagernet/sing v0.4.3 h1:Ty/NAiNnVd6844k7ujlL5lkzydhcTH5Psc432jXA4Y8=
104+
github.com/sagernet/sing v0.4.3/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls=
105+
github.com/sagernet/sing-dns v0.2.3 h1:YzeBUn2tR38F7HtvGEQ0kLRLmZWMEgi/+7wqa4Twb1k=
106+
github.com/sagernet/sing-dns v0.2.3/go.mod h1:BJpJv6XLnrUbSyIntOT6DG9FW0f4fETmPAHvNjOprLg=
105107
github.com/sagernet/sing-mux v0.2.0 h1:4C+vd8HztJCWNYfufvgL49xaOoOHXty2+EAjnzN3IYo=
106108
github.com/sagernet/sing-mux v0.2.0/go.mod h1:khzr9AOPocLa+g53dBplwNDz4gdsyx/YM3swtAhlkHQ=
107-
github.com/sagernet/sing-quic v0.2.0-beta.12 h1:BhvA5mmrDFEyDUQB5eeu+9UhF+ieyuNJ5Rsb0dAG3QY=
108-
github.com/sagernet/sing-quic v0.2.0-beta.12/go.mod h1:YVpLfVi8BvYM7NMrjmnvcRm3E8iMETf1gFQmTQDN9jI=
109-
github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s=
110-
github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM=
109+
github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8=
110+
github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE=
111111
github.com/sagernet/sing-shadowsocks2 v0.2.0 h1:wpZNs6wKnR7mh1wV9OHwOyUr21VkS3wKFHi+8XwgADg=
112112
github.com/sagernet/sing-shadowsocks2 v0.2.0/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
113113
github.com/sagernet/sing-shadowtls v0.1.4 h1:aTgBSJEgnumzFenPvc+kbD9/W0PywzWevnVpEx6Tw3k=
114114
github.com/sagernet/sing-shadowtls v0.1.4/go.mod h1:F8NBgsY5YN2beQavdgdm1DPlhaKQlaL6lpDdcBglGK4=
115-
github.com/sagernet/sing-tun v0.3.2 h1:z0bLUT/YXH9RrJS9DsIpB0Bb9afl2hVJOmHd0zA3HJY=
116-
github.com/sagernet/sing-tun v0.3.2/go.mod h1:DxLIyhjWU/HwGYoX0vNGg2c5QgTQIakphU1MuERR5tQ=
117-
github.com/sagernet/sing-vmess v0.1.8 h1:XVWad1RpTy9b5tPxdm5MCU8cGfrTGdR8qCq6HV2aCNc=
118-
github.com/sagernet/sing-vmess v0.1.8/go.mod h1:vhx32UNzTDUkNwOyIjcZQohre1CaytquC5mPplId8uA=
115+
github.com/sagernet/sing-tun v0.3.3 h1:LZnQNmfGcNG2KPTPkLgc+Lo7k606QJVkPp2DnjriwUk=
116+
github.com/sagernet/sing-tun v0.3.3/go.mod h1:DxLIyhjWU/HwGYoX0vNGg2c5QgTQIakphU1MuERR5tQ=
117+
github.com/sagernet/sing-vmess v0.1.12 h1:2gFD8JJb+eTFMoa8FIVMnknEi+vCSfaiTXTfEYAYAPg=
118+
github.com/sagernet/sing-vmess v0.1.12/go.mod h1:luTSsfyBGAc9VhtCqwjR+dt1QgqBhuYBCONB/POhF8I=
119119
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ=
120120
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo=
121-
github.com/sagernet/tfo-go v0.0.0-20231209031829-7b5343ac1dc6 h1:z3SJQhVyU63FT26Wn/UByW6b7q8QKB0ZkPqsyqcz2PI=
122-
github.com/sagernet/tfo-go v0.0.0-20231209031829-7b5343ac1dc6/go.mod h1:73xRZuxwkFk4aiLw28hG8W6o9cr2UPrGL9pdY2UTbvY=
123121
github.com/sagernet/utls v1.5.4 h1:KmsEGbB2dKUtCNC+44NwAdNAqnqQ6GA4pTO0Yik56co=
124122
github.com/sagernet/utls v1.5.4/go.mod h1:CTGxPWExIloRipK3XFpYv0OVyhO8kk3XCGW/ieyTh1s=
125123
github.com/sagernet/wireguard-go v0.0.0-20231215174105-89dec3b2f3e8 h1:R0OMYAScomNAVpTfbHFpxqJpvwuhxSRi+g6z7gZhABs=
@@ -168,8 +166,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
168166
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
169167
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
170168
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
171-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
172-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
169+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
170+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
173171
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
174172
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
175173
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -179,14 +177,14 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
179177
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
180178
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
181179
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
182-
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
183-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
180+
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
181+
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
184182
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
185183
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
186184
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
187185
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
188-
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
189-
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
186+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
187+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
190188
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
191189
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
192190
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -204,5 +202,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
204202
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
205203
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
206204
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
207-
lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI=
208-
lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
205+
lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE=
206+
lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=

libcore/nb4a.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/matsuridayo/libneko/neko_common"
1414
"github.com/matsuridayo/libneko/neko_log"
1515
boxmain "github.com/sagernet/sing-box/cmd/sing-box"
16+
"github.com/sagernet/sing-box/nekoutils"
1617
)
1718

1819
//go:linkname resourcePaths github.com/sagernet/sing-box/constant.resourcePaths
@@ -60,7 +61,7 @@ func InitCore(process, cachePath, internalAssets, externalAssets string,
6061
boxmain.SetDisableColor(true)
6162

6263
// nekoutils
63-
// nekoutils.Selector_OnProxySelected = intfNB4A.Selector_OnProxySelected
64+
nekoutils.Selector_OnProxySelected = intfNB4A.Selector_OnProxySelected
6465

6566
// Set up some component
6667
go func() {

libcore/platform_box.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import (
1111
"strings"
1212
"syscall"
1313

14+
"github.com/matsuridayo/libneko/neko_log"
1415
"github.com/sagernet/sing-box/adapter"
1516
"github.com/sagernet/sing-box/common/process"
1617
"github.com/sagernet/sing-box/experimental/libbox/platform"
18+
sblog "github.com/sagernet/sing-box/log"
1719
"github.com/sagernet/sing-box/option"
1820
tun "github.com/sagernet/sing-tun"
1921
"github.com/sagernet/sing/common/control"
@@ -147,3 +149,19 @@ func (w *boxPlatformInterfaceWrapper) Write(p []byte) (n int, err error) {
147149
}
148150
return len(p), nil
149151
}
152+
153+
// 日志
154+
155+
type boxPlatformLogWriterWrapper struct {
156+
}
157+
158+
var boxPlatformLogWriter sblog.PlatformWriter = &boxPlatformLogWriterWrapper{}
159+
160+
func (w *boxPlatformLogWriterWrapper) DisableColors() bool { return true }
161+
162+
func (w *boxPlatformLogWriterWrapper) WriteMessage(level uint8, message string) {
163+
if !strings.HasSuffix(message, "\n") {
164+
message += "\n"
165+
}
166+
neko_log.LogWriter.Write([]byte(message))
167+
}

0 commit comments

Comments
 (0)