From c02ce36f690811aabbacfdcb577e0875f9397340 Mon Sep 17 00:00:00 2001 From: Dorian Date: Mon, 16 Mar 2026 17:41:32 +0000 Subject: [PATCH] fix: Tor toggle tries systemd before container restart The toggle handler only tried `podman restart archy-tor` which fails on servers running Tor as a systemd service. Now tries `systemctl restart tor` first (like the rotation handler already does), falling back to container restart. Co-Authored-By: Claude Opus 4.6 (1M context) --- core/archipelago/src/api/rpc/tor.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/core/archipelago/src/api/rpc/tor.rs b/core/archipelago/src/api/rpc/tor.rs index 741c5842..10f02e44 100644 --- a/core/archipelago/src/api/rpc/tor.rs +++ b/core/archipelago/src/api/rpc/tor.rs @@ -330,15 +330,24 @@ impl RpcHandler { info!(app = app_id, "Disabled Tor access — removed hidden service dir"); } - // Restart archy-tor to apply changes - let status = tokio::process::Command::new("sudo") - .args(["podman", "restart", "archy-tor"]) + // Restart Tor to apply changes — try system service first, then container + let system_ok = tokio::process::Command::new("sudo") + .args(["systemctl", "restart", "tor"]) .status() .await - .context("Failed to restart archy-tor")?; + .map(|s| s.success()) + .unwrap_or(false); - if !status.success() { - warn!("archy-tor restart failed after toggle"); + if !system_ok { + let container_ok = tokio::process::Command::new("sudo") + .args(["podman", "restart", "archy-tor"]) + .status() + .await + .map(|s| s.success()) + .unwrap_or(false); + if !container_ok { + warn!("Failed to restart Tor after toggle"); + } } // If enabling, wait for hostname to appear