mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 08:14:14 +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
|
||||
"""
|
||||
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)
|
||||
else:
|
||||
mode, address = socket.AF_INET, (ip, port)
|
||||
|
|
Loading…
Reference in New Issue
Block a user