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 @@ -3,12 +3,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"); +} use crypto_tools::generate_device_id; use identity::identity_service_client::IdentityServiceClient; @@ -84,6 +88,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; } @@ -180,3 +190,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"), + }) +}