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
import (

View file

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

View file

@ -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) {

View file

@ -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{}