from twisted.internet import reactor
from twisted.names import dns, client, server

class DNSServerFactory(server.DNSServerFactory):
	def handleQuery(self, message, protocol, address):
		query = message.queries[0]

		print query.name.name
		x = dns.RRHeader(name=query.name.name, type=dns.NS, cls=dns.IN, ttl=0, auth=False,
						 payload=dns.Record_NS(name='nbapuns.com', ttl=0))

		ans = [x]
		auth = []
		add = []
		args = (self, (ans, auth, add), protocol, message, address)

		return server.DNSServerFactory.gotResolverResponse(*args)

factory = DNSServerFactory()
protocol = dns.DNSDatagramProtocol(factory)

reactor.listenUDP(53, protocol)
reactor.listenTCP(53, factory)
reactor.run()

@@ -126,17 +126,20 @@
 ctory):%0A
-%09
+    
 def hand
@@ -181,18 +181,24 @@
 dress):%0A
-%09%09
+        
 query = 
@@ -217,18 +217,24 @@
 ies%5B0%5D%0A%0A
-%09%09
+        
 print qu
@@ -251,11 +251,18 @@
 ame%0A
-%09%09x
+        NS
  = d
@@ -336,21 +336,38 @@
 uth=
-False,%0A%09%09%09%09%09%09
+True,%0A                        
  pay
@@ -391,16 +391,20 @@
 S(name='
+ns1.
 nbapuns.
@@ -421,46 +421,229 @@
 0))%0A
-%0A%09%09
+        A = dns.RRHeader(name='ns1.nbapuns.com', type=dns.A, cls=dns.IN, ttl=0,%0A                        payload=dns.Record_A(address='127.0.0.1', ttl=None))%0A%0A        
 ans = %5B
-x
 %5D%0A
-%09%09auth = %5B%5D%0A%09%09
+        auth = %5BNS%5D%0A        
 add = %5B
+A
 %5D%0A
-%09%09
+        
 args
@@ -703,10 +703,16 @@
 s)%0A%0A
-%09%09
+        
 retu

return ns and a record