summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-05-26 16:17:11 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-05-26 16:17:11 +0200
commit0190ceb88992acf6b1e3d8cd6cb29c45b4b78470 (patch)
tree7d6fc8a7ba1690c79b6e8a0b6bef8ff8ea42da94
parentbb08195a30cdf309f492231b88142d2d97c2a5ae (diff)
Replaced IPv6 resolver.
-rw-r--r--ipv6.py14
1 files 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())