platform.go 1.6 KB

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