]> code.delx.au - offlineimap/commitdiff
Support IPv6 with SSL
authorJohn Goerzen <jgoerzen@complete.org>
Mon, 23 May 2005 23:09:21 +0000 (00:09 +0100)
committerJohn Goerzen <jgoerzen@complete.org>
Mon, 23 May 2005 23:09:21 +0000 (00:09 +0100)
Fix for Debian #309965.

offlineimap/imaplib.py

index 59b3cb1ffeb7c54cd42d4ecc69e2f5229b130c89..d37e7da3009bd7df7658dd6e15352682dc6c71a5 100644 (file)
@@ -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 <apeeters@lashout.net> 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: