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