interface.go 943 B

1234567891011121314151617181920212223242526272829303132333435
  1. package platform
  2. import (
  3. "context"
  4. "io"
  5. "net/netip"
  6. "github.com/sagernet/sing-box/adapter"
  7. "github.com/sagernet/sing-box/common/process"
  8. "github.com/sagernet/sing-box/option"
  9. "github.com/sagernet/sing-tun"
  10. "github.com/sagernet/sing/common/control"
  11. "github.com/sagernet/sing/common/logger"
  12. )
  13. type Interface interface {
  14. Initialize(ctx context.Context, router adapter.Router) error
  15. UsePlatformAutoDetectInterfaceControl() bool
  16. AutoDetectInterfaceControl() control.Func
  17. OpenTun(options *tun.Options, platformOptions option.TunPlatformOptions) (tun.Tun, error)
  18. UsePlatformDefaultInterfaceMonitor() bool
  19. CreateDefaultInterfaceMonitor(logger logger.Logger) tun.DefaultInterfaceMonitor
  20. UsePlatformInterfaceGetter() bool
  21. Interfaces() ([]NetworkInterface, error)
  22. UnderNetworkExtension() bool
  23. process.Searcher
  24. io.Writer
  25. }
  26. type NetworkInterface struct {
  27. Index int
  28. MTU int
  29. Name string
  30. Addresses []netip.Prefix
  31. }