experimental.go 905 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. }