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"
|
"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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user