2022-07-19 14:16:49 +00:00
|
|
|
package adapter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
N "github.com/sagernet/sing/common/network"
|
|
|
|
)
|
|
|
|
|
2022-07-19 23:12:40 +00:00
|
|
|
type ClashServer interface {
|
|
|
|
Service
|
2022-09-10 06:09:47 +00:00
|
|
|
Mode() string
|
2022-09-10 06:40:16 +00:00
|
|
|
StoreSelected() bool
|
|
|
|
CacheFile() ClashCacheFile
|
2022-09-10 06:09:47 +00:00
|
|
|
RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule) (net.Conn, Tracker)
|
|
|
|
RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule) (N.PacketConn, Tracker)
|
2022-07-19 23:12:40 +00:00
|
|
|
}
|
|
|
|
|
2022-09-10 06:40:16 +00:00
|
|
|
type ClashCacheFile interface {
|
|
|
|
LoadSelected(group string) string
|
|
|
|
StoreSelected(group string, selected string) error
|
|
|
|
}
|
|
|
|
|
2022-07-25 22:56:13 +00:00
|
|
|
type Tracker interface {
|
|
|
|
Leave()
|
|
|
|
}
|
|
|
|
|
2022-07-22 05:51:08 +00:00
|
|
|
type OutboundGroup interface {
|
|
|
|
Now() string
|
|
|
|
All() []string
|
|
|
|
}
|
2022-07-28 08:36:31 +00:00
|
|
|
|
|
|
|
func OutboundTag(detour Outbound) string {
|
|
|
|
if group, isGroup := detour.(OutboundGroup); isGroup {
|
|
|
|
return group.Now()
|
|
|
|
}
|
|
|
|
return detour.Tag()
|
|
|
|
}
|