Ref: Passt die Funktion an, sodass sie das aktive Netzwerkinterface zurückgibt.

This commit is contained in:
2025-08-18 14:43:25 +02:00
parent 0a35f201d2
commit f9eb47fe27
3 changed files with 32 additions and 27 deletions

View File

@@ -3,7 +3,7 @@ use std::thread::sleep;
use std::time::Duration;
use crate::log::LogLevel;
use crate::log::log;
use crate::network::network_card::is_network_card_up;
use crate::network::network_interface::get_active_network_interface;
mod log;
mod network;
@@ -11,20 +11,27 @@ mod network;
fn main() {
log("main", "========== PROGRAMM START ==========", LogLevel::Info);
let mut network_interface = String::new();
let mut count = 0;
loop {
if count >= 10 {
let interface_str = get_active_network_interface().unwrap().trim().to_string();
if !interface_str.is_empty() {
network_interface = interface_str;
break;
} else if count >= 10 {
log("main", "Couldn't find active network card, exiting.", LogLevel::Error);
exit(1);
}
if is_network_card_up() {
break;
}
log("main", "No active network card found, waiting 10 seconds.", LogLevel::Warn);
log("main", "No active network card found, waiting 1 second.", LogLevel::Warn);
count = count+1;
sleep(Duration::from_secs(10));
sleep(Duration::from_secs(1));
}
log("main", &format!("Active network interface found: {}", network_interface), LogLevel::Info);
log("main", "========== PROGRAMM END ==========", LogLevel::Info);
}