Skip to content

Commit

Permalink
fix: proxy under AutoConfigUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosette committed Nov 20, 2024
1 parent 8e6cb34 commit f4af018
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ fn main() {
#[cfg(windows)]
{
println!("cargo:rerun-if-changed=tsukimi-manifest.rc");
embed_resource::compile("./tsukimi_manifest.rc", embed_resource::NONE);
embed_resource::compile("./tsukimi_manifest.rc", embed_resource::NONE)
.manifest_optional()
.unwrap();
}
}
12 changes: 11 additions & 1 deletion src/client/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ReqClient {

client_builder.build().expect("failed to initialize client")
};

tower::ServiceBuilder::new()
.concurrency_limit(SETTINGS.threads() as usize)
.service(client)
Expand All @@ -68,6 +68,16 @@ pub fn get_proxy_settings() -> Option<String> {
{
let proxy = PCWSTR(proxy_config.lpszProxy.0).to_string().unwrap();
return Some(proxy);
} else if WinHttpGetIEProxyConfigForCurrentUser(&mut proxy_config).is_ok()
&& !proxy_config.lpszAutoConfigUrl.is_null()
{
let proxy_url = PCWSTR(proxy_config.lpszAutoConfigUrl.0)
.to_string()
.unwrap();
let proxy = proxy_url.split('/').collect::<Vec<_>>()[..3]
.join("/")
.to_string();
return Some(proxy);
}
}
None
Expand Down

0 comments on commit f4af018

Please sign in to comment.