agentmux_srv/server/
lan_firewall_handlers.rs1use std::sync::Arc;
11
12use crate::backend::lan::{firewall, firewall_setup};
13use crate::backend::rpc::engine::WshRpcEngine;
14use crate::backend::rpc_types::{CommandLanFirewallSetupData, LanFirewallSetupResult, RpcContext, COMMAND_LAN_FIREWALL_SETUP};
15
16const WHY: &str = "only the person asks for the firewall setup, in the AgentMux window";
17
18async fn setup(ctx: &RpcContext) -> Result<LanFirewallSetupResult, String> {
19 ctx.operator_only(WHY)?;
20 let result = tokio::task::spawn_blocking(firewall_setup::run_blocking).await.map_err(|e| format!("lan:firewall:setup: {e}"))?;
21 tracing::info!(outcome = ?result.outcome, "LAN firewall setup asked for from the window");
22 firewall::read_again_now();
23 Ok(result)
24}
25
26pub fn register(engine: &Arc<WshRpcEngine>) {
27 engine.register_typed(COMMAND_LAN_FIREWALL_SETUP, move |_cmd: CommandLanFirewallSetupData, ctx| async move { setup(&ctx).await });
28}