From 85bb3131873f223f8dea3bdf0e3f5cd4ab5ee189 Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Mon, 28 Mar 2022 21:40:38 +0900 Subject: [PATCH] Update macos.rs --- src/interface/macos.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/interface/macos.rs b/src/interface/macos.rs index b0eaa14..89be874 100644 --- a/src/interface/macos.rs +++ b/src/interface/macos.rs @@ -15,8 +15,16 @@ pub fn get_if_type_map() -> HashMap { let mut map: HashMap = HashMap::new(); let interfaces = network_configuration::get_interfaces(); for interface in &interfaces { - let if_name: String = interface.bsd_name().unwrap().to_string(); - let type_id: String = interface.interface_type_string().unwrap().to_string(); + let if_name: String = if let Some(bsd_name) = interface.bsd_name() { + bsd_name.to_string() + }else{ + continue; + }; + let type_id: String = if let Some(type_string) = interface.interface_type_string() { + type_string.to_string() + }else{ + continue; + }; map.insert(if_name, get_if_type_from_id(type_id)); } return map;