platform.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package adapter
  2. import (
  3. "github.com/sagernet/sing-box/option"
  4. "github.com/sagernet/sing-tun"
  5. "github.com/sagernet/sing/common/logger"
  6. )
  7. type PlatformInterface interface {
  8. Initialize(networkManager NetworkManager) error
  9. UsePlatformAutoDetectInterfaceControl() bool
  10. AutoDetectInterfaceControl(fd int) error
  11. UsePlatformInterface() bool
  12. OpenInterface(options *tun.Options, platformOptions option.TunPlatformOptions) (tun.Tun, error)
  13. UsePlatformDefaultInterfaceMonitor() bool
  14. CreateDefaultInterfaceMonitor(logger logger.Logger) tun.DefaultInterfaceMonitor
  15. UsePlatformNetworkInterfaces() bool
  16. NetworkInterfaces() ([]NetworkInterface, error)
  17. UnderNetworkExtension() bool
  18. NetworkExtensionIncludeAllNetworks() bool
  19. ClearDNSCache()
  20. RequestPermissionForWIFIState() error
  21. ReadWIFIState() WIFIState
  22. SystemCertificates() []string
  23. UsePlatformConnectionOwnerFinder() bool
  24. FindConnectionOwner(request *FindConnectionOwnerRequest) (*ConnectionOwner, error)
  25. UsePlatformWIFIMonitor() bool
  26. UsePlatformNotification() bool
  27. SendNotification(notification *Notification) error
  28. UsePlatformNeighborResolver() bool
  29. StartNeighborMonitor(listener NeighborUpdateListener) error
  30. CloseNeighborMonitor(listener NeighborUpdateListener) error
  31. }
  32. type FindConnectionOwnerRequest struct {
  33. IpProtocol int32
  34. SourceAddress string
  35. SourcePort int32
  36. DestinationAddress string
  37. DestinationPort int32
  38. }
  39. type ConnectionOwner struct {
  40. ProcessID uint32
  41. UserId int32
  42. UserName string
  43. ProcessPath string
  44. AndroidPackageNames []string
  45. }
  46. type Notification struct {
  47. Identifier string
  48. TypeName string
  49. TypeID int32
  50. Title string
  51. Subtitle string
  52. Body string
  53. OpenURL string
  54. }
  55. type SystemProxyStatus struct {
  56. Available bool
  57. Enabled bool
  58. }