Skip to content

Commit

Permalink
Honor query timeout in udp/tcp resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
folbricht committed Jul 23, 2023
1 parent 75fca5a commit e24bfa3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dnsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ func NewDNSClient(id, endpoint, network string, opt DNSClientOptions) (*DNSClien
if opt.LocalAddr != nil {
switch network {
case "tcp":
dialer = &net.Dialer{LocalAddr: &net.TCPAddr{IP: opt.LocalAddr}}
dialer = &net.Dialer{LocalAddr: &net.TCPAddr{IP: opt.LocalAddr}, Timeout: opt.QueryTimeout}
case "udp":
dialer = &net.Dialer{LocalAddr: &net.UDPAddr{IP: opt.LocalAddr}}
dialer = &net.Dialer{LocalAddr: &net.UDPAddr{IP: opt.LocalAddr}, Timeout: opt.QueryTimeout}
}
}

client := &dns.Client{
Net: network,
Dialer: dialer,
TLSConfig: &tls.Config{},
UDPSize: 4096,
Timeout: opt.QueryTimeout,
}
return &DNSClient{
id: id,
Expand Down

0 comments on commit e24bfa3

Please sign in to comment.