added error check on parse ip
This commit is contained in:
parent
08e70f8f94
commit
c283d7a108
10
coolDns.go
10
coolDns.go
@ -137,8 +137,16 @@ func createServer(zones []zone, config config, aclList map[string]*net.IPNet) *d
|
|||||||
for _, z := range zones {
|
for _, z := range zones {
|
||||||
srv.HandleFunc(z.zone, func(w dns.ResponseWriter, r *dns.Msg) {
|
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)
|
ip := net.ParseIP(remoteIP)
|
||||||
|
|
||||||
|
// Check ACL rules
|
||||||
if len(z.acl) != 0 {
|
if len(z.acl) != 0 {
|
||||||
passed := false
|
passed := false
|
||||||
for _, rule := range z.acl {
|
for _, rule := range z.acl {
|
||||||
|
Loading…
Reference in New Issue
Block a user