experimental.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package adapter
  2. import (
  3. "context"
  4. "net"
  5. "github.com/sagernet/sing-box/common/urltest"
  6. N "github.com/sagernet/sing/common/network"
  7. )
  8. type ClashServer interface {
  9. Service
  10. Mode() string
  11. StoreSelected() bool
  12. CacheFile() ClashCacheFile
  13. HistoryStorage() *urltest.HistoryStorage
  14. RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule) (net.Conn, Tracker)
  15. RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule) (N.PacketConn, Tracker)
  16. }
  17. type ClashCacheFile interface {
  18. LoadSelected(group string) string
  19. StoreSelected(group string, selected string) error
  20. }
  21. type Tracker interface {
  22. Leave()
  23. }
  24. type OutboundGroup interface {
  25. Now() string
  26. All() []string
  27. }
  28. func OutboundTag(detour Outbound) string {
  29. if group, isGroup := detour.(OutboundGroup); isGroup {
  30. return group.Now()
  31. }
  32. return detour.Tag()
  33. }
  34. type V2RayServer interface {
  35. Service
  36. StatsService() V2RayStatsService
  37. }
  38. type V2RayStatsService interface {
  39. RoutedConnection(inbound string, outbound string, user string, conn net.Conn) net.Conn
  40. RoutedPacketConnection(inbound string, outbound string, user string, conn N.PacketConn) N.PacketConn
  41. }
  42. type SSMServer interface {
  43. Service
  44. RoutedConnection(metadata InboundContext, conn net.Conn) net.Conn
  45. RoutedPacketConnection(metadata InboundContext, conn N.PacketConn) N.PacketConn
  46. }
  47. type ManagedShadowsocksServer interface {
  48. Inbound
  49. Method() string
  50. Password() string
  51. UpdateUsers(users []string, uPSKs []string) error
  52. }