Merge branch 'earies-ipv6' into next
This commit is contained in:
commit
208f555230
@ -580,6 +580,18 @@ type = GmailMaildir
|
|||||||
type = IMAP
|
type = IMAP
|
||||||
|
|
||||||
|
|
||||||
|
# This option stands in the [Repository RemoteExample] section.
|
||||||
|
#
|
||||||
|
# Configure which address family to use for the connection. If not specified,
|
||||||
|
# AF_UNSPEC is used as a fallback (default).
|
||||||
|
#
|
||||||
|
# AF_INET6:
|
||||||
|
#ipv6 = True
|
||||||
|
#
|
||||||
|
# AF_INET:
|
||||||
|
#ipv6 = False
|
||||||
|
|
||||||
|
|
||||||
# These options stands in the [Repository RemoteExample] section.
|
# These options stands in the [Repository RemoteExample] section.
|
||||||
#
|
#
|
||||||
# The following can fetch the account credentials via a python expression that
|
# The following can fetch the account credentials via a python expression that
|
||||||
|
@ -74,7 +74,7 @@ class UsefulIMAPMixIn(object):
|
|||||||
"""open_socket()
|
"""open_socket()
|
||||||
Open socket choosing first address family available."""
|
Open socket choosing first address family available."""
|
||||||
msg = (-1, 'could not open socket')
|
msg = (-1, 'could not open socket')
|
||||||
for res in socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM):
|
for res in socket.getaddrinfo(self.host, self.port, self.af, socket.SOCK_STREAM):
|
||||||
af, socktype, proto, canonname, sa = res
|
af, socktype, proto, canonname, sa = res
|
||||||
try:
|
try:
|
||||||
# use socket of our own, possiblly socksified socket.
|
# use socket of our own, possiblly socksified socket.
|
||||||
@ -175,6 +175,9 @@ class WrappedIMAP4_SSL(UsefulIMAPMixIn, IMAP4_SSL):
|
|||||||
"""Improved version of imaplib.IMAP4_SSL overriding select()."""
|
"""Improved version of imaplib.IMAP4_SSL overriding select()."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
if "af" in kwargs:
|
||||||
|
self.af = kwargs['af']
|
||||||
|
del kwargs['af']
|
||||||
if "use_socket" in kwargs:
|
if "use_socket" in kwargs:
|
||||||
self.socket = kwargs['use_socket']
|
self.socket = kwargs['use_socket']
|
||||||
del kwargs['use_socket']
|
del kwargs['use_socket']
|
||||||
@ -209,6 +212,9 @@ class WrappedIMAP4(UsefulIMAPMixIn, IMAP4):
|
|||||||
"""Improved version of imaplib.IMAP4 overriding select()."""
|
"""Improved version of imaplib.IMAP4 overriding select()."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
if "af" in kwargs:
|
||||||
|
self.af = kwargs['af']
|
||||||
|
del kwargs['af']
|
||||||
if "use_socket" in kwargs:
|
if "use_socket" in kwargs:
|
||||||
self.socket = kwargs['use_socket']
|
self.socket = kwargs['use_socket']
|
||||||
del kwargs['use_socket']
|
del kwargs['use_socket']
|
||||||
|
@ -23,6 +23,7 @@ import base64
|
|||||||
import json
|
import json
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
import socket
|
||||||
import time
|
import time
|
||||||
import errno
|
import errno
|
||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
@ -80,6 +81,13 @@ class IMAPServer:
|
|||||||
self.goodpassword = None
|
self.goodpassword = None
|
||||||
|
|
||||||
self.usessl = repos.getssl()
|
self.usessl = repos.getssl()
|
||||||
|
self.useipv6 = repos.getipv6()
|
||||||
|
if self.useipv6 == True:
|
||||||
|
self.af = socket.AF_INET6
|
||||||
|
elif self.useipv6 == False:
|
||||||
|
self.af = socket.AF_INET
|
||||||
|
else:
|
||||||
|
self.af = socket.AF_UNSPEC
|
||||||
self.hostname = \
|
self.hostname = \
|
||||||
None if self.preauth_tunnel else repos.gethost()
|
None if self.preauth_tunnel else repos.gethost()
|
||||||
self.port = repos.getport()
|
self.port = repos.getport()
|
||||||
@ -487,6 +495,7 @@ class IMAPServer:
|
|||||||
fingerprint=self.fingerprint,
|
fingerprint=self.fingerprint,
|
||||||
use_socket=self.proxied_socket,
|
use_socket=self.proxied_socket,
|
||||||
tls_level=self.tlslevel,
|
tls_level=self.tlslevel,
|
||||||
|
af=self.af,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.ui.connecting(self.hostname, self.port)
|
self.ui.connecting(self.hostname, self.port)
|
||||||
@ -494,6 +503,7 @@ class IMAPServer:
|
|||||||
self.hostname, self.port,
|
self.hostname, self.port,
|
||||||
timeout=socket.getdefaulttimeout(),
|
timeout=socket.getdefaulttimeout(),
|
||||||
use_socket=self.proxied_socket,
|
use_socket=self.proxied_socket,
|
||||||
|
af=self.af,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.preauth_tunnel:
|
if not self.preauth_tunnel:
|
||||||
|
@ -194,6 +194,9 @@ class IMAPRepository(BaseRepository):
|
|||||||
|
|
||||||
return self.getconfint('remoteport', None)
|
return self.getconfint('remoteport', None)
|
||||||
|
|
||||||
|
def getipv6(self):
|
||||||
|
return self.getconfboolean('ipv6', None)
|
||||||
|
|
||||||
def getssl(self):
|
def getssl(self):
|
||||||
return self.getconfboolean('ssl', 1)
|
return self.getconfboolean('ssl', 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user