2022-06-30 21:27:56 +08:00
|
|
|
package adapter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
2022-07-07 21:47:21 +08:00
|
|
|
"net/netip"
|
2022-06-30 21:27:56 +08:00
|
|
|
|
2022-07-06 15:01:09 +08:00
|
|
|
N "github.com/sagernet/sing/common/network"
|
|
|
|
|
2022-07-05 13:23:47 +08:00
|
|
|
"github.com/sagernet/sing-box/common/geoip"
|
2022-07-05 09:05:35 +08:00
|
|
|
"github.com/sagernet/sing-box/common/geosite"
|
2022-07-07 21:47:21 +08:00
|
|
|
C "github.com/sagernet/sing-box/constant"
|
|
|
|
|
|
|
|
"golang.org/x/net/dns/dnsmessage"
|
2022-06-30 21:27:56 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type Router interface {
|
2022-07-05 13:23:47 +08:00
|
|
|
Service
|
2022-06-30 21:27:56 +08:00
|
|
|
Outbound(tag string) (Outbound, bool)
|
2022-07-06 23:11:48 +08:00
|
|
|
DefaultOutbound(network string) Outbound
|
2022-06-30 21:27:56 +08:00
|
|
|
RouteConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
|
|
|
|
RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
|
2022-07-05 13:23:47 +08:00
|
|
|
GeoIPReader() *geoip.Reader
|
2022-07-05 09:05:35 +08:00
|
|
|
GeositeReader() *geosite.Reader
|
2022-07-07 21:47:21 +08:00
|
|
|
Exchange(ctx context.Context, message *dnsmessage.Message) (*dnsmessage.Message, error)
|
|
|
|
Lookup(ctx context.Context, domain string, strategy C.DomainStrategy) ([]netip.Addr, error)
|
|
|
|
LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error)
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Rule interface {
|
2022-07-05 13:23:47 +08:00
|
|
|
Service
|
|
|
|
UpdateGeosite() error
|
2022-07-02 22:55:10 +08:00
|
|
|
Match(metadata *InboundContext) bool
|
2022-07-02 14:07:50 +08:00
|
|
|
Outbound() string
|
|
|
|
String() string
|
2022-06-30 21:27:56 +08:00
|
|
|
}
|