File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -324,7 +324,32 @@ fn dns_resolvers() -> &'static HashSet<IpAddr> {
324324 }
325325 set
326326 }
327- #[ cfg( not( unix) ) ]
327+ #[ cfg( windows) ]
328+ {
329+ let mut set = HashSet :: new ( ) ;
330+ if let Ok ( output) = std:: process:: Command :: new ( "ipconfig" ) . arg ( "/all" ) . output ( ) {
331+ let text = String :: from_utf8_lossy ( & output. stdout ) ;
332+ let mut in_dns_block = false ;
333+ for line in text. lines ( ) {
334+ let trimmed = line. trim ( ) ;
335+ if let Some ( rest) = trimmed. strip_prefix ( "DNS Servers" ) {
336+ in_dns_block = true ;
337+ let value = rest. trim_start_matches ( [ '.' , ' ' , ':' ] ) ;
338+ if let Ok ( ip) = value. parse :: < IpAddr > ( ) {
339+ set. insert ( ip) ;
340+ }
341+ } else if in_dns_block {
342+ if let Ok ( ip) = trimmed. parse :: < IpAddr > ( ) {
343+ set. insert ( ip) ;
344+ } else {
345+ in_dns_block = false ;
346+ }
347+ }
348+ }
349+ }
350+ set
351+ }
352+ #[ cfg( not( any( unix, windows) ) ) ]
328353 {
329354 HashSet :: new ( )
330355 }
You can’t perform that action at this time.
0 commit comments