From a7fe8de6a5da1d87b1bed239d8c55443f556fbaf Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Sun, 11 Sep 2022 11:48:28 +0800 Subject: [PATCH] fix --- .github/workflows/build-qv2ray-cmake.yml | 4 ++-- go/protect_bindinterface_windows.go | 11 ++++++++--- go/toolbox_windows.go | 2 +- libs/build_go.sh | 2 +- libs/dl.sh | 21 --------------------- 5 files changed, 12 insertions(+), 28 deletions(-) delete mode 100755 libs/dl.sh diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index 15340ff..d8399ed 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -19,7 +19,7 @@ jobs: uses: actions/setup-go@v2 with: stable: false - go-version: 1.18.5 + go-version: 1.18.6 - name: Build golang and common parts shell: bash run: | @@ -95,7 +95,7 @@ jobs: uses: actions/cache@v2 with: path: libs/deps - key: ${{ hashFiles('libs/build*.sh') }} + key: ${{ hashFiles('libs/build_deps_*.sh') }} - name: Build Dependencies shell: bash if: steps.cache-deps.outputs.cache-hit != 'true' diff --git a/go/protect_bindinterface_windows.go b/go/protect_bindinterface_windows.go index 772206a..2993023 100644 --- a/go/protect_bindinterface_windows.go +++ b/go/protect_bindinterface_windows.go @@ -20,7 +20,7 @@ var lock sync.Mutex func init() { internet.RegisterListenerController(func(network, address string, fd uintptr) error { - bindInterfaceIndex := getBindInterfaceIndex() + bindInterfaceIndex := getBindInterfaceIndex(address) if bindInterfaceIndex != 0 { if err := bindInterface(fd, bindInterfaceIndex, true, true); err != nil { log.Println("bind inbound interface", err) @@ -30,7 +30,7 @@ func init() { return nil }) internet.RegisterDialerController(func(network, address string, fd uintptr) error { - bindInterfaceIndex := getBindInterfaceIndex() + bindInterfaceIndex := getBindInterfaceIndex(address) if bindInterfaceIndex != 0 { var v4, v6 bool if strings.HasSuffix(network, "6") { @@ -68,7 +68,12 @@ func updateRoutes() { } } -func getBindInterfaceIndex() uint32 { +func getBindInterfaceIndex(address string) uint32 { + host, _, _ := net.SplitHostPort(address) + if !net.ParseIP(host).IsGlobalUnicast() { + return 0 + } + lock.Lock() defer lock.Unlock() diff --git a/go/toolbox_windows.go b/go/toolbox_windows.go index 8716ee3..86ce747 100644 --- a/go/toolbox_windows.go +++ b/go/toolbox_windows.go @@ -20,7 +20,7 @@ func ToolBox() { for _, route := range routes { log.Println(route) } - log.Println("Upstream:", getBindInterfaceIndex()) + log.Println("Upstream:", getBindInterfaceIndex("8.8.8.8:8888")) } } } diff --git a/libs/build_go.sh b/libs/build_go.sh index 656f84d..31aedee 100755 --- a/libs/build_go.sh +++ b/libs/build_go.sh @@ -33,7 +33,7 @@ if [ "$GOOS" != "windows" ]; then fi #### Go ext: sing-box #### -curl -Lso sing-box.zip https://github.com/SagerNet/sing-box/releases/download/v1.1-beta1/sing-box-1.1-beta1-windows-amd64.zip +curl -Lso sing-box.zip https://github.com/SagerNet/sing-box/releases/download/v1.1-beta2/sing-box-1.1-beta2-windows-amd64.zip unzip sing-box.zip mv sing-box-*/sing-box.exe $DEST rm -rf sing-box.zip sing-box-* diff --git a/libs/dl.sh b/libs/dl.sh deleted file mode 100755 index a5c9ab1..0000000 --- a/libs/dl.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -cd libs - -mkdir -p deps; cd ./deps -mkdir -p downloaded; cd ./downloaded; - -NAME=$1 -echo "Downloading: $NAME" -curl -sL $2 -o $NAME; - -cd .. - -for f in $(ls ./downloaded) -do - 7z x -y ./downloaded/$f -done - -# libs/deps/windows-x64/installed/ - -rm -rf downloaded