2022-06-30 13:27:56 +00:00
|
|
|
package adapter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
2022-07-05 05:23:47 +00:00
|
|
|
"github.com/sagernet/sing-box/common/geoip"
|
2022-07-05 01:05:35 +00:00
|
|
|
"github.com/sagernet/sing-box/common/geosite"
|
2022-06-30 13:27:56 +00:00
|
|
|
N "github.com/sagernet/sing/common/network"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Router interface {
|
2022-07-05 05:23:47 +00:00
|
|
|
Service
|
2022-06-30 13:27:56 +00:00
|
|
|
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
|
2022-07-05 05:23:47 +00:00
|
|
|
GeoIPReader() *geoip.Reader
|
2022-07-05 01:05:35 +00:00
|
|
|
GeositeReader() *geosite.Reader
|
2022-07-02 06:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Rule interface {
|
2022-07-05 05:23:47 +00:00
|
|
|
Service
|
|
|
|
UpdateGeosite() error
|
2022-07-02 14:55:10 +00:00
|
|
|
Match(metadata *InboundContext) bool
|
2022-07-02 06:07:50 +00:00
|
|
|
Outbound() string
|
|
|
|
String() string
|
2022-06-30 13:27:56 +00:00
|
|
|
}
|