@@ -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,12 @@ impl UpdaterBuilder {
242244 self
243245 }
244246
247+ /// Clear all proxies. See [`reqwest::ClientBuilder::no_proxy`](https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html#method.no_proxy).
248+ pub fn no_proxy ( mut self ) -> Self {
249+ self . no_proxy = true ;
250+ self
251+ }
252+
245253 pub fn pubkey < S : Into < String > > ( mut self , pubkey : S ) -> Self {
246254 self . config . pubkey = pubkey. into ( ) ;
247255 self
@@ -323,6 +331,7 @@ impl UpdaterBuilder {
323331 version_comparator : self . version_comparator ,
324332 timeout : self . timeout ,
325333 proxy : self . proxy ,
334+ no_proxy : self . no_proxy ,
326335 endpoints,
327336 installer_args : self . installer_args ,
328337 current_exe_args : self . current_exe_args ,
@@ -357,6 +366,7 @@ pub struct Updater {
357366 version_comparator : Option < VersionComparator > ,
358367 timeout : Option < Duration > ,
359368 proxy : Option < Url > ,
369+ no_proxy : bool ,
360370 endpoints : Vec < Url > ,
361371 arch : & ' static str ,
362372 // The `{{target}}` variable we replace in the endpoint and serach for in the JSON,
@@ -448,7 +458,10 @@ impl Updater {
448458 if let Some ( timeout) = self . timeout {
449459 request = request. timeout ( timeout) ;
450460 }
451- if let Some ( ref proxy) = self . proxy {
461+ if self . no_proxy {
462+ log:: debug!( "disabling proxy" ) ;
463+ request = request. no_proxy ( ) ;
464+ } else if let Some ( ref proxy) = self . proxy {
452465 log:: debug!( "using proxy {proxy}" ) ;
453466 let proxy = reqwest:: Proxy :: all ( proxy. as_str ( ) ) ?;
454467 request = request. proxy ( proxy) ;
@@ -539,6 +552,7 @@ impl Updater {
539552 raw_json : raw_json. unwrap ( ) ,
540553 timeout : None ,
541554 proxy : self . proxy . clone ( ) ,
555+ no_proxy : self . no_proxy ,
542556 headers : self . headers . clone ( ) ,
543557 installer_args : self . installer_args . clone ( ) ,
544558 current_exe_args : self . current_exe_args . clone ( ) ,
@@ -612,6 +626,8 @@ pub struct Update {
612626 pub timeout : Option < Duration > ,
613627 /// Request proxy
614628 pub proxy : Option < Url > ,
629+ /// Disable system proxy
630+ pub no_proxy : bool ,
615631 /// Request headers
616632 pub headers : HeaderMap ,
617633 /// Extract path
@@ -654,7 +670,9 @@ impl Update {
654670 if let Some ( timeout) = self . timeout {
655671 request = request. timeout ( timeout) ;
656672 }
657- if let Some ( ref proxy) = self . proxy {
673+ if self . no_proxy {
674+ request = request. no_proxy ( ) ;
675+ } else if let Some ( ref proxy) = self . proxy {
658676 let proxy = reqwest:: Proxy :: all ( proxy. as_str ( ) ) ?;
659677 request = request. proxy ( proxy) ;
660678 }
0 commit comments