Skip to content

Commit a16e21c

Browse files
committed
Merge branch 'master' of github.com:DNSCrypt/dnscrypt-proxy
* 'master' of github.com:DNSCrypt/dnscrypt-proxy: Use DialTimeout if possible
2 parents 66678e9 + ecfc925 commit a16e21c

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

dnscrypt-proxy/dnsutils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ func _dnsExchange(
449449
upstreamAddr = relay.RelayUDPAddr
450450
}
451451
now := time.Now()
452-
pc, err := net.DialUDP("udp", nil, upstreamAddr)
452+
pc, err := net.DialTimeout("udp", upstreamAddr.String(), proxy.timeout)
453453
if err != nil {
454454
return DNSExchangeResponse{err: err}
455455
}
@@ -485,7 +485,7 @@ func _dnsExchange(
485485
var pc net.Conn
486486
proxyDialer := proxy.xTransport.proxyDialer
487487
if proxyDialer == nil {
488-
pc, err = net.DialTCP("tcp", nil, upstreamAddr)
488+
pc, err = net.DialTimeout("tcp", upstreamAddr.String(), proxy.timeout)
489489
} else {
490490
pc, err = (*proxyDialer).Dial("tcp", tcpAddr.String())
491491
}

dnscrypt-proxy/netprobe_others.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NetProbe(proxy *Proxy, address string, timeout int) error {
3131
timeout = Min(MaxTimeout, timeout)
3232
}
3333
for tries := timeout; tries > 0; tries-- {
34-
pc, err := net.DialUDP("udp", nil, remoteUDPAddr)
34+
pc, err := net.DialTimeout("udp", remoteUDPAddr.String(), proxy.timeout)
3535
if err != nil {
3636
if !retried {
3737
retried = true

dnscrypt-proxy/netprobe_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NetProbe(proxy *Proxy, address string, timeout int) error {
2929
timeout = Min(MaxTimeout, timeout)
3030
}
3131
for tries := timeout; tries > 0; tries-- {
32-
pc, err := net.DialUDP("udp", nil, remoteUDPAddr)
32+
pc, err := net.DialTimeout("udp", remoteUDPAddr.String(), proxy.timeout)
3333
if err == nil {
3434
// Write at least 1 byte. This ensures that sockets are ready to use for writing.
3535
// Windows specific: during the system startup, sockets can be created but the underlying buffers may not be

0 commit comments

Comments
 (0)