chore: move Resolver interface to dns.go

This commit is contained in:
xvzc 2024-08-19 10:50:06 +09:00
parent 6c3b46bbea
commit 8515b9a23f
2 changed files with 9 additions and 9 deletions

View File

@ -13,12 +13,17 @@ import (
"github.com/xvzc/SpoofDPI/util" "github.com/xvzc/SpoofDPI/util"
) )
type Resolver interface {
Resolve(ctx context.Context, host string, qTypes []uint16) ([]net.IPAddr, error)
String() string
}
type Dns struct { type Dns struct {
host string host string
port string port string
systemClient client.Resolver systemClient Resolver
generalClient client.Resolver generalClient Resolver
dohClient client.Resolver dohClient Resolver
} }
func NewResolver(config *util.Config) *Dns { func NewResolver(config *util.Config) *Dns {
@ -61,7 +66,7 @@ func (d *Dns) ResolveHost(host string, enableDoh bool, useSystemDns bool) (strin
return "", fmt.Errorf("could not resolve %s using %s", host, clt) return "", fmt.Errorf("could not resolve %s using %s", host, clt)
} }
func (d *Dns) clientFactory(enableDoh bool, useSystemDns bool) client.Resolver { func (d *Dns) clientFactory(enableDoh bool, useSystemDns bool) Resolver {
if useSystemDns { if useSystemDns {
return d.systemClient return d.systemClient
} }

View File

@ -14,11 +14,6 @@ import (
type exchangeFunc = func(ctx context.Context, msg *dns.Msg) (*dns.Msg, error) type exchangeFunc = func(ctx context.Context, msg *dns.Msg) (*dns.Msg, error)
type Resolver interface {
Resolve(ctx context.Context, host string, qTypes []uint16) ([]net.IPAddr, error)
String() string
}
type DNSResult struct { type DNSResult struct {
msg *dns.Msg msg *dns.Msg
err error err error