Skip to content

Commit 41d609f

Browse files
authored
Merge pull request #650 from recreators01/https_proxy
feat: add support for https_proxy environment variable (#415)
2 parents 7491744 + ba57ada commit 41d609f

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

umu/umu_run.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from types import FrameType
2424
from typing import Any
2525

26-
from urllib3 import PoolManager, Retry
26+
from urllib3 import PoolManager, Retry, ProxyManager
2727
from urllib3.exceptions import HTTPError
2828
from urllib3.util import Timeout
2929
from Xlib import X, Xatom, display
@@ -935,11 +935,19 @@ def _check_offline_runtime(_rt: UmuRuntime) -> bool:
935935
else:
936936
timeouts = NET_TIMEOUT
937937

938+
http_pool: PoolManager
939+
if "https_proxy" in os.environ:
940+
http_pool = ProxyManager(
941+
proxy_url=os.environ["https_proxy"],
942+
timeout=Timeout(connect=timeouts, read=timeouts),
943+
retries=Retry(total=retries, redirect=True),
944+
)
945+
else:
946+
http_pool = PoolManager(
947+
timeout=Timeout(connect=timeouts, read=timeouts),
948+
retries=Retry(total=retries, redirect=True),
949+
)
938950
thread_pool = ThreadPoolExecutor()
939-
http_pool = PoolManager(
940-
timeout=Timeout(connect=timeouts, read=timeouts),
941-
retries=Retry(total=retries, redirect=True),
942-
)
943951
with thread_pool, http_pool:
944952
session_pools: tuple[ThreadPoolExecutor, PoolManager] = (thread_pool, http_pool)
945953

umu/umu_runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _install_umu(
118118
# Get the digest for the runtime archive
119119
resp = http_pool.request(
120120
HTTPMethod.GET.value,
121-
f"{host}{endpoint}/SHA256SUMS",
121+
f"https://{host}{endpoint}/SHA256SUMS",
122122
preload_content=False,
123123
)
124124
if resp.status != HTTPStatus.OK:
@@ -137,7 +137,7 @@ def _install_umu(
137137
# Get BUILD_ID.txt. We'll use the value to identify the file when cached.
138138
# This will guarantee we'll be picking up the correct file when resuming
139139
resp = http_pool.request(
140-
HTTPMethod.GET.value, f"{host}{endpoint}/BUILD_ID.txt"
140+
HTTPMethod.GET.value, f"https://{host}{endpoint}/BUILD_ID.txt"
141141
)
142142
if resp.status != HTTPStatus.OK:
143143
err: str = f"{host} returned the status: {resp.status}"
@@ -164,7 +164,7 @@ def _install_umu(
164164

165165
resp = http_pool.request(
166166
HTTPMethod.GET.value,
167-
f"{host}{endpoint}/{archive}",
167+
f"https://{host}{endpoint}/{archive}",
168168
preload_content=False,
169169
headers=headers,
170170
)
@@ -200,7 +200,7 @@ def _install_umu(
200200
}
201201
resp = http_pool.request(
202202
HTTPMethod.GET.value,
203-
f"{host}{endpoint}/{archive}",
203+
f"https://{host}{endpoint}/{archive}",
204204
preload_content=False,
205205
headers=headers,
206206
)
@@ -275,7 +275,7 @@ def setup_umu(
275275
codename, variant, _ = runtime_ver
276276
host: str = "repo.steampowered.com"
277277
endpoint: str = f"/{variant.removesuffix('-arm64')}/images/latest-public-beta"
278-
url: str = f"{host}{endpoint}/VERSION.txt"
278+
url: str = f"https://{host}{endpoint}/VERSION.txt"
279279
log.debug("Sending request to '%s' for 'VERSION.txt'...", url)
280280
resp = http_pool.request(HTTPMethod.GET.value, url)
281281
if resp.status != HTTPStatus.OK:

0 commit comments

Comments
 (0)