experimental.go 816 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package adapter
  2. import (
  3. "context"
  4. "net"
  5. N "github.com/sagernet/sing/common/network"
  6. )
  7. type ClashServer interface {
  8. Service
  9. Mode() string
  10. StoreSelected() bool
  11. CacheFile() ClashCacheFile
  12. RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule) (net.Conn, Tracker)
  13. RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule) (N.PacketConn, Tracker)
  14. }
  15. type ClashCacheFile interface {
  16. LoadSelected(group string) string
  17. StoreSelected(group string, selected string) error
  18. }
  19. type Tracker interface {
  20. Leave()
  21. }
  22. type OutboundGroup interface {
  23. Now() string
  24. All() []string
  25. }
  26. func OutboundTag(detour Outbound) string {
  27. if group, isGroup := detour.(OutboundGroup); isGroup {
  28. return group.Now()
  29. }
  30. return detour.Tag()
  31. }