|
|
@@ -52,7 +52,32 @@ fn configure_display_backend() -> Option<String> {
|
|
|
}
|
|
|
|
|
|
fn main() {
|
|
|
- unsafe { std::env::set_var("NO_PROXY", "127.0.0.1,localhost,::1") };
|
|
|
+ // Ensure loopback connections are never sent through proxy settings.
|
|
|
+ // Some VPNs/proxies set HTTP_PROXY/HTTPS_PROXY/ALL_PROXY without excluding localhost.
|
|
|
+ const LOOPBACK: [&str; 3] = ["127.0.0.1", "localhost", "::1"];
|
|
|
+
|
|
|
+ let upsert = |key: &str| {
|
|
|
+ let mut items = std::env::var(key)
|
|
|
+ .unwrap_or_default()
|
|
|
+ .split(',')
|
|
|
+ .map(|v| v.trim())
|
|
|
+ .filter(|v| !v.is_empty())
|
|
|
+ .map(|v| v.to_string())
|
|
|
+ .collect::<Vec<_>>();
|
|
|
+
|
|
|
+ for host in LOOPBACK {
|
|
|
+ if items.iter().any(|v| v.eq_ignore_ascii_case(host)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ items.push(host.to_string());
|
|
|
+ }
|
|
|
+
|
|
|
+ // Safety: called during startup before any threads are spawned.
|
|
|
+ unsafe { std::env::set_var(key, items.join(",")) };
|
|
|
+ };
|
|
|
+
|
|
|
+ upsert("NO_PROXY");
|
|
|
+ upsert("no_proxy");
|
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
{
|