diff --git a/ChangeLog.txt b/ChangeLog.txt index 4a0e852d..af01203b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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) diff --git a/configs/slpkg.toml b/configs/slpkg.toml index 51f507b7..a75f00fe 100644 --- a/configs/slpkg.toml +++ b/configs/slpkg.toml @@ -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 = "" diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 6d087f73..ff7a74cd 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -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: diff --git a/slpkg/configs.py b/slpkg/configs.py index 24a69473..001fc260 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -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']