1
0

platform.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. UsePlatformNotification() bool
  26. SendNotification(notification *Notification) error
  27. }
  28. type FindConnectionOwnerRequest struct {
  29. IpProtocol int32
  30. SourceAddress string
  31. SourcePort int32
  32. DestinationAddress string
  33. DestinationPort int32
  34. }
  35. type ConnectionOwner struct {
  36. ProcessID uint32
  37. UserId int32
  38. UserName string
  39. ProcessPath string
  40. AndroidPackageName string
  41. }
  42. type Notification struct {
  43. Identifier string
  44. TypeName string
  45. TypeID int32
  46. Title string
  47. Subtitle string
  48. Body string
  49. OpenURL string
  50. }
  51. type SystemProxyStatus struct {
  52. Available bool
  53. Enabled bool
  54. }