Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/add-updater-no-proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"updater": minor
"updater-js": minor
---

Add no_proxy config to disable system proxy for updater plugin.
21 changes: 19 additions & 2 deletions plugins/updater/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub struct UpdaterBuilder {
headers: HeaderMap,
timeout: Option<Duration>,
proxy: Option<Url>,
no_proxy: bool,
installer_args: Vec<OsString>,
current_exe_args: Vec<OsString>,
on_before_exit: Option<OnBeforeExit>,
Expand Down Expand Up @@ -174,6 +175,7 @@ impl UpdaterBuilder {
headers: Default::default(),
timeout: None,
proxy: None,
no_proxy: false,
on_before_exit: None,
configure_client: None,
}
Expand Down Expand Up @@ -242,6 +244,11 @@ impl UpdaterBuilder {
self
}

pub fn no_proxy(mut self) -> Self {
self.no_proxy = true;
self
}

pub fn pubkey<S: Into<String>>(mut self, pubkey: S) -> Self {
self.config.pubkey = pubkey.into();
self
Expand Down Expand Up @@ -315,6 +322,7 @@ impl UpdaterBuilder {
version_comparator: self.version_comparator,
timeout: self.timeout,
proxy: self.proxy,
no_proxy: self.no_proxy,
endpoints,
installer_args: self.installer_args,
current_exe_args: self.current_exe_args,
Expand Down Expand Up @@ -349,6 +357,7 @@ pub struct Updater {
version_comparator: Option<VersionComparator>,
timeout: Option<Duration>,
proxy: Option<Url>,
no_proxy: bool,
endpoints: Vec<Url>,
arch: &'static str,
// The `{{target}}` variable we replace in the endpoint and serach for in the JSON,
Expand Down Expand Up @@ -428,7 +437,10 @@ impl Updater {
if let Some(timeout) = self.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}");
let proxy = reqwest::Proxy::all(proxy.as_str())?;
request = request.proxy(proxy);
Expand Down Expand Up @@ -519,6 +531,7 @@ impl Updater {
raw_json: raw_json.unwrap(),
timeout: None,
proxy: self.proxy.clone(),
no_proxy: self.no_proxy,
headers: self.headers.clone(),
installer_args: self.installer_args.clone(),
current_exe_args: self.current_exe_args.clone(),
Expand Down Expand Up @@ -592,6 +605,8 @@ pub struct Update {
pub timeout: Option<Duration>,
/// Request proxy
pub proxy: Option<Url>,
/// Disable system proxy
pub no_proxy: bool,
/// Request headers
pub headers: HeaderMap,
/// Extract path
Expand Down Expand Up @@ -628,7 +643,9 @@ impl Update {
if let Some(timeout) = self.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())?;
request = request.proxy(proxy);
}
Expand Down
Loading