File tree 2 files changed +42
-1
lines changed
2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ pnet_datalink = "0.35.0"
48
48
[target .'cfg(target_os = "macos")' .dependencies ]
49
49
system-configuration = { version = " 0.6.1" , optional = true }
50
50
51
+ [target .'cfg(windows)' .dependencies ]
52
+ windows-registry = { version = " 0.4" , optional = true }
53
+
51
54
[features ]
52
55
default = []
53
56
@@ -68,7 +71,7 @@ full = [
68
71
client = [" hyper/client" , " dep:tracing" , " dep:futures-channel" , " dep:tower-service" ]
69
72
client-legacy = [" client" , " dep:socket2" , " tokio/sync" , " dep:libc" ]
70
73
client-proxy = [" client" , " dep:base64" , " dep:ipnet" , " dep:percent-encoding" ]
71
- client-proxy-system = [" dep:system-configuration" ]
74
+ client-proxy-system = [" dep:system-configuration" , " dep:windows-registry " ]
72
75
73
76
server = [" hyper/server" ]
74
77
server-auto = [" server" , " http1" , " http2" ]
Original file line number Diff line number Diff line change @@ -242,6 +242,9 @@ impl Builder {
242
242
#[ cfg( all( feature = "client-proxy-system" , target_os = "macos" ) ) ]
243
243
mac:: with_system ( & mut builder) ;
244
244
245
+ #[ cfg( all( feature = "client-proxy-system" , windows) ) ]
246
+ win:: with_system ( & mut builder) ;
247
+
245
248
builder
246
249
}
247
250
@@ -638,6 +641,41 @@ mod mac {
638
641
}
639
642
}
640
643
644
+ #[ cfg( feature = "client-proxy-system" ) ]
645
+ #[ cfg( windows) ]
646
+ mod win {
647
+ pub ( super ) fn with_system ( builder : & mut super :: Builder ) {
648
+ let settings = if let Ok ( settings) = windows_registry:: CURRENT_USER
649
+ . open ( "Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Internet Settings" )
650
+ {
651
+ settings
652
+ } else {
653
+ return ;
654
+ } ;
655
+
656
+ if settings. get_u32 ( "ProxyEnable" ) . unwrap_or ( 0 ) == 0 {
657
+ return ;
658
+ }
659
+
660
+ if builder. http . is_empty ( ) {
661
+ if let Ok ( val) = settings. get_string ( "ProxyServer" ) {
662
+ builder. http = val;
663
+ }
664
+ }
665
+
666
+ if builder. no . is_empty ( ) {
667
+ if let Ok ( val) = settings. get_string ( "ProxyOverride" ) {
668
+ builder. no = val
669
+ . split ( ';' )
670
+ . map ( |s| s. trim ( ) )
671
+ . collect :: < Vec < & str > > ( )
672
+ . join ( "," )
673
+ . replace ( "*." , "" ) ;
674
+ }
675
+ }
676
+ }
677
+ }
678
+
641
679
#[ cfg( test) ]
642
680
mod tests {
643
681
use super :: * ;
You can’t perform that action at this time.
0 commit comments