mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-26 21:41:48 +02:00
feat(updater): add no_proxy config to disable system proxy (#3073)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Fabian-Lars <github@fabianlars.de>
This commit is contained in:
co-authored by
Claude
Fabian-Lars
parent
82fbb0c790
commit
4375c98bed
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"updater": minor
|
||||||
|
"updater-js": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add no_proxy config to disable system proxy for updater plugin.
|
||||||
@@ -146,6 +146,7 @@ pub struct UpdaterBuilder {
|
|||||||
headers: HeaderMap,
|
headers: HeaderMap,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
proxy: Option<Url>,
|
proxy: Option<Url>,
|
||||||
|
no_proxy: bool,
|
||||||
installer_args: Vec<OsString>,
|
installer_args: Vec<OsString>,
|
||||||
current_exe_args: Vec<OsString>,
|
current_exe_args: Vec<OsString>,
|
||||||
on_before_exit: Option<OnBeforeExit>,
|
on_before_exit: Option<OnBeforeExit>,
|
||||||
@@ -174,6 +175,7 @@ impl UpdaterBuilder {
|
|||||||
headers: Default::default(),
|
headers: Default::default(),
|
||||||
timeout: None,
|
timeout: None,
|
||||||
proxy: None,
|
proxy: None,
|
||||||
|
no_proxy: false,
|
||||||
on_before_exit: None,
|
on_before_exit: None,
|
||||||
configure_client: None,
|
configure_client: None,
|
||||||
}
|
}
|
||||||
@@ -242,6 +244,12 @@ impl UpdaterBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clear all proxies. See [`reqwest::ClientBuilder::no_proxy`](https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html#method.no_proxy).
|
||||||
|
pub fn no_proxy(mut self) -> Self {
|
||||||
|
self.no_proxy = true;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn pubkey<S: Into<String>>(mut self, pubkey: S) -> Self {
|
pub fn pubkey<S: Into<String>>(mut self, pubkey: S) -> Self {
|
||||||
self.config.pubkey = pubkey.into();
|
self.config.pubkey = pubkey.into();
|
||||||
self
|
self
|
||||||
@@ -323,6 +331,7 @@ impl UpdaterBuilder {
|
|||||||
version_comparator: self.version_comparator,
|
version_comparator: self.version_comparator,
|
||||||
timeout: self.timeout,
|
timeout: self.timeout,
|
||||||
proxy: self.proxy,
|
proxy: self.proxy,
|
||||||
|
no_proxy: self.no_proxy,
|
||||||
endpoints,
|
endpoints,
|
||||||
installer_args: self.installer_args,
|
installer_args: self.installer_args,
|
||||||
current_exe_args: self.current_exe_args,
|
current_exe_args: self.current_exe_args,
|
||||||
@@ -357,6 +366,7 @@ pub struct Updater {
|
|||||||
version_comparator: Option<VersionComparator>,
|
version_comparator: Option<VersionComparator>,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
proxy: Option<Url>,
|
proxy: Option<Url>,
|
||||||
|
no_proxy: bool,
|
||||||
endpoints: Vec<Url>,
|
endpoints: Vec<Url>,
|
||||||
arch: &'static str,
|
arch: &'static str,
|
||||||
// The `{{target}}` variable we replace in the endpoint and serach for in the JSON,
|
// The `{{target}}` variable we replace in the endpoint and serach for in the JSON,
|
||||||
@@ -448,7 +458,10 @@ impl Updater {
|
|||||||
if let Some(timeout) = self.timeout {
|
if let Some(timeout) = self.timeout {
|
||||||
request = request.timeout(timeout);
|
request = request.timeout(timeout);
|
||||||
}
|
}
|
||||||
if let Some(ref proxy) = self.proxy {
|
if self.no_proxy {
|
||||||
|
log::debug!("disabling proxy");
|
||||||
|
request = request.no_proxy();
|
||||||
|
} else if let Some(ref proxy) = self.proxy {
|
||||||
log::debug!("using proxy {proxy}");
|
log::debug!("using proxy {proxy}");
|
||||||
let proxy = reqwest::Proxy::all(proxy.as_str())?;
|
let proxy = reqwest::Proxy::all(proxy.as_str())?;
|
||||||
request = request.proxy(proxy);
|
request = request.proxy(proxy);
|
||||||
@@ -539,6 +552,7 @@ impl Updater {
|
|||||||
raw_json: raw_json.unwrap(),
|
raw_json: raw_json.unwrap(),
|
||||||
timeout: None,
|
timeout: None,
|
||||||
proxy: self.proxy.clone(),
|
proxy: self.proxy.clone(),
|
||||||
|
no_proxy: self.no_proxy,
|
||||||
headers: self.headers.clone(),
|
headers: self.headers.clone(),
|
||||||
installer_args: self.installer_args.clone(),
|
installer_args: self.installer_args.clone(),
|
||||||
current_exe_args: self.current_exe_args.clone(),
|
current_exe_args: self.current_exe_args.clone(),
|
||||||
@@ -612,6 +626,8 @@ pub struct Update {
|
|||||||
pub timeout: Option<Duration>,
|
pub timeout: Option<Duration>,
|
||||||
/// Request proxy
|
/// Request proxy
|
||||||
pub proxy: Option<Url>,
|
pub proxy: Option<Url>,
|
||||||
|
/// Disable system proxy
|
||||||
|
pub no_proxy: bool,
|
||||||
/// Request headers
|
/// Request headers
|
||||||
pub headers: HeaderMap,
|
pub headers: HeaderMap,
|
||||||
/// Extract path
|
/// Extract path
|
||||||
@@ -654,7 +670,9 @@ impl Update {
|
|||||||
if let Some(timeout) = self.timeout {
|
if let Some(timeout) = self.timeout {
|
||||||
request = request.timeout(timeout);
|
request = request.timeout(timeout);
|
||||||
}
|
}
|
||||||
if let Some(ref proxy) = self.proxy {
|
if self.no_proxy {
|
||||||
|
request = request.no_proxy();
|
||||||
|
} else if let Some(ref proxy) = self.proxy {
|
||||||
let proxy = reqwest::Proxy::all(proxy.as_str())?;
|
let proxy = reqwest::Proxy::all(proxy.as_str())?;
|
||||||
request = request.proxy(proxy);
|
request = request.proxy(proxy);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user