feat: Implement SSH Agent Connector and gRPC server

- Added `AgentConnectorTrait` and `AgentConnector` for managing agent connections.
- Introduced `SshAgentConnector` to handle SSH-related functionalities and start a gRPC server.
- Created database entities for `agents`, `certificates`, `organizations`, `public_key_revocations`, `setup_tokens`, `upstreams`, `users`, `virtual_hosts`, and `workspaces` using SeaORM.
- Developed `CertificateService` for managing certificate generation and retrieval.
- Implemented the main server logic to initialize the database connection and start the agent server.
- Configured development settings in `development.toml` for server and database connections.
This commit is contained in:
GW_MC
2026-03-21 03:09:39 +00:00
parent 9640f03d69
commit f5eb25993b
27 changed files with 1581 additions and 2 deletions

View File

@@ -0,0 +1,63 @@
mod gen_agent_certs;
mod gen_certs;
use clap::{Parser, Subcommand};
use crate::{
cli::{gen_agent_certs::gen_agent_certs, gen_certs::gen_certs},
config::settings::Settings,
};
#[derive(Parser)]
#[command(version, about, long_about = None)]
pub struct Cli {
/// Start the master server
#[arg(short, long, group = "mode")]
pub serve: bool,
/// generate CA for key signing if not exist
/// If the CA already exists, generating CA will be skipped and the existing CA will be used
/// If the CA does not exist, a new CA will be generated and saved to the default location (./certs/ca.crt and ./certs/ca.key)
/// The generated CA will be used for signing agent certificates
/// If not specified, the server will check if the CA already exists and use it if available, otherwise exit with an error
#[arg(long)]
pub generate_ca: bool,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand)]
pub enum Commands {
GenCerts {
/// Output directory for generated certificates
#[arg(short, long, default_value = "./certs")]
output: String,
},
/// Generate certificates for agent
#[command(about = "Generate certificates for agent")]
GenAgentCerts {
/// Output directory for generated certificates
#[arg(short, long, default_value = "./certs")]
output: String,
#[arg(long, default_value = "agent-id-placeholder")]
agent_id: String,
#[arg(short, long, default_value = "false")]
zip: bool,
},
}
pub async fn handle_sub_command(
settings: &Settings,
command: Commands,
) -> Result<(), Box<dyn std::error::Error>> {
// run as a CLI tool for other commands
match command {
Commands::GenCerts { output } => Ok(gen_certs(settings, output).await?),
Commands::GenAgentCerts {
output,
agent_id,
zip,
} => Ok(gen_agent_certs(settings, output, agent_id, zip).await?),
}
}