Updated for proxies

This commit is contained in:
Dimitris Zlatanidis 2023-04-15 13:26:11 +03:00
parent 13dd1e0857
commit aab33f79a9
4 changed files with 12 additions and 11 deletions

View file

@ -1,3 +1,7 @@
4.7.9 - 15/04/203
Updated:
- For proxies configuration
4.7.8 - 12/04/203
Added:
- Module to support for Unix shell-style wildcards for blacklist (Thanks to marav)

View file

@ -67,10 +67,9 @@ LFTP_GET_OPTIONS = "-c get -e"
LFTP_MIRROR_OPTIONS = "-c mirror --parallel=100 --only-newer"
# If you are going to use a proxy server, try to fill in these variables.
# Choose between http or socks proxy type, not both.
# Choose between http or socks proxy type.
# For a socks proxy, you need to install the PySocks package.
# https://urllib3.readthedocs.io/en/stable/advanced-usage.html#socks-proxies
HTTP_PROXY_ADDRESS = ""
SOCKS_PROXY_ADDRESS = ""
PROXY_ADDRESS = ""
PROXY_USERNAME = ""
PROXY_PASSWORD = ""

View file

@ -171,17 +171,17 @@ class CheckUpdates(Configs):
http = PoolManager()
proxy_default_headers = make_headers(proxy_basic_auth=f'{self.proxy_username}:{self.proxy_password}')
if self.http_proxy_address:
http = ProxyManager(f'{self.http_proxy_address}', headers=proxy_default_headers)
if self.proxy_address.startswith('http'):
http = ProxyManager(f'{self.proxy_address}', headers=proxy_default_headers)
elif self.socks_proxy_address:
elif self.proxy_address.startswith('socks'):
# https://urllib3.readthedocs.io/en/stable/advanced-usage.html#socks-proxies
try: # Try to import PySocks if it's installed.
from urllib3.contrib.socks import SOCKSProxyManager
except (ModuleNotFoundError, ImportError):
raise SystemExit()
http = SOCKSProxyManager(f'{self.socks_proxy_address}', headers=proxy_default_headers)
http = SOCKSProxyManager(f'{self.proxy_address}', headers=proxy_default_headers)
repo = http.request('GET', self.repo_chg_txt)
except KeyboardInterrupt:

View file

@ -77,8 +77,7 @@ class Configs:
progress_spinner: str = 'pixel'
spinner_color: str = 'green'
http_proxy_address: str = ''
socks_proxy_address: str = ''
proxy_address: str = ''
proxy_username: str = ''
proxy_password: str = ''
@ -109,8 +108,7 @@ class Configs:
file_pattern_conf: str = config['FILE_PATTERN']
progress_spinner: str = config['PROGRESS_SPINNER']
spinner_color: str = config['SPINNER_COLOR']
http_proxy_address: str = config['HTTP_PROXY_ADDRESS']
socks_proxy_address: str = config['SOCKS_PROXY_ADDRESS']
proxy_address: str = config['PROXY_ADDRESS']
proxy_username: str = config['PROXY_USERNAME']
proxy_password: str = config['PROXY_PASSWORD']