Remove square braces from IPv6 addresses (#561)

This commit is contained in:
frizzlywitch 2018-01-26 16:38:13 +03:00 committed by Lonami
parent 43a3f40527
commit 3b8365f871

View File

@ -56,12 +56,7 @@ class TcpClient:
:param port: the port to connect to. :param port: the port to connect to.
""" """
if ':' in ip: # IPv6 if ':' in ip: # IPv6
# The address needs to be surrounded by [] as discussed on PR#425 ip = ip.replace('[', '').replace(']', '')
if not ip.startswith('['):
ip = '[' + ip
if not ip.endswith(']'):
ip = ip + ']'
mode, address = socket.AF_INET6, (ip, port, 0, 0) mode, address = socket.AF_INET6, (ip, port, 0, 0)
else: else:
mode, address = socket.AF_INET, (ip, port) mode, address = socket.AF_INET, (ip, port)