mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-04 22:34:52 +00:00
Fix handling proxies with domain names
This commit is contained in:
parent
28abcaac50
commit
8ea556b65f
1 changed files with 8 additions and 4 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import socks
|
import socks
|
||||||
|
|
@ -39,11 +40,14 @@ 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_INET6)
|
|
||||||
else:
|
|
||||||
super().__init__(socket.AF_INET)
|
super().__init__(socket.AF_INET)
|
||||||
|
else:
|
||||||
|
if isinstance(ip_address, ipaddress.IPv6Address):
|
||||||
|
super().__init__(socket.AF_INET6)
|
||||||
|
else:
|
||||||
|
super().__init__(socket.AF_INET)
|
||||||
|
|
||||||
self.set_proxy(
|
self.set_proxy(
|
||||||
proxy_type=socks.SOCKS5,
|
proxy_type=socks.SOCKS5,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue