Add flow dispatcher

This commit is contained in:
世界 2026-07-06 11:49:18 +08:00
parent 47bdde06c3
commit ed63adda33
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
27 changed files with 2469 additions and 963 deletions

14
tun.go
View file

@ -7,7 +7,6 @@ import (
"runtime"
"strconv"
"strings"
"time"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/buf"
@ -15,27 +14,16 @@ import (
E "github.com/sagernet/sing/common/exceptions"
F "github.com/sagernet/sing/common/format"
"github.com/sagernet/sing/common/logger"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
"github.com/sagernet/sing/common/ranges"
)
type Handler interface {
PrepareConnection(
network string,
source M.Socksaddr,
destination M.Socksaddr,
routeContext DirectRouteContext,
timeout time.Duration,
) (DirectRouteDestination, error)
JudgeFlow(network uint8, source netip.AddrPort, destination netip.AddrPort) FlowVerdict
N.TCPConnectionHandlerEx
N.UDPConnectionHandlerEx
}
type DirectRouteContext interface {
WritePacket(packet []byte) error
}
type Tun interface {
io.ReadWriter
Name() (string, error)