Remove DNS lookup timeouts

This commit is contained in:
Charlie Jonas 2021-08-16 18:32:55 +01:00
parent df2e29b74d
commit be7705efc3
1 changed files with 3 additions and 12 deletions

View File

@ -5,7 +5,6 @@ import (
"fmt"
"net"
"os"
"time"
)
// TCP_BUFFER_SIZE is the maximum packet size
@ -20,9 +19,6 @@ var (
INTERNAL_DNS = false
)
// lookupTimeout for DNS requests
const lookupTimeout = time.Second
// publicDns are servers to be queried if a local lookup fails
var publicDns = []string{
"1.0.0.1", // Cloudflare
@ -86,10 +82,7 @@ func lookup(address string) (ipaddress string, err error) {
// localLookupIP returns a host's IP address based on the local resolver.
func localLookupIP(address string) (ipaddress string, err error) {
ctx, cancel := context.WithTimeout(context.Background(), lookupTimeout)
defer cancel()
ip, err := net.DefaultResolver.LookupHost(ctx, address)
ip, err := net.LookupHost(address)
if err != nil {
return
}
@ -102,10 +95,8 @@ func remoteLookupIP(address, dns string) (ipaddress string, err error) {
r := &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{
Timeout: lookupTimeout,
}
return d.DialContext(ctx, "udp", dns+":53")
d := new(net.Dialer)
return d.DialContext(ctx, network, dns+":53")
},
}
ip, err := r.LookupHost(context.Background(), address)