Skip to content

Commit

Permalink
feat(deps): adopt to changes of if_addrs
Browse files Browse the repository at this point in the history
  • Loading branch information
hrzlgnm authored and renovate[bot] committed Apr 2, 2024
1 parent 375e988 commit 4831f8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ edition = "2021"
tauri-build = { version = "1", features = [] }

[dependencies]
tauri = { version = "1", features = [ "window-all", "process-relaunch", "process-exit",
tauri = { version = "1", features = [
"window-all",
"process-relaunch",
"process-exit",
"dialog-ask",
"shell-open",
"updater",
Expand All @@ -23,7 +26,6 @@ tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", br
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
log = "^0.4.21"
if-addrs = { version = "0.12.0", features = ["link-local"] }
network-interface = "1.1.2"

[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
Expand Down
14 changes: 0 additions & 14 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use if_addrs::{get_if_addrs, IfAddr, Interface};
use log::LevelFilter;
use mdns_sd::{ServiceDaemon, ServiceEvent};
use network_interface::{NetworkInterface, NetworkInterfaceConfig};
use serde::Serialize;
use std::{
collections::HashMap,
Expand Down Expand Up @@ -212,22 +211,9 @@ fn enum_service_types(state: State<MdnsState>) -> Vec<String> {
fn get_all_interfaces_except_loopback() -> Vec<Interface> {
let interface_addresses = get_if_addrs().unwrap();

// if_addrs unfortunately shows the GUID of the interface as name,
// so we work around here by using network_interface in addition to get user friendly names
let network_interfaces = NetworkInterface::show().unwrap();
let mut index_to_name = HashMap::new();
for network_interface in network_interfaces.iter() {
index_to_name.insert(network_interface.index, network_interface.name.clone());
}

interface_addresses
.into_iter()
.filter(|itf| !itf.is_loopback())
.map(|itf| Interface {
name: index_to_name.get(&itf.index.unwrap()).unwrap().clone(),
addr: itf.addr,
index: itf.index,
})
.collect()
}

Expand Down

0 comments on commit 4831f8e

Please sign in to comment.