Skip to content

Commit c431233

Browse files
marc-hbDaanDeMeyer
authored andcommitted
config.py: add config_default_proxy_exclude()
Automagically defaulting --proxy-url to a proxy value found in the environment is nice. But it backfires seriously when not ignoring the no_proxy= value in the same environment, because it effectively blocks access to internal mirrors with timeouts and/or confusing error messages. Signed-off-by: Marc Herbert <[email protected]>
1 parent 07a0a2b commit c431233

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mkosi/config.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,21 @@ def config_default_proxy_url(namespace: dict[str, Any]) -> Optional[str]:
10871087
return None
10881088

10891089

1090+
def config_default_proxy_exclude(namespace: dict[str, Any]) -> Optional[list[str]]:
1091+
names = ("no_proxy", "NO_PROXY")
1092+
1093+
for env in namespace["environment"]:
1094+
k, _, v = cast(str, env).partition("=")
1095+
if k in names:
1096+
return v.split(",")
1097+
1098+
for k, v in os.environ.items():
1099+
if k in names:
1100+
return v.split(",")
1101+
1102+
return None
1103+
1104+
10901105
def config_default_proxy_peer_certificate(namespace: dict[str, Any]) -> Optional[Path]:
10911106
for p in (Path("/etc/pki/tls/certs/ca-bundle.crt"), Path("/etc/ssl/certs/ca-certificates.crt")):
10921107
if p.exists():
@@ -3916,6 +3931,8 @@ def parse_kernel_module_filter_regexp(p: str) -> str:
39163931
ConfigSetting(
39173932
dest="proxy_exclude",
39183933
section="Build",
3934+
default_factory=config_default_proxy_exclude,
3935+
default_factory_depends=("environment",),
39193936
metavar="HOST",
39203937
parse=config_make_list_parser(delimiter=","),
39213938
help="Don't use the configured proxy for the specified host(s)",

0 commit comments

Comments
 (0)