- 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.
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
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
|
|
}
|
|
}
|