Ejemplo n.º 1
0
 def resolve(self, name, timeout = (1, 3, 11, 45)):
     """Return a Deferred that will resolve a hostname.
     """
     if not name:
         # XXX - This is *less than* '::', and will screw up IPv6 servers
         return defer.succeed('0.0.0.0')
     if abstract.isIPAddress(name):
         return defer.succeed(name)
     return self.resolver.getHostByName(name, timeout)
Ejemplo n.º 2
0
 def getHostByName(self, name, timeout = (1, 3, 11, 45)):
     try:
         address = socket.gethostbyname(name)
     except socket.error:
         msg = "address %r not found" % (name,)
         err = error.DNSLookupError(msg)
         return defer.fail(err)
     else:
         return defer.succeed(address)