Implement route rules

This commit is contained in:
世界
2022-07-02 22:55:10 +08:00
parent 7c57eb70e8
commit 6eae8e361f
40 changed files with 1220 additions and 145 deletions

View File

@@ -4,19 +4,23 @@ import (
"context"
"net"
"github.com/oschwald/geoip2-golang"
N "github.com/sagernet/sing/common/network"
)
type Router interface {
Start() error
Close() error
DefaultOutbound() Outbound
Outbound(tag string) (Outbound, bool)
RouteConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
Close() error
GeoIPReader() *geoip2.Reader
}
type Rule interface {
Match(metadata InboundContext) bool
Match(metadata *InboundContext) bool
Outbound() string
String() string
}