rm EBpf tun && disable android ebpf

This commit is contained in:
gVisor bot 2022-08-08 10:21:16 +08:00
parent 278a5a16a1
commit c1bd1de57e
4 changed files with 9 additions and 40 deletions

View file

@ -1,3 +1,5 @@
//go:build !android && linux
package ebpf package ebpf
import ( import (

View file

@ -1,4 +1,4 @@
//go:build !linux //go:build !linux || android
package ebpf package ebpf

View file

@ -335,7 +335,6 @@ func updateGeneral(general *config.General, force bool) {
P.ReCreateTProxy(general.TProxyPort, tcpIn, udpIn) P.ReCreateTProxy(general.TProxyPort, tcpIn, udpIn)
P.ReCreateMixed(general.MixedPort, tcpIn, udpIn) P.ReCreateMixed(general.MixedPort, tcpIn, udpIn)
P.ReCreateAutoRedir(general.EBpf.AutoRedir, tcpIn, udpIn) P.ReCreateAutoRedir(general.EBpf.AutoRedir, tcpIn, udpIn)
P.ReCreateRedirToTun(general.EBpf.RedirectToTun)
} }
func updateUsers(users []auth.AuthUser) { func updateUsers(users []auth.AuthUser) {

View file

@ -41,7 +41,6 @@ var (
mixedListener *mixed.Listener mixedListener *mixed.Listener
mixedUDPLister *socks.UDPListener mixedUDPLister *socks.UDPListener
tunStackListener ipstack.Stack tunStackListener ipstack.Stack
tcProgram *ebpf.TcEBpfProgram
autoRedirListener *autoredir.Listener autoRedirListener *autoredir.Listener
autoRedirProgram *ebpf.TcEBpfProgram autoRedirProgram *ebpf.TcEBpfProgram
@ -371,9 +370,9 @@ func ReCreateAutoRedir(ifaceNames []string, tcpIn chan<- C.ConnContext, _ chan<-
var err error var err error
defer func() { defer func() {
if err != nil { if err != nil {
if redirListener != nil { if autoRedirListener != nil {
_ = redirListener.Close() _ = autoRedirListener.Close()
redirListener = nil autoRedirListener = nil
} }
if autoRedirProgram != nil { if autoRedirProgram != nil {
autoRedirProgram.Close() autoRedirProgram.Close()
@ -387,10 +386,10 @@ func ReCreateAutoRedir(ifaceNames []string, tcpIn chan<- C.ConnContext, _ chan<-
slices.Sort(nicArr) slices.Sort(nicArr)
nicArr = slices.Compact(nicArr) nicArr = slices.Compact(nicArr)
if redirListener != nil && autoRedirProgram != nil { if autoRedirListener != nil && autoRedirProgram != nil {
_ = redirListener.Close() _ = autoRedirListener.Close()
autoRedirProgram.Close() autoRedirProgram.Close()
redirListener = nil autoRedirListener = nil
autoRedirProgram = 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()) 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 // GetPorts return the ports of proxy servers
func GetPorts() *Ports { func GetPorts() *Ports {
ports := &Ports{} ports := &Ports{}