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:
31
apps/nxmesh-master/src/cli/gen_certs.rs
Normal file
31
apps/nxmesh-master/src/cli/gen_certs.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::{config::settings::Settings, db, service};
|
||||
|
||||
pub async fn gen_certs(
|
||||
settings: &Settings,
|
||||
output: String,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
info!("Generating CA certificate to output directory: {}", output);
|
||||
use service::certificate::CertificateService;
|
||||
let cert_service = service::certificate::CertificateServiceImpl::new(
|
||||
#[expect(clippy::expect_used)]
|
||||
db::establish_connection(&settings.database.url)
|
||||
.await
|
||||
.expect("Failed to connect to database"),
|
||||
output.to_string(),
|
||||
Arc::new(settings.clone()),
|
||||
);
|
||||
cert_service
|
||||
.generate_ca_cert()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("Failed to generate CA certificate: {}", e);
|
||||
std::process::exit(1);
|
||||
})
|
||||
.unwrap();
|
||||
info!("Successfully generated CA certificate at: {}", output);
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user