1
0

experimental.go 686 B

12345678910111213141516171819202122232425262728293031323334
  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. TrafficController
  10. }
  11. type Tracker interface {
  12. Leave()
  13. }
  14. type TrafficController interface {
  15. RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule) (net.Conn, Tracker)
  16. RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule) (N.PacketConn, Tracker)
  17. }
  18. type OutboundGroup interface {
  19. Now() string
  20. All() []string
  21. }
  22. func OutboundTag(detour Outbound) string {
  23. if group, isGroup := detour.(OutboundGroup); isGroup {
  24. return group.Now()
  25. }
  26. return detour.Tag()
  27. }