don't store nil slice to db
This commit is contained in:
parent
739a68f292
commit
a588d9aecc
1 changed files with 3 additions and 3 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue