fix
This commit is contained in:
parent
06edb7c818
commit
278fac9985
1 changed files with 8 additions and 6 deletions
14
dns.py
14
dns.py
|
@ -24,13 +24,16 @@ class ProxyResolver(BaseResolver):
|
||||||
]
|
]
|
||||||
|
|
||||||
qname = DNSLabel(request.q.qname)
|
qname = DNSLabel(request.q.qname)
|
||||||
|
current_server = ()
|
||||||
for (net, sub, trans, dns) in subnets:
|
for (net, sub, trans, dns) in subnets:
|
||||||
for serv in dns:
|
for serv in dns:
|
||||||
if serv["domain"] == str(qname)[-len(serv["domain"])-1:-1]:
|
if serv == str(qname)[-len(serv)-1:-1]:
|
||||||
if net == self.config.local_network:
|
if net == self.config.local_network:
|
||||||
address = dns["ip"]
|
current_server = {"sub": sub, "trans": trans, "dns": dns[serv]}
|
||||||
else:
|
else:
|
||||||
address = translate(serc["ip"], sub, trans)
|
current_server = {"sub": sub, "trans": trans, "dns": translate(dns[serv], sub, trans)}
|
||||||
|
address = current_server["dns"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
proxy_r = request.send(address, port, timeout=self.timeout)
|
proxy_r = request.send(address, port, timeout=self.timeout)
|
||||||
reply = DNSRecord.parse(proxy_r)
|
reply = DNSRecord.parse(proxy_r)
|
||||||
|
@ -39,9 +42,8 @@ class ProxyResolver(BaseResolver):
|
||||||
reply.header.rcode = getattr(RCODE, 'NXDOMAIN')
|
reply.header.rcode = getattr(RCODE, 'NXDOMAIN')
|
||||||
if address != self.default_address and address not in self.config.data["network"][self.config.local_network]["dns"].values():
|
if address != self.default_address and address not in self.config.data["network"][self.config.local_network]["dns"].values():
|
||||||
for rr in reply.rr:
|
for rr in reply.rr:
|
||||||
for (net, sub, trans, dns) in subnets:
|
if address == current_server["dns"] and IPv4Address(rr.rdata) in IPv4Network(current_server["sub"]):
|
||||||
if address in dns.values() and netIPv4Address(rr.rdata) in IPv4Network(sub):
|
rr.rdata.data = IPv4Address(translate(str(rr.rdata), current_server["sub"], current_server["trans"])).packed
|
||||||
rr.rdata.data = IPv4Address(translate(str(rr.rdata), sub, trans)).packed
|
|
||||||
reply.set_header_qa()
|
reply.set_header_qa()
|
||||||
return reply
|
return reply
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue