Skip to content

Commit

Permalink
Improve nameserver auth IP check
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Aug 11, 2020
1 parent 6ded9b3 commit d17f83a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nameserver/nameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var (
dnsServer *dns.Server

listenAddress = "0.0.0.0:53"
ipv4Localhost = net.IPv4(127, 0, 0, 1)
localhostRRs []dns.RR
)

Expand Down Expand Up @@ -146,8 +145,8 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, query *dns.Msg) er
log.Warningf("nameserver: could not get remote address of request for %s%s, ignoring", q.FQDN, q.QType)
return nil
}
if !remoteAddr.IP.Equal(ipv4Localhost) {
// if request is not coming from 127.0.0.1, check if it's really local
if !netutils.IPIsLocalhost(remoteAddr.IP) {
// If request is not from a localhost address, check it it's really local.

localAddr, ok := w.RemoteAddr().(*net.UDPAddr)
if !ok {
Expand Down

0 comments on commit d17f83a

Please sign in to comment.