File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,39 @@ pub fn interfaces() -> Vec<Interface> {
9797
9898#[ cfg( all( target_vendor = "apple" , not( target_os = "macos" ) ) ) ]
9999pub fn interfaces ( ) -> Vec < Interface > {
100- unix_interfaces ( )
100+ let mut interfaces: Vec < Interface > = unix_interfaces ( ) ;
101+
102+ #[ cfg( feature = "gateway" ) ]
103+ let local_ip_opt: Option < IpAddr > = super :: get_local_ipaddr ( ) ;
104+
105+ #[ cfg( feature = "gateway" ) ]
106+ let gateway_map = gateway:: macos:: get_gateway_map ( ) ;
107+
108+ for iface in & mut interfaces {
109+ #[ cfg( feature = "gateway" ) ]
110+ {
111+ if let Some ( gateway) = gateway_map. get ( & iface. index ) {
112+ iface. gateway = Some ( gateway. clone ( ) ) ;
113+ }
114+
115+ if let Some ( local_ip) = local_ip_opt {
116+ iface. ipv4 . iter ( ) . for_each ( |ipv4| {
117+ if IpAddr :: V4 ( ipv4. addr ( ) ) == local_ip {
118+ iface. dns_servers = get_system_dns_conf ( ) ;
119+ iface. default = true ;
120+ }
121+ } ) ;
122+ iface. ipv6 . iter ( ) . for_each ( |ipv6| {
123+ if IpAddr :: V6 ( ipv6. addr ( ) ) == local_ip {
124+ iface. dns_servers = get_system_dns_conf ( ) ;
125+ iface. default = true ;
126+ }
127+ } ) ;
128+ }
129+ }
130+ }
131+
132+ interfaces
101133}
102134
103135#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
You can’t perform that action at this time.
0 commit comments