diff --git a/go/cmd/nekoray_core/core_ray.go b/go/cmd/nekoray_core/core_ray.go index dbf368c..c417d23 100644 --- a/go/cmd/nekoray_core/core_ray.go +++ b/go/cmd/nekoray_core/core_ray.go @@ -17,7 +17,8 @@ import ( ) var instance *libcore.V2RayInstance -var getNekorayTunIndex = func() int { return 0 } +var getNekorayTunIndex = func() int { return 0 } // Windows only +var underlyingNetDialer *net.Dialer // Windows only func setupCore() { // TODO del @@ -27,6 +28,9 @@ func setupCore() { // localdns setup resolver_def := &net.Resolver{PreferGo: false} resolver_go := &net.Resolver{PreferGo: true} + if underlyingNetDialer != nil { + resolver_go.Dial = underlyingNetDialer.DialContext + } localdns.SetLookupFunc(func(network string, host string) (ips []net.IP, err error) { // fix old sekai defer func() { diff --git a/go/cmd/nekoray_core/protect_bindinterface_windows.go b/go/cmd/nekoray_core/protect_bindinterface_windows.go index a0c2e97..48b8dbf 100644 --- a/go/cmd/nekoray_core/protect_bindinterface_windows.go +++ b/go/cmd/nekoray_core/protect_bindinterface_windows.go @@ -23,7 +23,7 @@ func init() { bindInterfaceIndex := getBindInterfaceIndex(address) if bindInterfaceIndex != 0 { if err := bindInterface(fd, bindInterfaceIndex, true, true); err != nil { - log.Println("bind inbound interface", err) + log.Println("bind inbound interface", network, address, err) return err } } @@ -41,12 +41,33 @@ func init() { v6 = false } if err := bindInterface(fd, bindInterfaceIndex, v4, v6); err != nil { - log.Println("bind outbound interface", err) + log.Println("bind outbound interface", network, address, err) return err } } return nil }) + underlyingNetDialer = &net.Dialer{ + Control: func(network, address string, c syscall.RawConn) error { + c.Control(func(fd uintptr) { + bindInterfaceIndex := getBindInterfaceIndex(address) + if bindInterfaceIndex != 0 { + var v4, v6 bool + if strings.HasSuffix(network, "6") { + v4 = false + v6 = true + } else { + v4 = true + v6 = false + } + if err := bindInterface(fd, bindInterfaceIndex, v4, v6); err != nil { + log.Println("underlyingNetDialer: bind interface", network, address, err) + } + } + }) + return nil + }, + } // updateRoutes() iphlpapi.RegisterNotifyRouteChange2(func(callerContext uintptr, row uintptr, notificationType uint32) uintptr { diff --git a/go/cmd/updater/main.go b/go/cmd/updater/main.go index ecfd80b..43a63a7 100644 --- a/go/cmd/updater/main.go +++ b/go/cmd/updater/main.go @@ -34,7 +34,7 @@ func main() { } else { // 1. nekoray stop it self and run "updater.exe" Copy("./updater.exe", "./updater.old") - exec.Command("./updater.old").Start() + exec.Command("./updater.old", os.Args[1:]...).Start() } } else { // 1. update files diff --git a/libs/deploy_linux64.sh b/libs/deploy_linux64.sh index 6220f60..6316178 100755 --- a/libs/deploy_linux64.sh +++ b/libs/deploy_linux64.sh @@ -9,7 +9,16 @@ mkdir -p $DEST #### copy binary #### cp $BUILD/nekoray $DEST +#### Download: prebuilt runtime #### +curl -Lso usr.zip https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/20230202-5.12.8-ubuntu20.04-linux64.zip +unzip usr.zip +mv usr $DEST + + #### copy so #### +# 5.11 looks buggy on new systems... +exit + USR_LIB=/usr/lib/x86_64-linux-gnu mkdir usr pushd usr