From c283d7a108ee06ae1e8694c86987175aaa9bdd06 Mon Sep 17 00:00:00 2001 From: Niklas Date: Wed, 23 Dec 2020 13:10:58 +0100 Subject: [PATCH] added error check on parse ip --- coolDns.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/coolDns.go b/coolDns.go index 3bfb0da..09f281e 100644 --- a/coolDns.go +++ b/coolDns.go @@ -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 {