There is a bug in the extractRecord function of common.py. And I open a ticket in <a href="http://twistedmatrix.com/trac/ticket/2850">http://twistedmatrix.com/trac/ticket/2850</a><br>----------------------------------------------------------------------------------------------------
<br><div class="searchable">
              <p>
Python Version:2.5<br>Twisted Version:2.5<br>
Names Version:0.4<br></p><p><br>
</p>
<p>
When we got a resolver and call getHostByname, perhaps DNS server can
return CNAME, Auth NS Server Name and Auth NS Server IP Address. So
extractRecord function will extract the Auth NS Server and send the DNS
request to the Auth NS Server. But there is a bug in the extractRecord
function.
</p>
<p>
Code:
</p>
<blockquote>
<p>
# No answers, but maybe there&#39;s a hint at who we should be asking about this
for r in answers:
</p>
<blockquote>
<p>
if r.type == dns.NS:
</p>
<blockquote>
<p>
from twisted.names import client
r = client.Resolver(servers=[(str(<a href="http://r.payload.name">r.payload.name</a>), dns.PORT)])
return r.lookupAddress(str(name)
</p>
</blockquote>
</blockquote>
</blockquote>
<p>Generally, the Auth NS Server is the Domain name, and it&#39;s IP
contained in the addition fields. If we get the NS Server by
<a href="http://r.payload.name">r.payload.name</a>, we will get the DNS Server Domain, so the Domain as
server will pass to client.queryUDP as DNS Server Address. UDP.write
will complaint that warnings.warn(&quot;Please only pass IPs to write(), not
hostnames &quot;+addr<a class="missing changeset" href="http://twistedmatrix.com/trac/changeset/0" rel="nofollow">[0]</a>, <a class="missing wiki" href="http://twistedmatrix.com/trac/wiki/DeprecationWarning" rel="nofollow">
DeprecationWarning?</a>, stacklevel=2). In addition, self.socket.sendto(datagram, addr) will call socket.gethostbyname(addr), but this call is block.
</p>
<p>
I think we should use the Auth NS Server IP to replace the Domain.
The patch code as fellow:</p><p>Any comment is welcome!<br>
</p>
<blockquote>
<p>
# No answers, but maybe there&#39;s a hint at who we should be asking about this
for r in answers:
</p>
<blockquote>
<p>
if r.type == dns.NS:
</p>
<blockquote>
<p>
from twisted.names import client <br></p><p>server = str(<a href="http://r.payload.name">r.payload.name</a>)
</p>
</blockquote>
</blockquote>
</blockquote>
<p>
</p>
<blockquote>
<blockquote>
<blockquote>
<p>
for s in answers:
</p>
<blockquote>
<p>
if s.type==dns.A and str(<a href="http://s.name">s.name</a>)==server :
</p>
<blockquote>
<p>
server =  socket.inet_ntop(socket.AF_INET, s.payload.address)
break
</p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<blockquote>
<blockquote>
<blockquote>
<p>
r = client.Resolver(servers=[(server, dns.PORT)])</p><br><p><br></p><br><p><br></p><p><br></p><p><br></p><p><br>
</p>
</blockquote>
</blockquote>
</blockquote>
            </div><br>