diff --git a/minode/connection.py b/minode/connection.py index cd10e0c..cf59b6e 100644 --- a/minode/connection.py +++ b/minode/connection.py @@ -544,11 +544,13 @@ class SocksConnection(Connection): import socks + proxy_type = socks.PROXY_TYPES[shared.socks_proxy.scheme.upper()] + try: self.s = socks.create_connection( - (self.host, self.port), 30, None, socks.PROXY_TYPE_SOCKS5, - shared.socks_proxy[0], shared.socks_proxy[1], True, - None, None, None) + (self.host, self.port), 30, None, proxy_type, + shared.socks_proxy.hostname, shared.socks_proxy.port, True, + shared.socks_proxy.username, shared.socks_proxy.password, None) self.status = 'connected' logging.debug('Established SOCKS connection to %s', peer_str) except socket.timeout: diff --git a/minode/main.py b/minode/main.py index 2fabfd5..53cadb4 100644 --- a/minode/main.py +++ b/minode/main.py @@ -5,8 +5,10 @@ import base64 import logging import multiprocessing import os +import re import signal import socket +from urllib import parse try: import socks @@ -118,10 +120,11 @@ def parse_arguments(): # pylint: disable=too-many-branches,too-many-statements if args.tor: shared.tor = True if not args.socks_proxy: - shared.socks_proxy = ('127.0.0.1', 9050) + args.socks_proxy = '127.0.0.1:9050' if args.socks_proxy: - addr = args.socks_proxy.split(':') - shared.socks_proxy = (addr[0], int(addr[1])) + if not re.match(r'^.*://', args.socks_proxy): + args.socks_proxy = '//' + args.socks_proxy + shared.socks_proxy = parse.urlparse(args.socks_proxy, scheme='socks5') def bootstrap_from_dns(): @@ -266,6 +269,13 @@ def main(): 'Error while creating data directory in: %s', shared.data_directory, exc_info=True) + if shared.socks_proxy: + try: + socks.PROXY_TYPES[shared.socks_proxy.scheme.upper()] + except KeyError: + logging.error('Unsupported proxy schema!') + return + if shared.ip_enabled and not shared.trusted_peer: bootstrap_from_dns()