mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-08-25 11:22:32 +00:00
34 lines
541 B
Go
34 lines
541 B
Go
|
package ebpf
|
||
|
|
||
|
import (
|
||
|
"net/netip"
|
||
|
|
||
|
C "github.com/Dreamacro/clash/constant"
|
||
|
"github.com/Dreamacro/clash/transport/socks5"
|
||
|
)
|
||
|
|
||
|
type TcEBpfProgram struct {
|
||
|
pros []C.EBpf
|
||
|
rawNICs []string
|
||
|
}
|
||
|
|
||
|
func (t *TcEBpfProgram) RawNICs() []string {
|
||
|
return t.rawNICs
|
||
|
}
|
||
|
|
||
|
func (t *TcEBpfProgram) Close() {
|
||
|
for _, p := range t.pros {
|
||
|
p.Close()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (t *TcEBpfProgram) Lookup(srcAddrPort netip.AddrPort) (addr socks5.Addr, err error) {
|
||
|
for _, p := range t.pros {
|
||
|
addr, err = p.Lookup(srcAddrPort)
|
||
|
if err == nil {
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
return
|
||
|
}
|