On Wed, 19 Aug 2009, Enrico Tröger wrote:
So, I changed the code above to use dns.query.tcp() and then I actually
I get the expected result. But I'd prefer to use UDP by default and
also fallback to TCP if necessary.
The question is now: is there a better way to check whether I need to
query via TCP than by checking whether q.answer is empty? I'd have
expected that dnspython raises an exception and this is why in the
except handler I have the TCP variant. But so far, no exception is
thrown instead the q.anser object is just empty.
I use (answer.flags & dns.flags.TC) to check whether the truncate (TC) bit
is checked, which indicates that the response was truncated.
Checking that the answers section is empty is not a good way to check, as
many servers will give a partial answer (and set the TC bit to inform the
querying application that it is a partial answer).
Just to be clear, some other DNS servers with less information output
on ANY I tested work with the above code. And I also get
the expected results for dnspython.org if I query specific RR types
like MX or similar, the problem is only with the type ANY.
Querying for -t any for dnspython.org results in a packet larger than 512
bytes (in this case, because dnspython.org has as lot of DNSSEC-related
records), so the answers do not fit in a standard DNS UDP packet, and
retrying on TCP is necessary to get the full answer.
--
Kevin Chen
_______________________________________________
dnspython-users mailing list
[email protected]
http://howl.play-bow.org/mailman/listinfo.cgi/dnspython-users