fix: compile

This commit is contained in:
gVisor bot 2022-05-29 20:00:38 +08:00
parent 6a5cdb7793
commit abf999d80f
7 changed files with 23 additions and 15 deletions

View file

@ -47,9 +47,9 @@ WINDOWS_ARCH_LIST = \
windows-arm64 \
windows-arm32v7
all:linux-amd64 linux-arm64\
darwin-amd64 darwin-arm64\
windows-amd64 windows-arm64\
all:linux-amd64v3 linux-arm64\
darwin-amd64v3 darwin-arm64\
windows-amd64v3 windows-arm64\
docker:
GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@

View file

@ -4,9 +4,7 @@ import (
"fmt"
"github.com/Dreamacro/clash/listener/inner"
"github.com/Dreamacro/clash/listener/tun/ipstack/commons"
"github.com/vishvananda/netlink"
"net"
"runtime"
"sort"
"strconv"
"sync"
@ -456,16 +454,7 @@ func Cleanup(wait bool) {
commons.WaitForTunClose(lastTunConf.Device)
}
if runtime.GOOS == "android" {
r := netlink.NewRule()
for i := 0; i < 5; i++ {
r.Priority = 9000 + i*10
err := netlink.RuleDel(r)
if err != nil {
log.Warnln("[TOUTE] cleanup route rule: %s", err)
}
}
}
commons.CleanupRule()
}
tunStackListener = nil
lastTunConf = nil

View file

@ -127,3 +127,14 @@ func configInterfaceRouting(index int, interfaceName string, ip netip.Addr) erro
return nil
}
func CleanupRule() {
r := netlink.NewRule()
for i := 0; i < 5; i++ {
r.Priority = 9000 + i*10
err := netlink.RuleDel(r)
if err != nil {
log.Warnln("[TOUTE] cleanup route rule: %s", err)
}
}
}

View file

@ -61,3 +61,5 @@ func execRouterCmd(action, inet, route string, interfaceName string) error {
_, err := cmd.ExecCmd(fmt.Sprintf("route %s %s %s -interface %s", action, inet, route, interfaceName))
return err
}
func CleanupRule() {}

View file

@ -103,3 +103,5 @@ func execRouterCmd(action, route, interfaceName, linkIP, table string) error {
_, err := cmd.ExecCmd(cmdStr)
return err
}
func CleanupRule() {}

View file

@ -17,3 +17,5 @@ func GetAutoDetectInterface() (string, error) {
func ConfigInterfaceAddress(device.Device, netip.Prefix, int, bool) error {
return fmt.Errorf("unsupported on this OS: %s", runtime.GOOS)
}
func CleanupRule() {}

View file

@ -269,3 +269,5 @@ func getAutoDetectInterfaceByFamily(family winipcfg.AddressFamily) (string, erro
return "", errors.New("ethernet interface not found")
}
func CleanupRule() {}