Allow Connection to connect to ipv6 addresses

This commit is contained in:
Dan 2018-06-13 13:35:41 +02:00
parent 8ac48c555c
commit efe26bcb19

View File

@ -21,6 +21,7 @@ import threading
import time import time
from .transport import * from .transport import *
from ..session.internals import DataCenter
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -36,16 +37,18 @@ class Connection:
4: TCPIntermediateO 4: TCPIntermediateO
} }
def __init__(self, address: tuple, proxy: dict, mode: int = 1): def __init__(self, dc_id: int, test_mode: bool, ipv6: bool, proxy: dict, mode: int = 1):
self.address = address self.ipv6 = ipv6
self.proxy = proxy self.proxy = proxy
self.address = DataCenter(dc_id, test_mode, ipv6)
self.mode = self.MODES.get(mode, TCPAbridged) self.mode = self.MODES.get(mode, TCPAbridged)
self.lock = threading.Lock() self.lock = threading.Lock()
self.connection = None self.connection = None
def connect(self): def connect(self):
for i in range(Connection.MAX_RETRIES): for i in range(Connection.MAX_RETRIES):
self.connection = self.mode(self.proxy) self.connection = self.mode(self.ipv6, self.proxy)
try: try:
log.info("Connecting...") log.info("Connecting...")