Fix protocol typing for python-socks.

This commit is contained in:
Serhii Dylda 2020-11-09 20:05:09 +01:00
parent 633986cfa6
commit 38d8a54cc1

View File

@ -74,11 +74,11 @@ class Connection(abc.ABC):
# to be backwards compatible with PySocks proxy format,
# (since socks.SOCKS5 == 2, socks.SOCKS4 == 1, socks.HTTP == 3)
if proxy_type == 2 or proxy_type == "socks5":
if isinstance(proxy_type, ProxyType.SOCKS5) or proxy_type == 2 or proxy_type == "socks5":
protocol = ProxyType.SOCKS5
elif proxy_type == 1 or proxy_type == "socks4":
elif isinstance(proxy_type, ProxyType.SOCKS4) or proxy_type == 1 or proxy_type == "socks4":
protocol = ProxyType.SOCKS4
elif proxy_type == 3 or proxy_type == "http":
elif isinstance(proxy_type, ProxyType.HTTP) or proxy_type == 3 or proxy_type == "http":
protocol = ProxyType.HTTP
else:
raise ValueError("Unknown proxy protocol type: {}".format(proxy_type))