This commit is contained in:
arm64v8a
2022-09-11 11:48:28 +08:00
parent 06b0163319
commit a7fe8de6a5
5 changed files with 12 additions and 28 deletions

View File

@@ -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'

View File

@@ -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()

View File

@@ -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"))
}
}
}

View File

@@ -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-*

View File

@@ -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