Blindly implement HTTP to DNS forwarding option
This commit is contained in:
parent
7ade18b2e0
commit
64daa71c84
1 changed files with 14 additions and 1 deletions
|
@ -6,6 +6,9 @@ import dns.resolver
|
|||
import dnslib
|
||||
import dnslib.server
|
||||
|
||||
dnshandler = False
|
||||
httphandler = False
|
||||
|
||||
class SuperResolver(dnslib.server.BaseResolver):
|
||||
def __init__(self, raddr, rport, timeout = 0):
|
||||
self.raddr = raddr
|
||||
|
@ -20,12 +23,19 @@ class SuperResolver(dnslib.server.BaseResolver):
|
|||
self.rip = str(resolver.query(raddr)[0])
|
||||
|
||||
class HTTPResolver(SuperResolver):
|
||||
def __init__(self, raddr = "httpns.kumi.systems", rport = 9539, timeout = 0):
|
||||
def __init__(self, raddr = "httpns.kumi.systems", rport = 9539, timeout = 0, forwarding = False):
|
||||
global dnshandler
|
||||
|
||||
SuperResolver.__init__(self, raddr, rport, timeout)
|
||||
self.forwarding = forwarding
|
||||
|
||||
def resolve(self, req, handler):
|
||||
rep = req.reply()
|
||||
rep.header.rcode = getattr(dnslib.RCODE, "NXDOMAIN")
|
||||
|
||||
if forwarding and rep.header.rcode == getattr(dnslib.RCODE, "NXDOMAIN"):
|
||||
rep = dnshandler.resolve(req, handler)
|
||||
|
||||
return rep
|
||||
|
||||
class DNSResolver(SuperResolver):
|
||||
|
@ -42,3 +52,6 @@ class DNSResolver(SuperResolver):
|
|||
|
||||
return rep
|
||||
|
||||
if __name__ == "__main__":
|
||||
dnshandler = DNSResolver()
|
||||
httphandler = HTTPResolver()
|
||||
|
|
Loading…
Reference in a new issue