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:
40
apps/nxmesh-master/src/connector/agent/mod.rs
Normal file
40
apps/nxmesh-master/src/connector/agent/mod.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use sea_orm::DatabaseConnection;
|
||||
use tonic::transport::Server;
|
||||
|
||||
pub mod ssh;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait AgentConnectorTrait: Send + Sync {
|
||||
async fn start_server(
|
||||
&mut self,
|
||||
settings: &crate::config::settings::Settings,
|
||||
cert_service: Arc<dyn crate::service::certificate::CertificateService>,
|
||||
connection: DatabaseConnection,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>;
|
||||
}
|
||||
|
||||
pub struct AgentConnector {
|
||||
connector: Box<dyn AgentConnectorTrait>,
|
||||
}
|
||||
|
||||
impl AgentConnector {
|
||||
pub fn new(connector: Box<dyn AgentConnectorTrait>) -> Self {
|
||||
Self { connector }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl AgentConnectorTrait for AgentConnector {
|
||||
async fn start_server(
|
||||
&mut self,
|
||||
settings: &crate::config::settings::Settings,
|
||||
cert_service: Arc<dyn crate::service::certificate::CertificateService>,
|
||||
connection: DatabaseConnection,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
self.connector
|
||||
.start_server(settings, cert_service, connection)
|
||||
.await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user