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