Skip to content

Commit 2fb3a0c

Browse files
committed
Added http_proxy support to downloader.ini file.
1 parent 02b74d9 commit 2fb3a0c

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ downloader_retries = 3
7373
; verbose: when true, will make Downloader output to display additional debug information
7474
; This is also necessary to be active to display benchmark information.
7575
verbose = false
76+
77+
; http_proxy: Routes all downloads through a proxy server (advanced, rarely needed)
78+
; Format: 'http://proxy-server:port'
79+
http_proxy = ''
7680
```
7781

7882
### Feature Roadmap

src/downloader/config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ class ConfigMisterSection(TypedDict):
8686
minimum_system_free_space_mb: int
8787
minimum_external_free_space_mb: int
8888
user_defined_options: List[str]
89+
http_proxy: Optional[str]
8990

9091

91-
class ConfigRequired(ConfigMisterSection, HttpConfig):
92+
class ConfigRequired(ConfigMisterSection):
9293
zip_file_count_threshold: int
9394
zip_accumulated_mb_threshold: int
9495
debug: bool
@@ -102,6 +103,7 @@ class ConfigRequired(ConfigMisterSection, HttpConfig):
102103
fail_on_file_error: bool
103104
curl_ssl: str
104105
http_logging: bool
106+
http_config: HttpConfig
105107

106108
class Config(ConfigRequired, total=False):
107109
environment: Environment # This should never be used. It's there just to be debug-logged.
@@ -142,8 +144,8 @@ def default_config() -> Config:
142144
'fail_on_file_error': False,
143145
'minimum_system_free_space_mb': DEFAULT_MINIMUM_SYSTEM_FREE_SPACE_MB,
144146
'minimum_external_free_space_mb': DEFAULT_MINIMUM_EXTERNAL_FREE_SPACE_MB,
145-
'http_proxy': None,
146-
'https_proxy': None
147+
'http_proxy': '',
148+
'http_config': None
147149
}
148150

149151

src/downloader/config_reader.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
K_DB_URL, K_DOWNLOADER_THREADS_LIMIT, K_DOWNLOADER_TIMEOUT, K_DOWNLOADER_RETRIES, K_FILTER, K_BASE_SYSTEM_PATH, \
3131
K_STORAGE_PRIORITY, K_ALLOW_DELETE, K_ALLOW_REBOOT, K_VERBOSE, K_UPDATE_LINUX, K_MINIMUM_SYSTEM_FREE_SPACE_MB, \
3232
K_MINIMUM_EXTERNAL_FREE_SPACE_MB, STORAGE_PRIORITY_OFF, STORAGE_PRIORITY_PREFER_SD, \
33-
STORAGE_PRIORITY_PREFER_EXTERNAL, EXIT_ERROR_WRONG_SETUP
33+
STORAGE_PRIORITY_PREFER_EXTERNAL, EXIT_ERROR_WRONG_SETUP, K_HTTP_PROXY
3434
from downloader.db_options import DbOptions, DbOptionsProps, DbOptionsValidationException
3535
from downloader.http_gateway import http_config
3636
from downloader.logger import Logger, time_str
@@ -160,7 +160,9 @@ def read_config(self, config_path: str) -> Config:
160160
result['curl_ssl'] = ''
161161

162162
if self._env['HTTP_PROXY'] or self._env['HTTPS_PROXY']:
163-
result.update(http_config(http_proxy=self._env['HTTP_PROXY'], https_proxy=self._env['HTTPS_PROXY']))
163+
result['http_config'] = http_config(http_proxy=self._env['HTTP_PROXY'], https_proxy=self._env['HTTPS_PROXY'])
164+
elif result['http_proxy'] != '':
165+
result['http_config'] = http_config(http_proxy=result['http_proxy'], https_proxy=None)
164166

165167
result['environment'] = self._env
166168

@@ -242,7 +244,8 @@ def _parse_mister_section(self, result: Config, parser: 'IniParser') -> ConfigMi
242244
'filter': parser.get_string(K_FILTER, result['filter']).strip().lower(),
243245
'minimum_system_free_space_mb': parser.get_int(K_MINIMUM_SYSTEM_FREE_SPACE_MB, result['minimum_system_free_space_mb']),
244246
'minimum_external_free_space_mb': parser.get_int(K_MINIMUM_EXTERNAL_FREE_SPACE_MB, result['minimum_external_free_space_mb']),
245-
'user_defined_options': []
247+
'user_defined_options': [],
248+
'http_proxy': parser.get_string(K_HTTP_PROXY, '').strip().lower()
246249
}
247250

248251
for key in mister:

src/downloader/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def FILE_7z_util_uninstalled_description() -> SafeFetchInfo: return {
156156
K_IS_PC_LAUNCHER: Final[str] = 'is_pc_launcher'
157157
K_MINIMUM_SYSTEM_FREE_SPACE_MB: Final[str] = 'minimum_system_free_space_mb'
158158
K_MINIMUM_EXTERNAL_FREE_SPACE_MB: Final[str] = 'minimum_external_free_space_mb'
159+
K_HTTP_PROXY: Final[str] = 'http_proxy'
159160

160161
# Default Config option
161162
DEFAULT_CACERT_FILE: Final[str] = '/etc/ssl/certs/cacert.pem'

src/downloader/full_run_service_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def create(self, config: Config):
7878
ssl_ctx=ssl_ctx,
7979
timeout=http_connection_timeout,
8080
logger=DebugOnlyLoggerDecorator(self._logger) if config['http_logging'] else None,
81-
config=config
81+
config=config['http_config']
8282
)
8383
atexit.register(http_gateway.cleanup)
8484
safe_file_fetcher = SafeFileFetcher(config, system_file_system, self._logger, http_gateway, waiter)

0 commit comments

Comments
 (0)