Skip to content
Snippets Groups Projects
Commit fca51371 authored by Zsombor Welker's avatar Zsombor Welker
Browse files

Only return NXDOMAIN of no records exist for a domain

If there are some records (only A, but no AAAA) return an empty NOERROR.
parent 1cb405cb
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ class DockerDNSConnector:
self.dns_domains = dns_domains
self.docker_interface = docker_interface
self.handler = handler
self.resolved_registered = False
self.dns_domains_globs = ['*%s' % domain if domain.startswith('.') else domain for domain in dns_domains]
......@@ -62,6 +63,9 @@ class DockerDNSConnector:
self.handler.on_stop()
def update_resolved(self, enabled=True):
if self.resolved_registered == enabled:
return
with IPRoute() as ipr:
ifi = ipr.link_lookup(ifname=self.docker_interface)
if not ifi:
......@@ -88,6 +92,8 @@ class DockerDNSConnector:
else:
manager.RevertLink(ifindex)
self.resolved_registered = enabled
def handle_hosts(self, hosts):
zone = []
host_names = []
......
......@@ -32,12 +32,14 @@ class ZoneResolver(BaseResolver):
qname = request.q.qname
qtype = QTYPE[request.q.qtype]
found_name_match = False
zone = self.zone
for name, rtype, rr in zone:
# Check if label & type match
if getattr(qname, self.eq)(name) and (qtype == rtype or
qtype == 'ANY' or
rtype == 'CNAME'):
if getattr(qname, self.eq)(name):
found_name_match = True
if qtype == rtype or qtype == 'ANY' or rtype == 'CNAME':
# If we have a glob match fix reply label
if self.glob:
a = copy.copy(rr)
......@@ -52,7 +54,7 @@ class ZoneResolver(BaseResolver):
if a_name == rr.rdata.label and a_rtype in ['A', 'AAAA']:
reply.add_ar(a_rr)
if not reply.rr:
if not found_name_match:
reply.header.rcode = RCODE.NXDOMAIN
return reply
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment