diff --git a/crawler.go b/crawler.go index 4233537..9ba4274 100644 --- a/crawler.go +++ b/crawler.go @@ -145,11 +145,20 @@ func (c *Crawler) StartMaintenanceLoop() { } } +// dnsResolver uses local caching DNS (infra-dns) +var dnsResolver = &net.Resolver{ + PreferGo: true, + Dial: func(ctx context.Context, network, address string) (net.Conn, error) { + d := net.Dialer{Timeout: 5 * time.Second} + return d.DialContext(ctx, "udp", "infra-dns:53") + }, +} + // domainCheck performs a DNS lookup to check if a domain resolves func (c *Crawler) domainCheck(host string) error { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - _, err := net.DefaultResolver.LookupHost(ctx, host) + _, err := dnsResolver.LookupHost(ctx, host) return err }