Pull request #1238: dnsforward: fix panic

Updates #3318.

Squashed commit of the following:

commit eebaa3ac3a6bfcb29e280006ead8ea9554b8a3bf
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Jul 6 14:59:00 2021 +0300

    dnsforward: imp code

commit 7591a3b183ab95f27f908267321518740cb7d4bb
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Jul 6 14:55:33 2021 +0300

    dnsforward: fix panic
This commit is contained in:
Ainar Garipov 2021-07-06 15:08:55 +03:00
parent 4b5a66ee61
commit 1571609e59
1 changed files with 5 additions and 3 deletions

View File

@ -379,15 +379,17 @@ func (s *Server) ipToHost(ip net.IP) (host string, ok bool) {
var v interface{}
v, ok = s.tableIPToHost.Get(ip)
if !ok {
return "", false
}
var typOK bool
if host, typOK = v.(string); !typOK {
if host, ok = v.(string); !ok {
log.Error("dns: bad type %T in tableIPToHost for %s", v, ip)
return "", false
}
return host, ok
return host, true
}
// Respond to PTR requests if the target IP is leased by our DHCP server and the