From cf4a3b1861f9735a5db8041a8be784cc56e1ba72 Mon Sep 17 00:00:00 2001 From: John Goerzen Date: Tue, 24 May 2005 00:09:21 +0100 Subject: [PATCH] Support IPv6 with SSL Fix for Debian #309965. --- offlineimap/imaplib.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/offlineimap/imaplib.py b/offlineimap/imaplib.py index 59b3cb1..d37e7da 100644 --- a/offlineimap/imaplib.py +++ b/offlineimap/imaplib.py @@ -1127,8 +1127,15 @@ class IMAP4_SSL(IMAP4): """ self.host = host self.port = port - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.connect((host, port)) + #This connects to the first ip found ipv4/ipv6 + #Added by Adriaan Peeters based on a socket + #example from the python documentation: + #http://www.python.org/doc/lib/socket-example.html + res = socket.getaddrinfo(host, port, socket.AF_UNSPEC, + socket.SOCK_STREAM) + af, socktype, proto, canonname, sa = res[0] + self.sock = socket.socket(af, socktype, proto) + self.sock.connect(sa) if sys.version_info[0] <= 2 and sys.version_info[1] <= 2: self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile) else: