Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Sep 11, 2022
1 parent 06b0163 commit a7fe8de
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-qv2ray-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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'
Expand Down
11 changes: 8 additions & 3 deletions go/protect_bindinterface_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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") {
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion go/toolbox_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}
}
2 changes: 1 addition & 1 deletion libs/build_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
21 changes: 0 additions & 21 deletions libs/dl.sh

This file was deleted.

0 comments on commit a7fe8de

Please sign in to comment.