fix(mount): M-03 — output webdav credentials and manual mount instructions for linux
This commit is contained in:
+48
-10
@@ -375,16 +375,8 @@ pub async fn mount_container(
|
||||
);
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
println!(
|
||||
" • gio Befehl: gio mount dav://127.0.0.1:{}/",
|
||||
bound_port
|
||||
);
|
||||
if let Some(mp) = mount_point {
|
||||
println!(
|
||||
" • davfs2: mount -t davfs http://127.0.0.1:{}/ {}",
|
||||
bound_port,
|
||||
mp.display()
|
||||
);
|
||||
for line in format_linux_mount_instructions(bound_port, &session_token, mount_point) {
|
||||
println!("{}", line);
|
||||
}
|
||||
}
|
||||
if let Some(secs) = idle_timeout {
|
||||
@@ -657,6 +649,36 @@ pub fn is_loopback_host(host_str: &str) -> bool {
|
||||
matches!(host_part, "127.0.0.1" | "localhost" | "::1")
|
||||
}
|
||||
|
||||
/// Erzeugt die plattformspezifischen Linux-Mount-Anweisungen und Authentifizierungsdaten (M-03).
|
||||
pub fn format_linux_mount_instructions(
|
||||
port: u16,
|
||||
token: &str,
|
||||
mount_point: Option<&std::path::Path>,
|
||||
) -> Vec<String> {
|
||||
let mut lines = Vec::new();
|
||||
lines.push(format!(
|
||||
" • WebDAV-Auth: Benutzer: sanctum | Token: {}",
|
||||
token
|
||||
));
|
||||
lines.push(format!(
|
||||
" • gio Befehl: echo {} | gio mount dav://sanctum@127.0.0.1:{}/",
|
||||
token, port
|
||||
));
|
||||
if let Some(mp) = mount_point {
|
||||
lines.push(format!(
|
||||
" • davfs2: mount -t davfs -o username=sanctum http://127.0.0.1:{}/ {}",
|
||||
port,
|
||||
mp.display()
|
||||
));
|
||||
} else {
|
||||
lines.push(format!(
|
||||
" • davfs2: mount -t davfs -o username=sanctum http://127.0.0.1:{}/ /mnt/sanctum",
|
||||
port
|
||||
));
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
/// Maximale Anzahl gleichzeitiger Verbindungen zum lokalen WebDAV-Endpunkt (Schutz gegen Socket-Exhaustion).
|
||||
const MAX_CONCURRENT_DAV_CONNECTIONS: usize = 64;
|
||||
|
||||
@@ -948,4 +970,20 @@ mod tests {
|
||||
// Leeres Token darf niemals matchen
|
||||
assert!(!uri_contains_token(&uri_clean, ""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_m03_format_linux_mount_instructions() {
|
||||
let token = "fedcba9876543210fedcba9876543210";
|
||||
let instructions = format_linux_mount_instructions(
|
||||
8443,
|
||||
token,
|
||||
Some(std::path::Path::new("/mnt/secure")),
|
||||
);
|
||||
|
||||
let all_text = instructions.join("\n");
|
||||
assert!(all_text.contains("Benutzer: sanctum"));
|
||||
assert!(all_text.contains(token));
|
||||
assert!(all_text.contains("gio mount dav://sanctum@127.0.0.1:8443/"));
|
||||
assert!(all_text.contains("mount -t davfs -o username=sanctum http://127.0.0.1:8443/ /mnt/secure"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user