From 934efb3d85f5830957dd82a32fc67f0de154e4e7 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sat, 4 Dec 2021 14:34:01 +0800 Subject: [PATCH] [fix]Linux TProxy --- Makefile | 3 + hub/executor/executor.go | 60 +++++++++---------- ..._iptables.go => .tproxy_linux_iptables.go} | 0 test/clash_test.go | 8 +-- test/snell_test.go | 4 +- test/ss_test.go | 2 +- test/trojan_test.go | 4 +- test/vless_test.go | 4 +- test/vmess_test.go | 4 +- 9 files changed, 44 insertions(+), 45 deletions(-) rename listener/tproxy/{tproxy_linux_iptables.go => .tproxy_linux_iptables.go} (100%) diff --git a/Makefile b/Makefile index c669d44e..0085ecc7 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,9 @@ linux-386: linux-amd64: GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ +linux-arm64: + GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + linux-armv5: GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ diff --git a/hub/executor/executor.go b/hub/executor/executor.go index 27d36a82..8f0d98e0 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -2,10 +2,7 @@ package executor import ( "fmt" - "net" "os" - "runtime" - "strconv" "strings" "sync" @@ -24,7 +21,6 @@ import ( "github.com/Dreamacro/clash/dns" P "github.com/Dreamacro/clash/listener" authStore "github.com/Dreamacro/clash/listener/auth" - "github.com/Dreamacro/clash/listener/tproxy" "github.com/Dreamacro/clash/listener/tun/dev" "github.com/Dreamacro/clash/log" "github.com/Dreamacro/clash/tunnel" @@ -78,7 +74,7 @@ func ApplyConfig(cfg *config.Config, force bool) { updateRules(cfg.Rules, cfg.RuleProviders) updateHosts(cfg.Hosts) updateProfile(cfg) - updateIPTables(cfg.DNS, cfg.General) + //updateIPTables(cfg.DNS, cfg.General) updateDNS(cfg.DNS, cfg.General) updateGeneral(cfg.General, force) updateExperimental(cfg) @@ -288,35 +284,35 @@ func patchSelectGroup(proxies map[string]C.Proxy) { } } -func updateIPTables(dns *config.DNS, general *config.General) { - if runtime.GOOS != "linux" || dns.Listen == "" || general.TProxyPort == 0 || general.Tun.Enable { - return - } - - _, dnsPortStr, err := net.SplitHostPort(dns.Listen) - if dnsPortStr == "0" || dnsPortStr == "" || err != nil { - return - } - - dnsPort, err := strconv.Atoi(dnsPortStr) - if err != nil { - return - } - - tproxy.CleanUpTProxyLinuxIPTables() - - err = tproxy.SetTProxyLinuxIPTables(general.Interface, general.TProxyPort, dnsPort) - - if err != nil { - log.Errorln("Can not setting iptables for TProxy on linux, %s", err.Error()) - os.Exit(2) - } -} +//func updateIPTables(dns *config.DNS, general *config.General) { +// if runtime.GOOS != "linux" || dns.Listen == "" || general.TProxyPort == 0 || general.Tun.Enable { +// return +// } +// +// _, dnsPortStr, err := net.SplitHostPort(dns.Listen) +// if dnsPortStr == "0" || dnsPortStr == "" || err != nil { +// return +// } +// +// dnsPort, err := strconv.Atoi(dnsPortStr) +// if err != nil { +// return +// } +// +// tproxy.CleanUpTProxyLinuxIPTables() +// +// err = tproxy.SetTProxyLinuxIPTables(general.Interface, general.TProxyPort, dnsPort) +// +// if err != nil { +// log.Errorln("Can not setting iptables for TProxy on linux, %s", err.Error()) +// os.Exit(2) +// } +//} func CleanUp() { P.CleanUp() - if runtime.GOOS == "linux" { - tproxy.CleanUpTProxyLinuxIPTables() - } + //if runtime.GOOS == "linux" { + // tproxy.CleanUpTProxyLinuxIPTables() + //} } diff --git a/listener/tproxy/tproxy_linux_iptables.go b/listener/tproxy/.tproxy_linux_iptables.go similarity index 100% rename from listener/tproxy/tproxy_linux_iptables.go rename to listener/tproxy/.tproxy_linux_iptables.go diff --git a/test/clash_test.go b/test/clash_test.go index 5eb9d5bd..5a21de77 100644 --- a/test/clash_test.go +++ b/test/clash_test.go @@ -15,10 +15,10 @@ import ( "testing" "time" - "github.com/Dreamacro/clash/adapter/outbound" - C "github.com/Dreamacro/clash/constant" - "github.com/Dreamacro/clash/hub/executor" - "github.com/Dreamacro/clash/transport/socks5" + "github.com/Dreamacro/Clash.Meta/adapter/outbound" + C "github.com/Dreamacro/Clash.Meta/constant" + "github.com/Dreamacro/Clash.Meta/hub/executor" + "github.com/Dreamacro/Clash.Meta/transport/socks5" "github.com/docker/docker/api/types" "github.com/docker/docker/client" diff --git a/test/snell_test.go b/test/snell_test.go index f9cd610c..f341b293 100644 --- a/test/snell_test.go +++ b/test/snell_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/Dreamacro/clash/adapter/outbound" - C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/Clash.Meta/adapter/outbound" + C "github.com/Dreamacro/Clash.Meta/constant" "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert" diff --git a/test/ss_test.go b/test/ss_test.go index 446bae93..a611bea5 100644 --- a/test/ss_test.go +++ b/test/ss_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/Dreamacro/clash/adapter/outbound" + "github.com/Dreamacro/Clash.Meta/adapter/outbound" "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert" diff --git a/test/trojan_test.go b/test/trojan_test.go index d1ab2a00..6feddb64 100644 --- a/test/trojan_test.go +++ b/test/trojan_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/Dreamacro/clash/adapter/outbound" - C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/Clash.Meta/adapter/outbound" + C "github.com/Dreamacro/Clash.Meta/constant" "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert" diff --git a/test/vless_test.go b/test/vless_test.go index 8bce51d6..5b431d35 100644 --- a/test/vless_test.go +++ b/test/vless_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/Dreamacro/clash/adapter/outbound" - C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/Clash.Meta/adapter/outbound" + C "github.com/Dreamacro/Clash.Meta/constant" "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert" diff --git a/test/vmess_test.go b/test/vmess_test.go index 1483cf0a..b1d21e5f 100644 --- a/test/vmess_test.go +++ b/test/vmess_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/Dreamacro/clash/adapter/outbound" - C "github.com/Dreamacro/clash/constant" + "github.com/Dreamacro/Clash.Meta/adapter/outbound" + C "github.com/Dreamacro/Clash.Meta/constant" "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/assert"