From 708b8beadf7f41c7c287387c8422a90b7be3f112 Mon Sep 17 00:00:00 2001 From: adlyq Date: Sun, 29 May 2022 20:00:38 +0800 Subject: [PATCH] fix: compile --- Makefile | 6 +++--- listener/listener.go | 13 +------------ listener/tun/ipstack/commons/router_android.go | 11 +++++++++++ listener/tun/ipstack/commons/router_darwin.go | 2 ++ listener/tun/ipstack/commons/router_linux.go | 2 ++ listener/tun/ipstack/commons/router_others.go | 2 ++ listener/tun/ipstack/commons/router_windows.go | 2 ++ 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index f0a0618d..1a87f518 100644 --- a/Makefile +++ b/Makefile @@ -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)-$@ diff --git a/listener/listener.go b/listener/listener.go index abedb842..29f6d441 100644 --- a/listener/listener.go +++ b/listener/listener.go @@ -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 diff --git a/listener/tun/ipstack/commons/router_android.go b/listener/tun/ipstack/commons/router_android.go index 5abaee94..172c9ce3 100644 --- a/listener/tun/ipstack/commons/router_android.go +++ b/listener/tun/ipstack/commons/router_android.go @@ -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) + } + } +} diff --git a/listener/tun/ipstack/commons/router_darwin.go b/listener/tun/ipstack/commons/router_darwin.go index 47e3db1a..3132fced 100644 --- a/listener/tun/ipstack/commons/router_darwin.go +++ b/listener/tun/ipstack/commons/router_darwin.go @@ -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() {} diff --git a/listener/tun/ipstack/commons/router_linux.go b/listener/tun/ipstack/commons/router_linux.go index 9428accb..d5f3edab 100644 --- a/listener/tun/ipstack/commons/router_linux.go +++ b/listener/tun/ipstack/commons/router_linux.go @@ -103,3 +103,5 @@ func execRouterCmd(action, route, interfaceName, linkIP, table string) error { _, err := cmd.ExecCmd(cmdStr) return err } + +func CleanupRule() {} diff --git a/listener/tun/ipstack/commons/router_others.go b/listener/tun/ipstack/commons/router_others.go index 6c8ea341..dfc409f4 100644 --- a/listener/tun/ipstack/commons/router_others.go +++ b/listener/tun/ipstack/commons/router_others.go @@ -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() {} diff --git a/listener/tun/ipstack/commons/router_windows.go b/listener/tun/ipstack/commons/router_windows.go index b29b20ab..2abfa0ff 100644 --- a/listener/tun/ipstack/commons/router_windows.go +++ b/listener/tun/ipstack/commons/router_windows.go @@ -269,3 +269,5 @@ func getAutoDetectInterfaceByFamily(family winipcfg.AddressFamily) (string, erro return "", errors.New("ethernet interface not found") } + +func CleanupRule() {}