mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 05:04:33 +03:00
Ensure IPv6 addresses are surrounded by '[]' (#425)
This commit is contained in:
parent
edd73ed69a
commit
4ddbc78699
|
@ -37,6 +37,12 @@ class TcpClient:
|
||||||
'timeout' must be given in seconds
|
'timeout' must be given in seconds
|
||||||
"""
|
"""
|
||||||
if ':' in ip: # IPv6
|
if ':' in ip: # IPv6
|
||||||
|
# The address needs to be surrounded by [] as discussed on PR#425
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user