Try multiple ports for vaultwarden connection detection

This commit is contained in:
Christoffer Martinsson 2025-10-13 20:57:28 +02:00
parent c5795e3add
commit 6b22d23a2e

View File

@ -932,20 +932,24 @@ impl ServiceCollector {
} }
async fn get_vaultwarden_info(&self) -> Option<String> { async fn get_vaultwarden_info(&self) -> Option<String> {
// Check HTTP connections - vaultwarden typically runs on port 8000 or behind nginx // Try common vaultwarden ports: 8080, 8084, 8000
let output = Command::new("/run/current-system/sw/bin/ss") let ports = ["8080", "8084", "8000"];
.args(["-tn", "state", "established", "dport", "= :8000"])
.stdout(Stdio::piped()) for port in &ports {
.stderr(Stdio::piped()) let output = Command::new("/run/current-system/sw/bin/ss")
.output() .args(["-tn", "state", "established", "dport", &format!("= :{}", port)])
.await .stdout(Stdio::piped())
.ok()?; .stderr(Stdio::piped())
.output()
.await
.ok()?;
if output.status.success() { if output.status.success() {
let stdout = String::from_utf8_lossy(&output.stdout); let stdout = String::from_utf8_lossy(&output.stdout);
let connection_count = stdout.lines().count().saturating_sub(1); let connection_count = stdout.lines().count().saturating_sub(1);
if connection_count > 0 { if connection_count > 0 {
return Some(format!("{} connections", connection_count)); return Some(format!("{} connections", connection_count));
}
} }
} }