Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrLocalDNSDisabled = errors.New("local dns is disabled")
)
Functions ¶
Types ¶
type LocalDNS ¶ added in v0.10.3
type LocalDNS struct {
// contains filtered or unexported fields
}
LocalDNS local dns server it has a simple dns cache, and can customize dns message exchange function
func NewLocalDNS ¶ added in v0.10.3
func (*LocalDNS) LookupIP ¶ added in v0.10.3
func (s *LocalDNS) LookupIP(host string, exchange func(dnServer string, query *dns.Msg) (resp *dns.Msg, err error)) (ips []net.IP, err error)
LookupIP lookup ip address for a host use custom exchange function
func (*LocalDNS) ReverseLookup ¶ added in v0.10.3
ReverseLookup reverse lookup hostnames for an ip address
type Options ¶
type Options struct { Listen string // listen address Upstream string // upstream dns server Evict time.Duration // cache evict duration Exchange func(upstream string, clientAddr string, query *dns.Msg) (resp *dns.Msg, err error) // dns message exchange function }
Options local dns server options
type Resolver ¶ added in v0.12.1
type Resolver struct { IPv4Servers []string IPv6Servers []string Exchange func(dnServer string, r *dns.Msg) (*dns.Msg, error) }
var DefaultResolver Resolver = Resolver{ IPv4Servers: []string{"8.8.8.8:53", "223.5.5.5:53"}, IPv6Servers: []string{"[2001:4860:4860::8888]:53", "[2400:3200::1]:53"}, Exchange: func(dnServer string, r *dns.Msg) (resp *dns.Msg, err error) { dnsLookupCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() resp, _, err = dnsClient.ExchangeContext(dnsLookupCtx, r, dnServer) return }, }
Click to show internal directories.
Click to hide internal directories.