add 'disabled' state, fix handshake proxy send

This commit is contained in:
2026-06-17 18:23:24 +02:00
parent 940b595e3a
commit 64b2f04f8f
15 changed files with 57 additions and 20 deletions

32
src/cli/disable.rs Normal file
View File

@ -0,0 +1,32 @@
use bollard::Docker;
use clap::Arg;
use clap::{Command, ArgMatches};
use crate::DbPool;
use crate::srvmgr;
use crate::status::ServerStatus;
use diesel::prelude::*;
use crate::schema;
pub fn create_subcommand() -> Command {
Command::new("disable")
.about("disable")
.arg(Arg::new("NAME").required(true))
}
pub async fn subcommand(arguments: &ArgMatches, pool: &DbPool, docker: &Docker) -> Result<(), String> {
use schema::servers::dsl::*;
let server_name = arguments.get_one::<String>("NAME").unwrap();
println!("Stopping container");
srvmgr::stop_server(&docker, pool, server_name, true).await?;
println!("container stopped");
let conn = &mut pool.get().unwrap();
diesel::update(servers).filter(name.eq(server_name)).set(status.eq(ServerStatus::Disabled)).execute(conn).map_err(|e| format!("Failed to disable the server : {}", e))?;
Ok(())
}