mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 20:59:29 +00:00
Fix handling proxies with domain names
This commit is contained in:
parent
28abcaac50
commit
8ea556b65f
@ -18,6 +18,7 @@
|
||||
|
||||
import logging
|
||||
import socket
|
||||
import ipaddress
|
||||
|
||||
try:
|
||||
import socks
|
||||
@ -39,8 +40,11 @@ class TCP(socks.socksocket):
|
||||
port = proxy.get("port", None)
|
||||
|
||||
try:
|
||||
socket.inet_aton(hostname)
|
||||
except socket.error:
|
||||
ip_address = ipaddress.ip_address(hostname)
|
||||
except ValueError:
|
||||
super().__init__(socket.AF_INET)
|
||||
else:
|
||||
if isinstance(ip_address, ipaddress.IPv6Address):
|
||||
super().__init__(socket.AF_INET6)
|
||||
else:
|
||||
super().__init__(socket.AF_INET)
|
||||
|
Loading…
Reference in New Issue
Block a user