11 Commits
Author SHA1 Message Date
DragonSlayer_14 10bcd17ea6 Merge pull request 'chore(deps): update rust crate clap to v4.6.7' (#9) from renovate/cargo-dependencies into dev
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
TruffleHog Secret Scan / TruffleHog (push) Successful in 16s
Security Scans / Trivy & OSV-Scanner (push) Successful in 33s
Code Quality (Auto-Format & Clippy-Fix) / Formatierung & Clippy automatisch beheben (push) Successful in 44s
Reviewed-on: #9
Reviewed-by: dragonslayer14@murena.io <4+dragonslayer_14@noreply.localhost>
2026-09-20 10:07:59 +00:00
DragonSlayer_14 462fe20bed Merge pull request 'chore(deps): update gitea actions' (#10) from renovate/gitea-actions into dev
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
TruffleHog Secret Scan / TruffleHog (push) Successful in 27s
Security Scans / Trivy & OSV-Scanner (push) Successful in 1m14s
Code Quality (Auto-Format & Clippy-Fix) / Formatierung & Clippy automatisch beheben (push) Successful in 1m24s
Reviewed-on: #10
2026-09-20 09:02:04 +00:00
Renovate-Bot 92cb9d83d9 chore(deps): update gitea actions
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
Unit-Tests / Unit-Tests (pull_request) Skipped
TruffleHog Secret Scan / TruffleHog (push) Successful in 17s
TruffleHog Secret Scan / TruffleHog (pull_request) Successful in 16s
Security Scans / Trivy & OSV-Scanner (pull_request) Successful in 32s
2026-09-20 03:01:12 +00:00
Renovate-Bot 62d65149ab chore(deps): update rust crate clap to v4.6.7
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
TruffleHog Secret Scan / TruffleHog (push) Successful in 22s
TruffleHog Secret Scan / TruffleHog (pull_request) Successful in 20s
Unit-Tests / Unit-Tests (pull_request) Skipped
Security Scans / Trivy & OSV-Scanner (pull_request) Successful in 47s
2026-09-19 19:03:49 +00:00
Gitea-Bot 2b9e761d9e Style: Automatische Formatierung & Clippy-Fixes
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
TruffleHog Secret Scan / TruffleHog (push) Successful in 16s
Security Scans / Trivy & OSV-Scanner (push) Successful in 34s
Code Quality (Auto-Format & Clippy-Fix) / Formatierung & Clippy automatisch beheben (push) Successful in 35s
2026-09-14 22:51:40 +00:00
DragonSlayer_14 232e39f518 Merge remote-tracking branch 'origin/dev' into dev
TruffleHog Secret Scan / TruffleHog (push) Successful in 17s
Security Scans / Trivy & OSV-Scanner (push) Successful in 33s
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
Code Quality (Auto-Format & Clippy-Fix) / Formatierung & Clippy automatisch beheben (push) Successful in 36s
2026-09-15 00:50:56 +02:00
DragonSlayer_14 8ce23b6374 Merge branch 'main' into dev 2026-09-15 00:50:51 +02:00
DragonSlayer_14andClaude Sonnet 5 b094b11429 Chore: Terminal-Ausgaben ins Englische übersetzt
Log-Meldungen, Fehlertexte, CLI---help-Ausgabe und der interaktive
Vertrauens-Prompt erscheinen jetzt auf Englisch. Rustdoc-Kommentare
bleiben unverändert Deutsch; in cli.rs wird dafür ein separates
clap-help-Attribut (Englisch) neben dem deutschen Doc-Kommentar
verwendet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011asoZDNEvn4RZBxxPQLCG9
2026-09-15 00:33:45 +02:00
DragonSlayer_14 fd441a95a6 Merge pull request 'chore(deps): update gitea actions' (#8) from renovate/gitea-actions into dev
Security Scans / Trivy & OSV-Scanner (push) Successful in 58s
TruffleHog Secret Scan / TruffleHog (push) Successful in 31s
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
Code Quality (Auto-Format & Clippy-Fix) / Formatierung & Clippy automatisch beheben (push) Successful in 1m33s
Reviewed-on: #8
Reviewed-by: dragonslayer14@murena.io <4+dragonslayer_14@noreply.localhost>
2026-09-14 10:52:11 +00:00
Renovate-Bot 2c8c9c885f chore(deps): update gitea actions
TruffleHog Secret Scan / TruffleHog (push) Successful in 17s
TruffleHog Secret Scan / TruffleHog (pull_request) Successful in 15s
Security Scans / Trivy & OSV-Scanner (pull_request) Successful in 28s
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
Unit-Tests / Unit-Tests (pull_request) Skipped
2026-09-14 10:01:00 +00:00
DragonSlayer_14 8073ee6a49 Merge pull request 'Merge testing in main: Release 1.0.0' (#6) from testing into main
Testing Build, Publish & Preview Release / Build, Publish Packages (Testing) & Create Preview Release (push) Skipped
Main Release & Publish / Erkenne relevante Code-Änderungen (push) Successful in 5s
Security Scans / Trivy & OSV-Scanner (push) Successful in 22s
Main Release & Publish / Build, Publish Packages (Stable) & Create Release (push) Successful in 12m27s
TruffleHog Secret Scan / TruffleHog (push) Successful in 10s
Reviewed-on: #6
Reviewed-by: dragonslayer14@murena.io <4+dragonslayer_14@noreply.localhost>
2026-09-13 20:46:58 +00:00
12 changed files with 96 additions and 76 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ jobs:
renovate: renovate:
name: Dependency-Updates prüfen & Pull Requests erstellen name: Dependency-Updates prüfen & Pull Requests erstellen
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ghcr.io/renovatebot/renovate:44.83.0 container: ghcr.io/renovatebot/renovate:44.103.6
steps: steps:
- name: Renovate ausführen - name: Renovate ausführen
run: renovate run: renovate
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
TRIVY_VERSION: "0.74.0" TRIVY_VERSION: "0.74.0"
OSV_SCANNER_VERSION: "2.5.1" OSV_SCANNER_VERSION: "2.6.0"
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v7 uses: actions/checkout@v7
+1 -1
View File
@@ -12,7 +12,7 @@ jobs:
name: TruffleHog name: TruffleHog
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
TRUFFLEHOG_VERSION: "3.97.4" TRUFFLEHOG_VERSION: "3.97.5"
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v7 uses: actions/checkout@v7
Generated
+10 -10
View File
@@ -375,9 +375,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.6.6" version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca" checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@@ -385,9 +385,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.6.6" version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889" checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@@ -397,9 +397,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.6.4" version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061" checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
@@ -586,7 +586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [ dependencies = [
"libc 0.2.189", "libc 0.2.189",
"windows-sys 0.61.2", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@@ -1280,7 +1280,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@@ -1717,7 +1717,7 @@ dependencies = [
"errno", "errno",
"libc 0.2.189", "libc 0.2.189",
"linux-raw-sys 0.12.1", "linux-raw-sys 0.12.1",
"windows-sys 0.61.2", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@@ -1996,7 +1996,7 @@ dependencies = [
"getrandom 0.4.3", "getrandom 0.4.3",
"once_cell", "once_cell",
"rustix 1.1.4", "rustix 1.1.4",
"windows-sys 0.61.2", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
+12 -22
View File
@@ -68,7 +68,7 @@ impl Cache {
Err(e) => { Err(e) => {
crate::log::warn( crate::log::warn(
"cache", "cache",
&format!("Cache-Lesefehler (trusted_networks): {e}"), &format!("Cache read error (trusted_networks): {e}"),
); );
false false
} }
@@ -90,7 +90,7 @@ impl Cache {
{ {
crate::log::warn( crate::log::warn(
"cache", "cache",
&format!("Cache-Schreibfehler (trusted_networks, ignoriert): {e}"), &format!("Cache write error (trusted_networks, ignored): {e}"),
); );
} }
} }
@@ -108,7 +108,7 @@ impl Cache {
{ {
Ok(rows) => rows, Ok(rows) => rows,
Err(e) => { Err(e) => {
crate::log::warn("cache", &format!("Cache-Lesefehler: {e}")); crate::log::warn("cache", &format!("Cache read error: {e}"));
return None; return None;
} }
}; };
@@ -126,7 +126,7 @@ impl Cache {
} }
Ok(None) => None, Ok(None) => None,
Err(e) => { Err(e) => {
crate::log::warn("cache", &format!("Cache-Lesefehler: {e}")); crate::log::warn("cache", &format!("Cache read error: {e}"));
None None
} }
} }
@@ -145,7 +145,7 @@ impl Cache {
) )
.await .await
{ {
crate::log::warn("cache", &format!("Cache-Schreibfehler (ignoriert): {e}")); crate::log::warn("cache", &format!("Cache write error (ignored): {e}"));
} }
} }
} }
@@ -157,19 +157,15 @@ pub fn is_expired(updated_at: i64, now: i64, ttl_seconds: u64) -> bool {
fn ensure_cache_dir(dir: &Path) -> Result<(), String> { fn ensure_cache_dir(dir: &Path) -> Result<(), String> {
if !dir.exists() { if !dir.exists() {
std::fs::create_dir_all(dir).map_err(|e| { std::fs::create_dir_all(dir)
format!( .map_err(|e| format!("could not create directory '{}': {e}", dir.display()))?;
"Verzeichnis '{}' konnte nicht angelegt werden: {e}",
dir.display()
)
})?;
// create_dir_all() unterliegt dem Prozess-Umask; explizites chmod ist nötig, um // create_dir_all() unterliegt dem Prozess-Umask; explizites chmod ist nötig, um
// wirklich 0777 zu erreichen (Verzeichnis-Rechte steuern nicht die Umask neuer Dateien). // wirklich 0777 zu erreichen (Verzeichnis-Rechte steuern nicht die Umask neuer Dateien).
// Wird nur beim Neuanlegen ausgeführt; bei existierenden Verzeichnissen würde ein // Wird nur beim Neuanlegen ausgeführt; bei existierenden Verzeichnissen würde ein
// unprivilegierter Aufruf auf root-eigenen Pfaden mit EPERM fehlschlagen. // unprivilegierter Aufruf auf root-eigenen Pfaden mit EPERM fehlschlagen.
#[cfg(unix)] #[cfg(unix)]
std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o777)) std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o777))
.map_err(|e| format!("Verzeichnis-Rechte konnten nicht gesetzt werden: {e}"))?; .map_err(|e| format!("could not set directory permissions: {e}"))?;
} }
Ok(()) Ok(())
} }
@@ -191,7 +187,7 @@ pub async fn try_open_cache(db_path: &Path) -> Option<Cache> {
if let Some(dir) = db_path.parent() if let Some(dir) = db_path.parent()
&& let Err(reason) = ensure_cache_dir(dir) && let Err(reason) = ensure_cache_dir(dir)
{ {
crate::log::warn("cache", &format!("Cache deaktiviert: {reason}")); crate::log::warn("cache", &format!("Cache disabled: {reason}"));
return None; return None;
} }
@@ -201,10 +197,7 @@ pub async fn try_open_cache(db_path: &Path) -> Option<Cache> {
{ {
Ok(db) => db, Ok(db) => db,
Err(e) => { Err(e) => {
crate::log::warn( crate::log::warn("cache", &format!("Could not open cache database: {e}"));
"cache",
&format!("Cache-Datenbank konnte nicht geöffnet werden: {e}"),
);
return None; return None;
} }
}; };
@@ -212,17 +205,14 @@ pub async fn try_open_cache(db_path: &Path) -> Option<Cache> {
let conn = match db.connect() { let conn = match db.connect() {
Ok(c) => c, Ok(c) => c,
Err(e) => { Err(e) => {
crate::log::warn("cache", &format!("Cache-Verbindung fehlgeschlagen: {e}")); crate::log::warn("cache", &format!("Cache connection failed: {e}"));
return None; return None;
} }
}; };
let cache = Cache { conn }; let cache = Cache { conn };
if let Err(e) = cache.init_schema().await { if let Err(e) = cache.init_schema().await {
crate::log::warn( crate::log::warn("cache", &format!("Could not initialize cache schema: {e}"));
"cache",
&format!("Cache-Schema konnte nicht initialisiert werden: {e}"),
);
return None; return None;
} }
+47 -10
View File
@@ -11,50 +11,87 @@ use crate::mac::MacAddress;
name = "mac2ip", name = "mac2ip",
author, author,
version, version,
about = "Findet zuverlässig die aktuelle IP-Adresse zu einer MAC-Adresse im lokalen Netzwerk", about = "Reliably finds the current IP address for a MAC address on the local network",
long_about = None long_about = None
)] )]
pub struct Cli { pub struct Cli {
/// MAC-Adresse, deren aktuelle IP-Adresse ermittelt werden soll (z. B. aa:bb:cc:dd:ee:ff) /// MAC-Adresse, deren aktuelle IP-Adresse ermittelt werden soll (z. B. aa:bb:cc:dd:ee:ff)
#[arg(help = "MAC address to look up the current IP address for (e.g. aa:bb:cc:dd:ee:ff)")]
pub mac: MacAddress, pub mac: MacAddress,
/// Gibt das Ergebnis als einzeiliges JSON-Objekt aus; unterdrückt alle sonstigen Log-Ausgaben /// Gibt das Ergebnis als einzeiliges JSON-Objekt aus; unterdrückt alle sonstigen Log-Ausgaben
#[arg(long)] #[arg(
long,
help = "Print the result as a single-line JSON object; suppresses all other log output"
)]
pub json: bool, pub json: bool,
/// Benutzerdefinierter Pfad zur Konfigurationsdatei /// Benutzerdefinierter Pfad zur Konfigurationsdatei
#[arg(long)] #[arg(long, help = "Custom path to the configuration file")]
pub config: Option<PathBuf>, pub config: Option<PathBuf>,
/// Logging-Level (error, warn, info, debug) /// Logging-Level (error, warn, info, debug)
#[arg(long, value_enum, env = "MAC2IP_LOG_LEVEL")] #[arg(
long,
value_enum,
env = "MAC2IP_LOG_LEVEL",
help = "Log level (error, warn, info, debug)"
)]
pub log_level: Option<LogLevelArg>, pub log_level: Option<LogLevelArg>,
/// Cache-TTL in Sekunden (Standard: 1800) /// Cache-TTL in Sekunden (Standard: 1800)
#[arg(long, env = "MAC2IP_CACHE_TTL_SECONDS")] #[arg(
long,
env = "MAC2IP_CACHE_TTL_SECONDS",
help = "Cache TTL in seconds (default: 1800)"
)]
pub cache_ttl_seconds: Option<u64>, pub cache_ttl_seconds: Option<u64>,
/// Pfad zur globalen Cache-Datenbankdatei (Standard: /var/lib/mac2ip/cache.db) /// Pfad zur globalen Cache-Datenbankdatei (Standard: /var/lib/mac2ip/cache.db)
#[arg(long, env = "MAC2IP_CACHE_DB_PATH")] #[arg(
long,
env = "MAC2IP_CACHE_DB_PATH",
help = "Path to the global cache database file (default: /var/lib/mac2ip/cache.db)"
)]
pub cache_db_path: Option<PathBuf>, pub cache_db_path: Option<PathBuf>,
/// Timeout in Sekunden für einen einzelnen nmap-Subnetz-Scan (Standard: 120) /// Timeout in Sekunden für einen einzelnen nmap-Subnetz-Scan (Standard: 120)
#[arg(long, env = "MAC2IP_NMAP_TIMEOUT_SECONDS")] #[arg(
long,
env = "MAC2IP_NMAP_TIMEOUT_SECONDS",
help = "Timeout in seconds for a single nmap subnet scan (default: 120)"
)]
pub nmap_timeout_seconds: Option<u64>, pub nmap_timeout_seconds: Option<u64>,
/// Kommagetrennte Liste von CIDR-Subnetzen für den nmap-Scan (überschreibt Auto-Erkennung) /// Kommagetrennte Liste von CIDR-Subnetzen für den nmap-Scan (überschreibt Auto-Erkennung)
#[arg(long, env = "MAC2IP_NETWORKS", value_delimiter = ',')] #[arg(
long,
env = "MAC2IP_NETWORKS",
value_delimiter = ',',
help = "Comma-separated list of CIDR subnets for the nmap scan (overrides auto-detection)"
)]
pub networks: Option<Vec<String>>, pub networks: Option<Vec<String>>,
/// Kommagetrennte Liste von Gateway-MAC-Adressen, deren Netzwerke ohne Rückfrage für /// Kommagetrennte Liste von Gateway-MAC-Adressen, deren Netzwerke ohne Rückfrage für
/// nmap-Scans (Schritt 3) vertraut werden (überschreibt die Konfigurationsdatei vollständig) /// nmap-Scans (Schritt 3) vertraut werden (überschreibt die Konfigurationsdatei vollständig)
#[arg(long, env = "MAC2IP_TRUSTED_NETWORKS", value_delimiter = ',')] #[arg(
long,
env = "MAC2IP_TRUSTED_NETWORKS",
value_delimiter = ',',
help = "Comma-separated list of gateway MAC addresses whose networks are trusted for \
nmap scans (step 3) without confirmation (fully overrides the config file)"
)]
pub trusted_networks: Option<Vec<MacAddress>>, pub trusted_networks: Option<Vec<MacAddress>>,
/// Beantwortet die "nmap-Scan in diesem Netzwerk erlauben?"-Rückfrage vor Schritt 3 /// Beantwortet die "nmap-Scan in diesem Netzwerk erlauben?"-Rückfrage vor Schritt 3
/// automatisch mit Ja (und merkt sich das Netzwerk dauerhaft im Cache), statt /// automatisch mit Ja (und merkt sich das Netzwerk dauerhaft im Cache), statt
/// interaktiv nachzufragen bzw. im --json-Modus den Scan abzulehnen /// interaktiv nachzufragen bzw. im --json-Modus den Scan abzulehnen
#[arg(long)] #[arg(
long,
help = "Automatically answers yes to the \"allow nmap scan on this network?\" prompt \
before step 3 (and remembers the network permanently in the cache), instead of \
asking interactively or rejecting the scan in --json mode"
)]
pub auto_trust_networks: bool, pub auto_trust_networks: bool,
} }
+5 -5
View File
@@ -4,15 +4,15 @@ use crate::mac::MacAddressError;
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum Mac2IpError { pub enum Mac2IpError {
#[error("keine IP-Adresse für MAC '{mac}' gefunden")] #[error("no IP address found for MAC '{mac}'")]
NotFound { mac: String }, NotFound { mac: String },
#[error( #[error(
"nmap-Scan abgelehnt: Netzwerk nicht vertrauenswürdig{}", "nmap scan rejected: network not trusted{}",
.gateway_mac.as_ref().map(|m| format!(" (Gateway-MAC {m})")).unwrap_or_default() .gateway_mac.as_ref().map(|m| format!(" (gateway MAC {m})")).unwrap_or_default()
)] )]
UntrustedNetwork { gateway_mac: Option<String> }, UntrustedNetwork { gateway_mac: Option<String> },
#[error("MAC-Adresse ungültig: {0}")] #[error("invalid MAC address: {0}")]
InvalidMac(#[from] MacAddressError), InvalidMac(#[from] MacAddressError),
#[error("E/A-Fehler: {0}")] #[error("I/O error: {0}")]
Io(#[from] std::io::Error), Io(#[from] std::io::Error),
} }
+1 -1
View File
@@ -9,7 +9,7 @@ pub struct MacAddress([u8; 6]);
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)] #[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
pub enum MacAddressError { pub enum MacAddressError {
#[error("ungültige MAC-Adresse: '{0}'")] #[error("invalid MAC address: '{0}'")]
InvalidFormat(String), InvalidFormat(String),
} }
+3 -3
View File
@@ -86,11 +86,11 @@ pub enum SudoMode {
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum NmapRunError { pub enum NmapRunError {
#[error("sudo-Zugangsdaten nicht verfügbar (nicht-interaktiver Modus)")] #[error("sudo credentials unavailable (non-interactive mode)")]
SudoUnavailable, SudoUnavailable,
#[error("nmap-Scan hat das Zeitlimit überschritten")] #[error("nmap scan exceeded the time limit")]
Timeout, Timeout,
#[error("E/A-Fehler: {0}")] #[error("I/O error: {0}")]
Io(#[from] std::io::Error), Io(#[from] std::io::Error),
} }
+3 -5
View File
@@ -42,12 +42,11 @@ pub fn print_success(result: &ResolveResult, json: bool) {
if json { if json {
println!( println!(
"{}", "{}",
serde_json::to_string(&success_json(result)) serde_json::to_string(&success_json(result)).expect("JSON serialization never fails")
.expect("JSON-Serialisierung schlägt nicht fehl")
); );
} else { } else {
println!( println!(
"{} -> {} (Quelle: {})", "{} -> {} (source: {})",
result.mac, result.mac,
result.ip, result.ip,
result.source.as_str() result.source.as_str()
@@ -59,8 +58,7 @@ pub fn print_failure(mac: &MacAddress, err: &Mac2IpError, json: bool) {
if json { if json {
println!( println!(
"{}", "{}",
serde_json::to_string(&failure_json(mac, err)) serde_json::to_string(&failure_json(mac, err)).expect("JSON serialization never fails")
.expect("JSON-Serialisierung schlägt nicht fehl")
); );
} else { } else {
crate::log::error("mac2ip", &err.to_string()); crate::log::error("mac2ip", &err.to_string());
+8 -11
View File
@@ -55,10 +55,7 @@ pub async fn resolve(
&& !cache::is_expired(entry.updated_at, now, config.cache_ttl_seconds) && !cache::is_expired(entry.updated_at, now, config.cache_ttl_seconds)
&& network::ping_check(entry.ip).await && network::ping_check(entry.ip).await
{ {
crate::log::info( crate::log::info("resolver", &format!("Cache hit for {mac}: {}", entry.ip));
"resolver",
&format!("Treffer im Cache für {mac}: {}", entry.ip),
);
return Ok(ResolveResult { return Ok(ResolveResult {
mac: *mac, mac: *mac,
ip: entry.ip, ip: entry.ip,
@@ -69,13 +66,13 @@ pub async fn resolve(
// Schritt 2: ip neigh // Schritt 2: ip neigh
crate::log::debug( crate::log::debug(
"resolver", "resolver",
"Cache-Treffer nicht verfügbar, prüfe 'ip neigh show'", "No cache hit available, checking 'ip neigh show'",
); );
if let Ok(output) = network::run_ip_neigh_show().await if let Ok(output) = network::run_ip_neigh_show().await
&& let Some(ip) = network::parse_ip_neigh_output(&output, mac) && let Some(ip) = network::parse_ip_neigh_output(&output, mac)
&& network::ping_check(ip).await && network::ping_check(ip).await
{ {
crate::log::info("resolver", &format!("Treffer via ip neigh für {mac}: {ip}")); crate::log::info("resolver", &format!("Hit via ip neigh for {mac}: {ip}"));
if let Some(cache) = cache { if let Some(cache) = cache {
cache.upsert(mac, ip, MatchSource::Arp.as_str(), now).await; cache.upsert(mac, ip, MatchSource::Arp.as_str(), now).await;
} }
@@ -87,14 +84,14 @@ pub async fn resolve(
} }
// Schritt 3: nmap // Schritt 3: nmap
crate::log::debug("resolver", "Kein Treffer via ip neigh, starte nmap-Scan"); crate::log::debug("resolver", "No hit via ip neigh, starting nmap scan");
match trust::ensure_network_trusted(config, cache, auto_trust_networks, json_mode, now).await { match trust::ensure_network_trusted(config, cache, auto_trust_networks, json_mode, now).await {
TrustDecision::Allowed => {} TrustDecision::Allowed => {}
TrustDecision::Denied { gateway_mac } => { TrustDecision::Denied { gateway_mac } => {
crate::log::warn( crate::log::warn(
"resolver", "resolver",
"nmap-Scan übersprungen: Netzwerk nicht als vertrauenswürdig bestätigt", "nmap scan skipped: network not confirmed as trusted",
); );
return Err(Mac2IpError::UntrustedNetwork { return Err(Mac2IpError::UntrustedNetwork {
gateway_mac: gateway_mac.map(|m| m.to_string()), gateway_mac: gateway_mac.map(|m| m.to_string()),
@@ -125,7 +122,7 @@ pub async fn resolve(
if let Some(ip) = network::parse_nmap_output(&output, mac) if let Some(ip) = network::parse_nmap_output(&output, mac)
&& network::ping_check(ip).await && network::ping_check(ip).await
{ {
crate::log::info("resolver", &format!("Treffer via nmap für {mac}: {ip}")); crate::log::info("resolver", &format!("Hit via nmap for {mac}: {ip}"));
if let Some(cache) = cache { if let Some(cache) = cache {
cache.upsert(mac, ip, MatchSource::Nmap.as_str(), now).await; cache.upsert(mac, ip, MatchSource::Nmap.as_str(), now).await;
} }
@@ -139,12 +136,12 @@ pub async fn resolve(
Err(NmapRunError::SudoUnavailable) => { Err(NmapRunError::SudoUnavailable) => {
crate::log::warn( crate::log::warn(
"nmap", "nmap",
"sudo -n fehlgeschlagen (keine Zugangsdaten) - Schritt 3 wird abgebrochen", "sudo -n failed (no credentials available) - aborting step 3",
); );
break; // sudo-Session-Status ist global, ein Retry pro Subnetz bringt nichts break; // sudo-Session-Status ist global, ein Retry pro Subnetz bringt nichts
} }
Err(e) => { Err(e) => {
crate::log::warn("nmap", &format!("nmap-Scan für {cidr} fehlgeschlagen: {e}")); crate::log::warn("nmap", &format!("nmap scan for {cidr} failed: {e}"));
continue; // Fehler pro Subnetz (z. B. Timeout) - nächstes Subnetz versuchen continue; // Fehler pro Subnetz (z. B. Timeout) - nächstes Subnetz versuchen
} }
} }
+4 -6
View File
@@ -35,12 +35,12 @@ pub async fn ensure_network_trusted(
let Some(gateway_mac) = network::detect_default_gateway_mac().await else { let Some(gateway_mac) = network::detect_default_gateway_mac().await else {
crate::log::warn( crate::log::warn(
"trust", "trust",
"Gateway-MAC konnte nicht ermittelt werden, Netzwerk kann nicht identifiziert werden", "Could not determine gateway MAC, network cannot be identified",
); );
if auto_trust { if auto_trust {
crate::log::warn( crate::log::warn(
"trust", "trust",
"--auto-trust-networks gesetzt: nmap-Scan wird trotz unbekannter Gateway-MAC ausgeführt", "--auto-trust-networks set: running nmap scan despite unknown gateway MAC",
); );
return TrustDecision::Allowed; return TrustDecision::Allowed;
} }
@@ -60,9 +60,7 @@ pub async fn ensure_network_trusted(
if auto_trust { if auto_trust {
crate::log::info( crate::log::info(
"trust", "trust",
&format!( &format!("Network (gateway MAC {gateway_mac}) automatically marked as trusted"),
"Netzwerk (Gateway-MAC {gateway_mac}) automatisch als vertrauenswürdig markiert"
),
); );
if let Some(cache) = cache { if let Some(cache) = cache {
cache.trust_network(&gateway_mac, now).await; cache.trust_network(&gateway_mac, now).await;
@@ -95,7 +93,7 @@ pub async fn ensure_network_trusted(
async fn prompt_trust_confirmation(gateway_mac: MacAddress) -> bool { async fn prompt_trust_confirmation(gateway_mac: MacAddress) -> bool {
tokio::task::spawn_blocking(move || { tokio::task::spawn_blocking(move || {
eprint!( eprint!(
"Unbekanntes Netzwerk (Gateway-MAC {gateway_mac}). nmap-Scan in diesem Netzwerk erlauben und dauerhaft merken? [y/N]: " "Unknown network (gateway MAC {gateway_mac}). Allow nmap scan on this network and remember it permanently? [y/N]: "
); );
let _ = std::io::stderr().flush(); let _ = std::io::stderr().flush();