network-interface icon indicating copy to clipboard operation
network-interface copied to clipboard

atfer Unplug the network cable, I got the same response.

Open zrz4066 opened this issue 2 years ago • 5 comments

network-interface can show the network interce .Actually atfer Unplug the network cable, I got the same response.

itf:NetworkInterface { name: "以太网", addr: [V6(V6IfAddr { ip: fe80::322c:fcc3:745d:86d8, broadcast: None, netmask: None })], mac_addr: Some("E8:6A:64:80:BF:F5"), index: 17 } itf:NetworkInterface { name: "以太网", addr: [V4(V4IfAddr { ip: 192.168.3.201, broadcast: Some(192.168.3.255), netmask: Some(255.255.255.0) })], mac_addr: Some("E8:6A:64:80:BF:F5"), index: 17 } itf:NetworkInterface { name: "以太网", addr: [V4(V4IfAddr { ip: 192.168.10.201, broadcast: Some(192.168.3.255), netmask: Some(255.255.255.0) })], mac_addr: Some("E8:6A:64:80:BF:F5"), index: 17 } itf:NetworkInterface { name: "以太网", addr: [V4(V4IfAddr { ip: 192.168.100.201, broadcast: Some(192.168.3.255), netmask: Some(255.255.255.0) })], mac_addr: Some("E8:6A:64:80:BF:F5"), index: 17 } itf:NetworkInterface { name: "以太网 2", addr: [V6(V6IfAddr { ip: fe80::1918:6d19:1c08:3d8f, broadcast: None, netmask: None })], mac_addr: Some("0A:00:27:00:00:05"), index: 5 } itf:NetworkInterface { name: "以太网 2", addr: [V4(V4IfAddr { ip: 192.168.56.1, broadcast: Some(192.168.56.255), netmask: Some(255.255.255.0) })], mac_addr: Some("0A:00:27:00:00:05"), index: 5 } itf:NetworkInterface { name: "本地连接* 1", addr: [V6(V6IfAddr { ip: fe80::ef61:935a:9cc6:223d, broadcast: None, netmask: None })], mac_addr: Some("FA:A2:D6:DE:6F:37"), index: 8 } itf:NetworkInterface { name: "本地连接* 1", addr: [V4(V4IfAddr { ip: 169.254.30.206, broadcast: None, netmask: Some(255.255.0.0) })], mac_addr: Some("FA:A2:D6:DE:6F:37"), index: 8 } itf:NetworkInterface { name: "本地连接* 10", addr: [V6(V6IfAddr { ip: fe80::3883:5d0b:7d77:3e81, broadcast: None, netmask: None })], mac_addr: Some("FE:A2:D6:DF:6F:37"), index: 12 } itf:NetworkInterface { name: "本地连接* 10", addr: [V4(V4IfAddr { ip: 169.254.192.168, broadcast: None, netmask: Some(255.255.0.0) })], mac_addr: Some("FE:A2:D6:DF:6F:37"), index: 12 } itf:NetworkInterface { name: "WLAN", addr: [V6(V6IfAddr { ip: fe80::b329:92f2:11e4:9258, broadcast: None, netmask: None })], mac_addr: Some("F8:A2:D6:B9:9A:55"), index: 3 } itf:NetworkInterface { name: "WLAN", addr: [V4(V4IfAddr { ip: 192.168.2.4, broadcast: Some(192.168.2.255), netmask: Some(255.255.255.0) })], mac_addr: Some("F8:A2:D6:B9:9A:55"), index: 3 } itf:NetworkInterface { name: "蓝牙网络连接", addr: [V6(V6IfAddr { ip: fe80::2dc5:cd8b:ccb:4b8f, broadcast: None, netmask: None })], mac_addr: Some("F8:A2:D6:B9:9A:56"), index: 18 } itf:NetworkInterface { name: "蓝牙网络连接", addr: [V4(V4IfAddr { ip: 169.254.76.35, broadcast: None, netmask: Some(255.255.0.0) })], mac_addr: Some("F8:A2:D6:B9:9A:56"), index: 18 } itf:NetworkInterface { name: "Loopback Pseudo-Interface 1", addr: [V6(V6IfAddr { ip: ::1, broadcast: None, netmask: None })], mac_addr: None, index: 1 } itf:NetworkInterface { name: "Loopback Pseudo-Interface 1", addr: [V4(V4IfAddr { ip: 127.0.0.1, broadcast: Some(127.255.255.255), netmask: Some(255.0.0.0) })], mac_addr: None, index: 1 }

zrz4066 avatar Sep 20 '23 07:09 zrz4066

Hi @zrz4066, thanks for openning this issue!

Can you help me with more context? Could you please provide information such as OS, Version and how are you using the crate?

Its important to mention that theres no persisntance of data nor cache in the call to show.

Every invocation on show is idempotent, and will perform syscalls to pull data from the OS and parse it into crate structs.

LeoBorai avatar Oct 20 '23 10:10 LeoBorai

That also happens to me in Windows 11. Maybe if you add a "is_up()" method (like default-net does) that will return true or false if the interface is plugged or not, will solve the problem.

Llorx avatar Nov 03 '23 23:11 Llorx

Hi @Llorx!

Thanks for sharing insights, PRs are welcome in case you want to provide a suggestion on a fix!

I will mark this a windows and help wanted as I lack of access to Windows System ATM.

LeoBorai avatar Nov 06 '23 21:11 LeoBorai

I would be glad, but the project where I use this crate is my first rust one, so I have a looooong way until I know how to do things properly. The borrow checker is a pain, being a noob xD

Maybe in a couple of weeks I can do so.

Llorx avatar Nov 06 '23 22:11 Llorx

Hi @Llorx! No worries we are here to help! Feel free to mention me in this thread if you need any assistance.

LeoBorai avatar May 17 '24 21:05 LeoBorai