Flake8 and Pylint validations fixed
This commit is contained in:
parent
43e1c0149b
commit
c2c7f674a0
|
@ -45,10 +45,10 @@ def dns():
|
|||
for port in [8080, 8444]:
|
||||
logger.debug("Resolving %i through SOCKS...", port)
|
||||
address_family = socket.AF_INET
|
||||
sock = socks.socksocket(address_family, socket.SOCK_STREAM)
|
||||
sock = socks.SockSocket(address_family, socket.SOCK_STREAM)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.settimeout(20)
|
||||
proxytype = socks.PROXY_TYPE_SOCKS5
|
||||
proxytype = socks.proxy_type_socks5
|
||||
sockshostname = BMConfigParser().get(
|
||||
'bitmessagesettings', 'sockshostname')
|
||||
socksport = BMConfigParser().getint(
|
||||
|
|
|
@ -129,12 +129,12 @@ def wrapmodule(module):
|
|||
most of the Python Standard Library falls into this category.
|
||||
"""
|
||||
if _default_proxy is not None:
|
||||
module.socket.socket = Socksocket
|
||||
module.socket.socket = SockSocket
|
||||
else:
|
||||
raise GeneralProxyError((4, "no proxy specified"))
|
||||
|
||||
|
||||
class Socksocket(socket.socket):
|
||||
class SockSocket(socket.socket):
|
||||
"""socksocket([family[, type[, proto]]]) -> socket object
|
||||
Open a SOCKS enabled socket. The parameters are the same as
|
||||
those of the standard socket init. In order for SOCKS to work,
|
||||
|
@ -226,8 +226,8 @@ class Socksocket(socket.socket):
|
|||
# Okay, we need to perform a basic username/password
|
||||
# authentication.
|
||||
self.sendall(
|
||||
chr(0x01).encode() + chr(len(self.__proxy[4])) +
|
||||
self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]
|
||||
chr(0x01).encode() + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(
|
||||
len(self.__proxy[5])) + self.__proxy[5]
|
||||
)
|
||||
authstat = self.__recvall(2)
|
||||
if authstat[0:1] != chr(0x01).encode():
|
||||
|
@ -404,9 +404,9 @@ class Socksocket(socket.socket):
|
|||
addr = socket.gethostbyname(destination_address)
|
||||
else:
|
||||
addr = destination_address
|
||||
self.sendall(("CONNECT {} : {} HTTP/1.1\r\n Host: {} \r\n\r\n".format(
|
||||
addr, str(destination_port), destination_address)
|
||||
).encode())
|
||||
self.sendall(
|
||||
("CONNECT {} : {} HTTP/1.1\r\n Host: {} \r\n\r\n".format(
|
||||
addr, str(destination_port), destination_address)).encode())
|
||||
# We read the response until we get the string "\r\n\r\n"
|
||||
resp = self.recv(1)
|
||||
while resp.find("\r\n\r\n".encode()) == -1:
|
||||
|
@ -438,9 +438,8 @@ class Socksocket(socket.socket):
|
|||
To select the proxy server use setproxy().
|
||||
"""
|
||||
# Do a minimal input check first
|
||||
if (not type(destination_pair) in (list, tuple)) or \
|
||||
(len(destination_pair) < 2) or \
|
||||
(type(destination_pair[0]) != type('')) or (not isinstance(destination_pair[1], int)):
|
||||
if (not isinstance(destination_pair, (list, tuple))) or (len(destination_pair) < 2) \
|
||||
or not isinstance(destination_pair[0], str) or not isinstance(destination_pair[1], int):
|
||||
raise GeneralProxyError((5, _generalerrors[5]))
|
||||
|
||||
if self.__proxy[0] == proxy_type_socks5:
|
||||
|
|
Loading…
Reference in New Issue
Block a user