[Twisted-Python] Twisted.Names assistance with auth and additional sections

Jean-Paul Calderone exarkun at divmod.com
Tue Mar 20 18:30:11 EDT 2007


On Tue, 20 Mar 2007 14:27:26 -0700, Sean Leach <kickdaddy at gmail.com> wrote:
>Hey all,
>
>I have a client I have written using twisted.names that will send a
>DNS request.  Here is the gist of the relevant code:
>
>    (tfp, tfile) = tempfile.mkstemp()
>    os.write(tfp, 'nameserver %s' % ip)
>    os.close(tfp)
>    resolver = client.createResolver(resolvconf=tfile)
>    deferred = resolver.lookupAddress(somevalue)
>    deferred.addCallback(resultHandler)
>
>hacky way to set the IP, but I am having issues with passing in the
>"servers" list I don't want to troubleshoot until I figure out this
>problem.
>
>Anyways, as you can see, this code calls the lookupAddress method for
>the name I want.  The problem I am having is it is only returning the
>answer section of the response.  I need the additional and authority
>sections as well (and I know for sure those sections exist in the
>response).  I have looked at the docs and the code, and I don't know
>what I am missing.  I am sure it's something silly, but I am missing
>it right now.
>
>So long question short, what do I need to change in my code so I can
>get the additional sections and authority sections in the response so
>I can get to those values?

One approach would be to use queryUDP directly instead of lookupAddress:

    resolver.queryUDP([dns.Query(name, dns.A, dns.IN)])

Which will give you a full message object back, including lists of answers,
additional, and authority sections.

Jean-Paul




More information about the Twisted-Python mailing list