From 0190ceb88992acf6b1e3d8cd6cb29c45b4b78470 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Wed, 26 May 2010 16:17:11 +0200 Subject: Replaced IPv6 resolver. --- ipv6.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ipv6.py b/ipv6.py index eb6ce2e..12562c9 100644 --- a/ipv6.py +++ b/ipv6.py @@ -5,6 +5,9 @@ from twisted.internet import default from twisted.internet import protocol from twisted.internet import reactor +from twisted.names.client import Resolver +resolver = Resolver('/etc/resolv.conf') + class IPv6Address(object): def __init__(self, type, host, port, flowInfo, scope): self.type = type @@ -38,10 +41,17 @@ class Client(tcp.Client): if isIPv6Address(self.addr[0]): self._setRealAddress(self.addr[0]) else: - reactor.resolve(self.addr[0]).addCallbacks( - self._setRealAddress, self.failIfNotConnected + resolver.lookupIPV6Address(self.addr[0]).addCallbacks( + self.resolvedAddress, self.failIfNotConnected ) + def resolvedAddress(self, addr): + aaaa = addr[0][-1].payload + if aaaa.fancybasename != 'AAAA': + self.failIfNotConnected(Exception('Unable to resolve IPv6 address.')) + return + self._setRealAddress(aaaa._address) + def getHost(self): return IPv6Address('TCP', *self.socket.getsockname()) -- cgit v1.2.3