mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-23 08:33:45 +01:00
88117f7d16
* Test upstream DNS for availability as soon as they are received from management * Use root zone for DNS tests
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
//go:build !ios
|
|
|
|
package dns
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"time"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
type upstreamResolverNonIOS struct {
|
|
*upstreamResolverBase
|
|
}
|
|
|
|
func newUpstreamResolver(parentCTX context.Context, interfaceName string, ip net.IP, net *net.IPNet) (*upstreamResolverNonIOS, error) {
|
|
upstreamResolverBase := newUpstreamResolverBase(parentCTX)
|
|
nonIOS := &upstreamResolverNonIOS{
|
|
upstreamResolverBase: upstreamResolverBase,
|
|
}
|
|
upstreamResolverBase.upstreamClient = nonIOS
|
|
return nonIOS, nil
|
|
}
|
|
|
|
func (u *upstreamResolverNonIOS) exchange(upstream string, r *dns.Msg) (rm *dns.Msg, t time.Duration, err error) {
|
|
// default upstream timeout
|
|
ctx, cancel := context.WithTimeout(u.ctx, u.upstreamTimeout)
|
|
defer cancel()
|
|
return u.exchangeContext(ctx, upstream, r)
|
|
}
|
|
|
|
func (u *upstreamResolverNonIOS) exchangeContext(ctx context.Context, upstream string, r *dns.Msg) (rm *dns.Msg, t time.Duration, err error) {
|
|
upstreamExchangeClient := &dns.Client{}
|
|
return upstreamExchangeClient.ExchangeContext(ctx, r, upstream)
|
|
}
|