diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs --- a/native/native_rust_library/src/lib.rs +++ b/native/native_rust_library/src/lib.rs @@ -5,12 +5,16 @@ use tokio::runtime::{Builder, Runtime}; use tonic::{transport::Channel, Status}; use tracing::instrument; +use tunnelbroker::tunnelbroker_service_client::TunnelbrokerServiceClient; mod crypto_tools; mod identity_client; mod identity { tonic::include_proto!("identity"); } +mod tunnelbroker { + tonic::include_proto!("tunnelbroker"); +} lazy_static! { pub static ref RUNTIME: Arc = Arc::new( @@ -83,6 +87,12 @@ user_public_key: String, ) -> Result; + // Tunnelbroker Service Client + type TunnelbrokerClient; + + #[cxx_name = "TunnelbrokerInitializeClient"] + fn initialize_tunnelbroker_client(addr: String) -> Box; + // Crypto Tools fn generate_device_id(device_type: DeviceType) -> Result; } @@ -179,3 +189,16 @@ user_public_key, )) } + +#[derive(Debug)] +pub struct TunnelbrokerClient { + tunnelbroker_client: TunnelbrokerServiceClient, +} + +fn initialize_tunnelbroker_client(addr: String) -> Box { + Box::new(TunnelbrokerClient { + tunnelbroker_client: RUNTIME + .block_on(TunnelbrokerServiceClient::connect(addr)) + .expect("Failed to create Tokio runtime for the Tunnelbroker client"), + }) +}