fix(windows): avoid pnet interface enumeration panic (#2031)

This commit is contained in:
KKRainbow
2026-03-29 23:16:44 +08:00
committed by GitHub
parent a1bec48dc9
commit 8c19a2293c
2 changed files with 91 additions and 1 deletions
@@ -221,7 +221,8 @@ fn get_or_create_worker(interface_name: &str) -> io::Result<Arc<InterfaceWorker>
// But creation is rare.
// Let's find interface first.
let interfaces = datalink::interfaces();
let interfaces = std::panic::catch_unwind(datalink::interfaces)
.map_err(|_| io::Error::other("failed to enumerate network interfaces: pnet panicked"))?;
let interface = interfaces
.into_iter()
.find(|iface| iface.name == interface_name)