[Twisted-Python] [PATCH] twisted.names.hosts not working correct with getHostByName

ralf at brainbot.com ralf at brainbot.com
Mon Feb 16 20:47:19 EST 2004


Even with my prior patch I'm not able to use twisted.names.client.getHostByName.
Seems like twisted.names.hosts.Resolver calls itself with bad parameters
and even doesn't use the ip address it extracted from /etc/hosts. Also the return 
value could not be handled by the code in twisted.names.common.extractRecord.
The following patch seems to solve those problems.

- Ralf




===================================================================
RCS file: /cvs/Twisted/twisted/names/hosts.py,v
retrieving revision 1.14
diff -u -r1.14 hosts.py
--- twisted/names/hosts.py      19 Jul 2003 10:13:50 -0000      1.14
+++ twisted/names/hosts.py      17 Feb 2004 01:45:44 -0000
@@ -49,11 +49,11 @@
 
 
     def query(self, query, timeout = None):
-        return self._lookup(str(query.name), query.type, query.type, timeout)
+        return self._lookup(str(query.name), query.cls, query.type, timeout)
 
 
     def _lookup(self, name, cls, type, timeout):
-        if cls != dns.IN or type != dns.A:
+        if cls != dns.IN or (type != dns.A and type != dns.ALL_RECORDS): # getHostByName passes type==dns.ALL_RECORDS. what else do we need here?
             return defer.fail(failure.Failure(NotImplementedError(type, cls)))
         return self.lookupAddress(
             name, timeout
@@ -64,7 +64,7 @@
         res = searchFileFor(self.file, name)
         if res:
             return defer.succeed([
-                [dns.RRHeader(name, dns.A, dns.IN, self.ttl)], (), ()
+                [dns.RRHeader(name, dns.A, dns.IN, self.ttl, dns.Record_A(res, self.ttl))], [], []
             ])
         return defer.fail(failure.Failure(dns.DomainError(name)))
 
-- 
brainbot technologies ag
boppstrasse 64 . 55118 mainz . germany
fon +49 6131 211639-1 . fax +49 6131 211639-2
http://brainbot.com/  mailto:ralf at brainbot.com




More information about the Twisted-Python mailing list