diff --git a/server/src/main.rs b/server/src/main.rs index 6b23036..b60074f 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -761,106 +761,6 @@ fn main() -> Result<(), Box> { state.rebuild_index(); - if let Some(command) = cli.command { - match command { - Commands::Gate { subcmd } => match subcmd { - GateCommands::Set { - action, - target, - namespace, - params, - authorize, - block, - reason, - } => { - let status = if authorize { - "authorized".to_string() - } else if block { - "blocked".to_string() - } else { - "pending".to_string() - }; - let mut param_map = HashMap::new(); - for p in params { - if let Some((k, v)) = p.split_once('=') { - param_map.insert(k.to_string(), v.to_string()); - } - } - let record = GateRecord { - id: uuid::Uuid::new_v4().to_string(), - action: action.clone(), - target: target.clone(), - namespace, - params: param_map, - status, - reason, - timestamp: SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs(), - }; - state.gates.modify(|gates| { - gates.retain(|g| !(g.action == record.action && g.target == record.target)); - gates.push(record); - }); - println!("Gate state updated."); - std::process::exit(0); - } - GateCommands::Verify { - action, - target, - namespace, - params, - consume, - } => { - let mut param_map = HashMap::new(); - for p in params { - if let Some((k, v)) = p.split_once('=') { - param_map.insert(k.to_string(), v.to_string()); - } - } - let mut found = None; - let mut to_remove = None; - state.gates.modify(|gates| { - if let Some(idx) = gates.iter().position(|g| { - g.action == action - && g.target == target - && g.namespace == namespace - && g.params == param_map - }) { - found = Some(gates[idx].clone()); - if consume { - to_remove = Some(idx); - } - } - if let Some(idx) = to_remove { - gates.remove(idx); - } - }); - - match found { - Some(record) => { - if record.status == "authorized" { - std::process::exit(0); - } else { - if let Some(r) = record.reason { - eprintln!("❌ Action blocked. Reason: {}", r); - } else { - eprintln!("❌ Action blocked."); - } - std::process::exit(1); - } - } - None => { - eprintln!("❌ Action not yet authorized (no gate record found)."); - std::process::exit(2); - } - } - } - }, - } - } - run_server(state) } diff --git a/stub/src/main.rs b/stub/src/main.rs index 113c863..2100ade 100644 --- a/stub/src/main.rs +++ b/stub/src/main.rs @@ -19,7 +19,7 @@ fn main() -> Result<(), Box> { let cli = Cli::parse(); let rt = tokio::runtime::Runtime::new()?; rt.block_on(async { - let (msg_tx, mut msg_rx) = mpsc::channel::(100); + let (msg_tx, msg_rx) = mpsc::channel::(100); let (shutdown_tx, mut shutdown_rx) = mpsc::channel::<()>(1); tokio::spawn(async move {