Skip to content

Commit 4e05d6e

Browse files
miaoshengkunclaude
andcommitted
feat(updater): add no_proxy config to disable system proxy
Add a `no_proxy` configuration option to the updater plugin that calls reqwest's `no_proxy()` method. This allows users to prevent update requests from being affected by system proxy settings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6aead24 commit 4e05d6e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.changes/add-plugin-no-proxy.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"updater": minor
3+
"updater-js": minor
4+
---
5+
6+
Add no_proxy config to disable system proxy for updater plugin.

plugins/updater/src/updater.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ pub struct UpdaterBuilder {
146146
headers: HeaderMap,
147147
timeout: Option<Duration>,
148148
proxy: Option<Url>,
149+
no_proxy: bool,
149150
installer_args: Vec<OsString>,
150151
current_exe_args: Vec<OsString>,
151152
on_before_exit: Option<OnBeforeExit>,
@@ -174,6 +175,7 @@ impl UpdaterBuilder {
174175
headers: Default::default(),
175176
timeout: None,
176177
proxy: None,
178+
no_proxy: false,
177179
on_before_exit: None,
178180
configure_client: None,
179181
}
@@ -242,6 +244,11 @@ impl UpdaterBuilder {
242244
self
243245
}
244246

247+
pub fn no_proxy(mut self) -> Self {
248+
self.no_proxy = true;
249+
self
250+
}
251+
245252
pub fn pubkey<S: Into<String>>(mut self, pubkey: S) -> Self {
246253
self.config.pubkey = pubkey.into();
247254
self
@@ -315,6 +322,7 @@ impl UpdaterBuilder {
315322
version_comparator: self.version_comparator,
316323
timeout: self.timeout,
317324
proxy: self.proxy,
325+
no_proxy: self.no_proxy,
318326
endpoints,
319327
installer_args: self.installer_args,
320328
current_exe_args: self.current_exe_args,
@@ -349,6 +357,7 @@ pub struct Updater {
349357
version_comparator: Option<VersionComparator>,
350358
timeout: Option<Duration>,
351359
proxy: Option<Url>,
360+
no_proxy: bool,
352361
endpoints: Vec<Url>,
353362
arch: &'static str,
354363
// The `{{target}}` variable we replace in the endpoint and serach for in the JSON,
@@ -428,7 +437,10 @@ impl Updater {
428437
if let Some(timeout) = self.timeout {
429438
request = request.timeout(timeout);
430439
}
431-
if let Some(ref proxy) = self.proxy {
440+
if self.no_proxy {
441+
log::debug!("disabling proxy");
442+
request = request.no_proxy();
443+
} else if let Some(ref proxy) = self.proxy {
432444
log::debug!("using proxy {proxy}");
433445
let proxy = reqwest::Proxy::all(proxy.as_str())?;
434446
request = request.proxy(proxy);
@@ -519,6 +531,7 @@ impl Updater {
519531
raw_json: raw_json.unwrap(),
520532
timeout: None,
521533
proxy: self.proxy.clone(),
534+
no_proxy: self.no_proxy,
522535
headers: self.headers.clone(),
523536
installer_args: self.installer_args.clone(),
524537
current_exe_args: self.current_exe_args.clone(),
@@ -592,6 +605,8 @@ pub struct Update {
592605
pub timeout: Option<Duration>,
593606
/// Request proxy
594607
pub proxy: Option<Url>,
608+
/// Disable system proxy
609+
pub no_proxy: bool,
595610
/// Request headers
596611
pub headers: HeaderMap,
597612
/// Extract path
@@ -628,7 +643,9 @@ impl Update {
628643
if let Some(timeout) = self.timeout {
629644
request = request.timeout(timeout);
630645
}
631-
if let Some(ref proxy) = self.proxy {
646+
if self.no_proxy {
647+
request = request.no_proxy();
648+
} else if let Some(ref proxy) = self.proxy {
632649
let proxy = reqwest::Proxy::all(proxy.as_str())?;
633650
request = request.proxy(proxy);
634651
}

0 commit comments

Comments
 (0)