From c1bd1de57ec840aa79db77c9c3aad34d55d5c0cd Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Mon, 8 Aug 2022 10:21:16 +0800 Subject: [PATCH] rm EBpf tun && disable android ebpf --- component/ebpf/ebpf_linux.go | 2 ++ component/ebpf/ebpf_others.go | 2 +- hub/executor/executor.go | 1 - listener/listener.go | 44 +++++------------------------------ 4 files changed, 9 insertions(+), 40 deletions(-) diff --git a/component/ebpf/ebpf_linux.go b/component/ebpf/ebpf_linux.go index 6893ae48..0fa2e275 100644 --- a/component/ebpf/ebpf_linux.go +++ b/component/ebpf/ebpf_linux.go @@ -1,3 +1,5 @@ +//go:build !android && linux + package ebpf import ( diff --git a/component/ebpf/ebpf_others.go b/component/ebpf/ebpf_others.go index 53658ffe..0ecf5caa 100644 --- a/component/ebpf/ebpf_others.go +++ b/component/ebpf/ebpf_others.go @@ -1,4 +1,4 @@ -//go:build !linux +//go:build !linux || android package ebpf diff --git a/hub/executor/executor.go b/hub/executor/executor.go index a155bda7..d35a9149 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -335,7 +335,6 @@ func updateGeneral(general *config.General, force bool) { P.ReCreateTProxy(general.TProxyPort, tcpIn, udpIn) P.ReCreateMixed(general.MixedPort, tcpIn, udpIn) P.ReCreateAutoRedir(general.EBpf.AutoRedir, tcpIn, udpIn) - P.ReCreateRedirToTun(general.EBpf.RedirectToTun) } func updateUsers(users []auth.AuthUser) { diff --git a/listener/listener.go b/listener/listener.go index 79b60e5e..8184b9cf 100644 --- a/listener/listener.go +++ b/listener/listener.go @@ -41,7 +41,6 @@ var ( mixedListener *mixed.Listener mixedUDPLister *socks.UDPListener tunStackListener ipstack.Stack - tcProgram *ebpf.TcEBpfProgram autoRedirListener *autoredir.Listener autoRedirProgram *ebpf.TcEBpfProgram @@ -371,9 +370,9 @@ func ReCreateAutoRedir(ifaceNames []string, tcpIn chan<- C.ConnContext, _ chan<- var err error defer func() { if err != nil { - if redirListener != nil { - _ = redirListener.Close() - redirListener = nil + if autoRedirListener != nil { + _ = autoRedirListener.Close() + autoRedirListener = nil } if autoRedirProgram != nil { autoRedirProgram.Close() @@ -387,10 +386,10 @@ func ReCreateAutoRedir(ifaceNames []string, tcpIn chan<- C.ConnContext, _ chan<- slices.Sort(nicArr) nicArr = slices.Compact(nicArr) - if redirListener != nil && autoRedirProgram != nil { - _ = redirListener.Close() + if autoRedirListener != nil && autoRedirProgram != nil { + _ = autoRedirListener.Close() autoRedirProgram.Close() - redirListener = nil + autoRedirListener = nil autoRedirProgram = nil } @@ -420,37 +419,6 @@ func ReCreateAutoRedir(ifaceNames []string, tcpIn chan<- C.ConnContext, _ chan<- log.Infoln("Auto redirect proxy listening at: %s, attached tc ebpf program to interfaces %v", autoRedirListener.Address(), autoRedirProgram.RawNICs()) } -func ReCreateRedirToTun(ifaceNames []string) { - tcMux.Lock() - defer tcMux.Unlock() - - nicArr := ifaceNames - slices.Sort(nicArr) - nicArr = slices.Compact(nicArr) - - if tcProgram != nil { - tcProgram.Close() - tcProgram = nil - } - - if len(nicArr) == 0 { - return - } - - if lastTunConf == nil || !lastTunConf.Enable { - return - } - - program, err := ebpf.NewTcEBpfProgram(nicArr, lastTunConf.Device) - if err != nil { - log.Errorln("Attached tc ebpf program error: %v", err) - return - } - tcProgram = program - - log.Infoln("Attached tc ebpf program to interfaces %v", tcProgram.RawNICs()) -} - // GetPorts return the ports of proxy servers func GetPorts() *Ports { ports := &Ports{}