[Twisted-Python] Beginner's question about names and callbacks

Adan Broderick broder79 at gmail.com
Sun Jan 25 23:06:37 MST 2009


I'm trying to write a program that will call my own function whenever a
query to a nameserver times out. I have figured out how to run the DNS
server. And I also know how to use filterAnswers(). But how do I catch the
"Failure: twisted.names.error.DNSQueryTimeoutError:" messages by adding code
to the resolver I've constructed?
I've got something like this:

class myResolver(client.Resolver):
    def filterAnswers(self, message):
        print "answer:",message
        [snipped code]

resolver = myResolver(servers=[('10.0.1.1', 53)])
f = server.DNSServerFactory(clients=[resolver])
reactor.listenTCP(4053, f)
reactor.run()

But I don't see where to add an addErrback call. The important thing here is
that I'm not getting the  domains to look up on the command line or from the
user. They are coming in over a socket from, say, dig. So I'm trying to
avoid parsing those queries myself since the full DNS query protocol is
hefty; that is, I want twisted to do the work of the parsing the input.
Thanks for your help.

-Broder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20090126/8a05b0c0/attachment.html>


More information about the Twisted-Python mailing list