sing-box/adapter/experimental.go

52 lines
1.2 KiB
Go
Raw Permalink Normal View History

2022-07-19 22:16:49 +08:00
package adapter
import (
"context"
"net"
2022-09-15 15:22:08 +08:00
"github.com/sagernet/sing-box/common/urltest"
2022-07-19 22:16:49 +08:00
N "github.com/sagernet/sing/common/network"
)
2022-07-20 07:12:40 +08:00
type ClashServer interface {
Service
2023-03-18 20:26:58 +08:00
PreStarter
2022-09-10 14:09:47 +08:00
Mode() string
2022-09-10 14:40:16 +08:00
StoreSelected() bool
CacheFile() ClashCacheFile
2022-09-15 15:22:08 +08:00
HistoryStorage() *urltest.HistoryStorage
2022-09-10 14:09:47 +08: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-20 07:12:40 +08:00
}
2022-09-10 14:40:16 +08:00
type ClashCacheFile interface {
LoadSelected(group string) string
StoreSelected(group string, selected string) error
}
2022-07-26 06:56:13 +08:00
type Tracker interface {
Leave()
}
2022-07-22 13:51:08 +08:00
type OutboundGroup interface {
Now() string
All() []string
}
2022-07-28 16:36:31 +08:00
func OutboundTag(detour Outbound) string {
if group, isGroup := detour.(OutboundGroup); isGroup {
return group.Now()
}
return detour.Tag()
}
2022-09-26 19:37:06 +08:00
type V2RayServer interface {
Service
StatsService() V2RayStatsService
}
type V2RayStatsService interface {
2023-02-08 16:50:15 +08:00
RoutedConnection(inbound string, outbound string, user string, conn net.Conn) net.Conn
RoutedPacketConnection(inbound string, outbound string, user string, conn N.PacketConn) N.PacketConn
2022-09-26 19:37:06 +08:00
}