ebpf.go 543 B

123456789101112131415161718192021222324252627282930313233
  1. package ebpf
  2. import (
  3. "net/netip"
  4. C "github.com/metacubex/mihomo/constant"
  5. "github.com/metacubex/mihomo/transport/socks5"
  6. )
  7. type TcEBpfProgram struct {
  8. pros []C.EBpf
  9. rawNICs []string
  10. }
  11. func (t *TcEBpfProgram) RawNICs() []string {
  12. return t.rawNICs
  13. }
  14. func (t *TcEBpfProgram) Close() {
  15. for _, p := range t.pros {
  16. p.Close()
  17. }
  18. }
  19. func (t *TcEBpfProgram) Lookup(srcAddrPort netip.AddrPort) (addr socks5.Addr, err error) {
  20. for _, p := range t.pros {
  21. addr, err = p.Lookup(srcAddrPort)
  22. if err == nil {
  23. return
  24. }
  25. }
  26. return
  27. }