test sing-box 1.3-b12

This commit is contained in:
arm64v8a 2023-05-13 12:35:33 +09:00
parent f6d60e9d09
commit 0ac46f4bc6
4 changed files with 11 additions and 48 deletions

View File

@ -1,5 +1,5 @@
if [ ! -z $ENV_NB4A ]; then
export COMMIT_SING_BOX_EXTRA="b80bbaf5c70acb992ba1c9a3d5e165992eefe131"
export COMMIT_SING_BOX_EXTRA="d663cfa6b9f721d306ec3972460b61bb2c935685"
fi
if [ ! -z $ENV_SING_BOX_EXTRA ]; then

View File

@ -7,39 +7,25 @@ import (
"io"
"libcore/device"
"log"
"net/http"
"reflect"
"runtime"
"runtime/debug"
"strings"
"time"
"unsafe"
"github.com/matsuridayo/sing-box-extra/boxbox"
_ "github.com/matsuridayo/sing-box-extra/distro/all"
"github.com/matsuridayo/libneko/neko_common"
"github.com/matsuridayo/libneko/protect_server"
"github.com/matsuridayo/libneko/speedtest"
"github.com/matsuridayo/sing-box-extra/boxapi"
"github.com/sagernet/sing-box/common/dialer/conntrack"
sblog "github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-box/outbound"
)
var mainInstance *BoxInstance
func init() {
neko_common.GetProxyHttpClient = func() *http.Client {
if mainInstance == nil {
return nil
}
return boxapi.GetProxyHttpClient(mainInstance.Box)
}
}
func VersionBox() string {
version := []string{
"sing-box-extra: " + boxbox.Version(),
@ -110,13 +96,7 @@ func NewSingBoxInstance(config string) (b *BoxInstance, err error) {
}
// fuck your sing-box platformFormatter
logFactory_ := reflect.Indirect(reflect.ValueOf(instance)).FieldByName("logFactory")
logFactory_ = reflect.NewAt(logFactory_.Type(), unsafe.Pointer(logFactory_.UnsafeAddr())).Elem() // get unexported logFactory
logFactory_ = logFactory_.Elem().Elem() // get struct
platformFormatter_ := logFactory_.FieldByName("platformFormatter")
platformFormatter_ = reflect.NewAt(platformFormatter_.Type(), unsafe.Pointer(platformFormatter_.UnsafeAddr())) // get unexported Formatter
platformFormatter := platformFormatter_.Interface().(*sblog.Formatter)
platformFormatter.DisableColors = true
instance.GetLogPlatformFormatter().DisableColors = true
// selector
if proxy, ok := b.Router().Outbound("proxy"); ok {
@ -158,25 +138,8 @@ func (b *BoxInstance) Close() (err error) {
}
// close box
t := time.NewTimer(time.Second * 2)
c := make(chan struct{}, 1)
disableSingBoxLog = true
b.CloseWithTimeout(b.cancel, time.Second*2, log.Println)
go func(cancel context.CancelFunc, closer io.Closer) {
cancel()
closer.Close()
c <- struct{}{}
close(c)
}(b.cancel, b.Box)
select {
case <-t.C:
log.Println("[Warning] sing-box close takes longer than expected.")
case <-c:
}
disableSingBoxLog = false
t.Stop()
return nil
}
@ -215,9 +178,9 @@ func UrlTest(i *BoxInstance, link string, timeout int32) (latency int32, err err
defer device.DeferPanicToError("box.UrlTest", func(err_ error) { err = err_ })
if i == nil {
// test current
return speedtest.UrlTest(neko_common.GetProxyHttpClient(), link, timeout)
return speedtest.UrlTest(boxapi.CreateProxyHttpClient(mainInstance.Box), link, timeout)
}
return speedtest.UrlTest(boxapi.GetProxyHttpClient(i.Box), link, timeout)
return speedtest.UrlTest(boxapi.CreateProxyHttpClient(i.Box), link, timeout)
}
var protectCloser io.Closer

View File

@ -7,7 +7,7 @@ require (
github.com/matsuridayo/libneko v1.0.0 // replaced
github.com/matsuridayo/sing-box-extra v1.0.0 // replaced
github.com/miekg/dns v1.1.54
github.com/sagernet/sing v0.2.5-0.20230509045155-f60c80c56f21
github.com/sagernet/sing v0.2.5-0.20230512033628-9be7806bab51
github.com/sagernet/sing-box v1.0.0 // replaced
// github.com/sagernet/sing-dns v1.0.0 // replaced
github.com/sagernet/sing-tun v0.1.5-0.20230509102026-91df97aee204
@ -63,7 +63,7 @@ require (
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
github.com/sagernet/sing-mux v0.0.0-20230425130511-b0a6ffd8406f // indirect
github.com/sagernet/sing-shadowsocks v0.2.2-0.20230509053848-d83f8fe1194c // indirect
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230510062121-18b8e5920cb2 // indirect
github.com/sagernet/sing-shadowsocks2 v0.0.0-20230512030659-23bb92c1eb97 // indirect
github.com/sagernet/sing-shadowtls v0.1.2-0.20230417103049-4f682e05f19b // indirect
github.com/sagernet/sing-vmess v0.1.5-0.20230417103030-8c3070ae3fb3 // indirect
github.com/sagernet/smux v0.0.0-20230312102458-337ec2a5af37 // indirect

View File

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