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 logging
|
||||||
import socket
|
import socket
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import socks
|
import socks
|
||||||
@ -39,8 +40,11 @@ class TCP(socks.socksocket):
|
|||||||
port = proxy.get("port", None)
|
port = proxy.get("port", None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
socket.inet_aton(hostname)
|
ip_address = ipaddress.ip_address(hostname)
|
||||||
except socket.error:
|
except ValueError:
|
||||||
|
super().__init__(socket.AF_INET)
|
||||||
|
else:
|
||||||
|
if isinstance(ip_address, ipaddress.IPv6Address):
|
||||||
super().__init__(socket.AF_INET6)
|
super().__init__(socket.AF_INET6)
|
||||||
else:
|
else:
|
||||||
super().__init__(socket.AF_INET)
|
super().__init__(socket.AF_INET)
|
||||||
|
Loading…
Reference in New Issue
Block a user