Skip to content

Instantly share code, notes, and snippets.

@wallrj

wallrj/toothe.py Secret

Last active August 29, 2015 14:02
Show Gist options
  • Save wallrj/84c3815a0be52831e077 to your computer and use it in GitHub Desktop.
Save wallrj/84c3815a0be52831e077 to your computer and use it in GitHub Desktop.
diff --git a/toothe.py b/toothe.py
index 8da4cae..507b434 100644
--- a/toothe.py
+++ b/toothe.py
@@ -11,8 +11,9 @@ class DynamicResolver(object):
name = name,
payload = dns.Record_A(address=b'1.2.3.4'))
- second = dns.RRHeader(
+ answer = dns.RRHeader(
name = name,
+ type = dns.TXT,
payload = dns.Record_TXT('First', 'Second'))
answers = [answer]
#!/usr/bin/python
from twisted.internet import reactor
from twisted.names import client, dns, server
class DynamicResolver(object):
def query(self, query, timeout=None):
name = query.name.name
answer = dns.RRHeader(
name = name,
payload = dns.Record_A(address=b'1.2.3.4'))
answer = dns.RRHeader(
name = name,
type = dns.TXT,
payload = dns.Record_TXT('First', 'Second'))
answers = [answer]
authority = []
additional = []
return answers, authority, additional
def main():
factory = server.DNSServerFactory(
clients = [DynamicResolver()]
)
protocol = dns.DNSDatagramProtocol(controller=factory)
reactor.listenUDP(10053, protocol)
reactor.listenTCP(10053, factory)
reactor.run()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment