Ref: Überarbeitet get_ip_from_mac zur verbesserten Verarbeitung von mac und Logging.
This commit is contained in:
@@ -114,8 +114,11 @@ pub fn get_ip_from_mac(mac: &str, network: &str) -> Option<String> {
|
||||
log("network_utils", &*stdout, LogLevel::Debug);
|
||||
|
||||
for line in stdout.lines() {
|
||||
if line.contains(mac) {
|
||||
if let Some(ip_line) = line.split('\n').find(|l| l.contains("Nmap scan report for")) {
|
||||
if line.contains("Nmap scan report for") {
|
||||
let ip_line = line;
|
||||
log("network_utils", &*ip_line, LogLevel::Debug);
|
||||
if let Some(next_line) = stdout.lines().find(|l| l.to_lowercase().contains(mac)) {
|
||||
log("network_utils", &*next_line, LogLevel::Debug);
|
||||
if let Some(ip) = ip_line.split_whitespace().last() {
|
||||
return Some(ip.to_string());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user