feat: Implement SSH master connector and CLI for certificate management
This commit is contained in:
40
apps/nxmesh-agent/src/connector/master/mod.rs
Normal file
40
apps/nxmesh-agent/src/connector/master/mod.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
pub mod ssh;
|
||||
|
||||
pub type AgentClient = nxmesh_proto::agent_service_client::AgentServiceClient<tonic::transport::Channel>;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait MasterConnectorTrait: Send + Sync {
|
||||
async fn connect(
|
||||
&mut self,
|
||||
settings: &crate::config::settings::Settings,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>;
|
||||
fn get_client(&self) -> Arc<Mutex<AgentClient>>;
|
||||
}
|
||||
|
||||
pub struct MasterConnector {
|
||||
connector: Box<dyn MasterConnectorTrait>,
|
||||
}
|
||||
|
||||
impl MasterConnector {
|
||||
pub fn new(connector: Box<dyn MasterConnectorTrait>) -> Self {
|
||||
Self { connector }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MasterConnectorTrait for MasterConnector {
|
||||
async fn connect(
|
||||
&mut self,
|
||||
settings: &crate::config::settings::Settings,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
self.connector.connect(settings).await
|
||||
}
|
||||
|
||||
fn get_client(&self) -> Arc<Mutex<AgentClient>> {
|
||||
self.connector.get_client()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user