feat: allow HTTP operation on private LAN addresses

This commit is contained in:
2026-11-16 06:48:36 +01:00
parent 4337f1d801
commit 870844dbe3
9 changed files with 83 additions and 31 deletions

View File

@ -1,6 +1,6 @@
//! Zweck: Gemeinsame Token- und API-Typen für Server und Client.
//! Wichtige Information: Geheimnisse werden nur erzeugt und gehasht, nie protokolliert.
//! Version: 1
//! Version: 2
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
use serde::{Deserialize, Serialize};
@ -102,6 +102,19 @@ pub struct Problem {
pub korrelation_id: String,
}
/// Erlaubt HTTP zu lokalen und privaten IP-Adressen im freigegebenen LAN-Betrieb.
#[must_use]
pub fn lan_host(host: &str) -> bool {
if host == "localhost" {
return true;
}
match host.trim_matches(['[', ']']).parse::<std::net::IpAddr>() {
Ok(std::net::IpAddr::V4(ip)) => ip.is_loopback() || ip.is_private(),
Ok(std::net::IpAddr::V6(ip)) => ip.is_loopback() || ip.is_unique_local(),
Err(_) => false,
}
}
#[cfg(test)]
mod selbsttest {
use super::*;