diff --git a/client/run.py b/client/run.py index 61aa884..b132182 100644 --- a/client/run.py +++ b/client/run.py @@ -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()