diff --git a/cmd/domaincheckbot/dns/domain.go b/cmd/domaincheckbot/dns/domain.go index 9f18dc5..0419d44 100644 --- a/cmd/domaincheckbot/dns/domain.go +++ b/cmd/domaincheckbot/dns/domain.go @@ -60,6 +60,7 @@ func getNameserverForTLD(tld string) ([]string, error) { } func queryTLDNamserver(fqdn, tldServer string) ([]string, error) { + nameservers := []string{} // Create a new DNS message m := new(dns.Msg) // Set the question section of the message with the fqdn and query type @@ -71,16 +72,15 @@ func queryTLDNamserver(fqdn, tldServer string) ([]string, error) { // Send the DNS query to the TLD server r, _, err := c.Exchange(m, tldServer) if err != nil { - return nil, fmt.Errorf("dns query error: %v", err) + return nameservers, fmt.Errorf("dns query error: %v", err) } // Check for response errors if r.Rcode != dns.RcodeSuccess { - return nil, fmt.Errorf("failed to get a valid response for %v: %v", fqdn, r.Rcode) + return nameservers, fmt.Errorf("failed to get a valid response for %v: %v", fqdn, r.Rcode) } // Print the nameservers from the response - nameservers := []string{} for _, ans := range r.Ns { if ns, ok := ans.(*dns.NS); ok { nameservers = append(nameservers, strings.ToLower(ns.Ns))