Migrate components to library

This commit is contained in:
世界
2022-07-11 18:44:59 +08:00
parent f548511d7e
commit 3d16df288c
46 changed files with 109 additions and 2438 deletions

View File

@@ -1,22 +0,0 @@
package adapter
import (
"context"
"net/netip"
C "github.com/sagernet/sing-box/constant"
"golang.org/x/net/dns/dnsmessage"
)
type DNSClient interface {
Exchange(ctx context.Context, transport DNSTransport, message *dnsmessage.Message) (*dnsmessage.Message, error)
Lookup(ctx context.Context, transport DNSTransport, domain string, strategy C.DomainStrategy) ([]netip.Addr, error)
}
type DNSTransport interface {
Service
Raw() bool
Exchange(ctx context.Context, message *dnsmessage.Message) (*dnsmessage.Message, error)
Lookup(ctx context.Context, domain string, strategy C.DomainStrategy) ([]netip.Addr, error)
}

View File

@@ -4,7 +4,7 @@ import (
"context"
"net/netip"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-dns"
M "github.com/sagernet/sing/common/metadata"
)
@@ -25,7 +25,7 @@ type InboundContext struct {
// cache
DomainStrategy C.DomainStrategy
DomainStrategy dns.DomainStrategy
SniffEnabled bool
SniffOverrideDestination bool
DestinationAddresses []netip.Addr

View File

@@ -6,7 +6,7 @@ import (
"net/netip"
"github.com/sagernet/sing-box/common/geoip"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-dns"
N "github.com/sagernet/sing/common/network"
"golang.org/x/net/dns/dnsmessage"
@@ -21,7 +21,7 @@ type Router interface {
GeoIPReader() *geoip.Reader
LoadGeosite(code string) (Rule, error)
Exchange(ctx context.Context, message *dnsmessage.Message) (*dnsmessage.Message, error)
Lookup(ctx context.Context, domain string, strategy C.DomainStrategy) ([]netip.Addr, error)
Lookup(ctx context.Context, domain string, strategy dns.DomainStrategy) ([]netip.Addr, error)
LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error)
AutoDetectInterface() bool
DefaultInterfaceName() string