mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 14:26:31 +00:00
chore: move Resolver interface to dns.go
This commit is contained in:
parent
6c3b46bbea
commit
8515b9a23f
13
dns/dns.go
13
dns/dns.go
@ -13,12 +13,17 @@ import (
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
)
|
||||
|
||||
type Resolver interface {
|
||||
Resolve(ctx context.Context, host string, qTypes []uint16) ([]net.IPAddr, error)
|
||||
String() string
|
||||
}
|
||||
|
||||
type Dns struct {
|
||||
host string
|
||||
port string
|
||||
systemClient client.Resolver
|
||||
generalClient client.Resolver
|
||||
dohClient client.Resolver
|
||||
systemClient Resolver
|
||||
generalClient Resolver
|
||||
dohClient Resolver
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (d *Dns) clientFactory(enableDoh bool, useSystemDns bool) client.Resolver {
|
||||
func (d *Dns) clientFactory(enableDoh bool, useSystemDns bool) Resolver {
|
||||
if useSystemDns {
|
||||
return d.systemClient
|
||||
}
|
||||
|
@ -14,11 +14,6 @@ import (
|
||||
|
||||
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 {
|
||||
msg *dns.Msg
|
||||
err error
|
||||
|
Loading…
Reference in New Issue
Block a user