From 56ac894f4145a650722f225f8a6fb99de3e429a8 Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Tue, 29 Apr 2003 03:17:30 +0100 Subject: [PATCH] /offlineimap/head: changeset 457 Made OfflineIMAP IPv6-aware. Used the short patch from Adriaan Peeters in Debian bug report 186636. Closes: #186636. --- offlineimap/head/debian/changelog | 3 +++ offlineimap/head/offlineimap/imaplib.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/offlineimap/head/debian/changelog b/offlineimap/head/debian/changelog index 9573c74..17b4d36 100644 --- a/offlineimap/head/debian/changelog +++ b/offlineimap/head/debian/changelog @@ -10,6 +10,9 @@ offlineimap (3.99.15) unstable; urgency=low error message would not have been visible. Closes: #185709. * Fixed a silly error relating to handling of the remotepassfile. Closes: #189935. + * Made OfflineIMAP IPv6-aware. Used the short patch from + Adriaan Peeters in Debian bug report 186636. + Closes: #186636. -- John Goerzen Mon, 28 Apr 2003 14:00:32 -0500 diff --git a/offlineimap/head/offlineimap/imaplib.py b/offlineimap/head/offlineimap/imaplib.py index 82e1894..baf00b1 100644 --- a/offlineimap/head/offlineimap/imaplib.py +++ b/offlineimap/head/offlineimap/imaplib.py @@ -217,8 +217,16 @@ class 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) + self.file = self.sock.makefile('rb')