added error check on parse ip

This commit is contained in:
Niklas 2020-12-23 13:10:58 +01:00
parent 08e70f8f94
commit c283d7a108

View File

@ -137,8 +137,16 @@ func createServer(zones []zone, config config, aclList map[string]*net.IPNet) *d
for _, z := range zones {
srv.HandleFunc(z.zone, func(w dns.ResponseWriter, r *dns.Msg) {
remoteIP, _, _ := net.SplitHostPort(w.RemoteAddr().String())
// Parse IP
remoteIP, _, err := net.SplitHostPort(w.RemoteAddr().String())
if err != nil {
log.Printf("Faild to parse remote IP WTF? :%s", err.Error())
return
}
ip := net.ParseIP(remoteIP)
// Check ACL rules
if len(z.acl) != 0 {
passed := false
for _, rule := range z.acl {