Fix #706 - logging for resolveRDNS
This commit is contained in:
parent
85046abb15
commit
64a4443d0c
10
dns.go
10
dns.go
@ -93,26 +93,26 @@ func resolveRDNS(ip string) string {
|
|||||||
var err error
|
var err error
|
||||||
req.Question[0].Name, err = dns.ReverseAddr(ip)
|
req.Question[0].Name, err = dns.ReverseAddr(ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("dns.ReverseAddr: %s", err)
|
log.Debug("Error while calling dns.ReverseAddr(%s): %s", ip, err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := dnsctx.upstream.Exchange(&req)
|
resp, err := dnsctx.upstream.Exchange(&req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("upstream.Exchange: %s", err)
|
log.Error("Error while making an rDNS lookup for %s: %s", ip, err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if len(resp.Answer) != 1 {
|
if len(resp.Answer) != 1 {
|
||||||
log.Error("len(resp.Answer) != 1")
|
log.Debug("No answer for rDNS lookup of %s", ip)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
ptr, ok := resp.Answer[0].(*dns.PTR)
|
ptr, ok := resp.Answer[0].(*dns.PTR)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Error("not a dns.PTR response")
|
log.Error("not a PTR response for %s", ip)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracef("PTR response: %s", ptr.String())
|
log.Tracef("PTR response for %s: %s", ip, ptr.String())
|
||||||
if strings.HasSuffix(ptr.Ptr, ".") {
|
if strings.HasSuffix(ptr.Ptr, ".") {
|
||||||
ptr.Ptr = ptr.Ptr[:len(ptr.Ptr)-1]
|
ptr.Ptr = ptr.Ptr[:len(ptr.Ptr)-1]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user