From 7a52e3eb29a6787fec881a81881e1a9cd098005e Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Thu, 20 Mar 2025 13:54:37 +0200 Subject: [PATCH 1/4] Print error if verification failed --- mobile_config_cli/src/client.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mobile_config_cli/src/client.rs b/mobile_config_cli/src/client.rs index 10fca6c14..38238d44f 100644 --- a/mobile_config_cli/src/client.rs +++ b/mobile_config_cli/src/client.rs @@ -255,7 +255,10 @@ impl GatewayClient { .filter_map(|(res, pubkey)| async move { match res.verify(&pubkey) { Ok(()) => Some(res), - Err(_) => None, + Err(e) => { + eprintln!("Response verification failed. {e}"); + None + } } }) .flat_map(|res| stream::iter(res.gateways.into_iter())) From 7466a5f4161d739a7c0095cbd14750fa6297d5f6 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Thu, 20 Mar 2025 14:24:58 +0200 Subject: [PATCH 2/4] Use v2 requests --- mobile_config_cli/src/client.rs | 12 ++++++------ mobile_config_cli/src/cmds/gateway.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mobile_config_cli/src/client.rs b/mobile_config_cli/src/client.rs index 38238d44f..a83cd45b3 100644 --- a/mobile_config_cli/src/client.rs +++ b/mobile_config_cli/src/client.rs @@ -12,8 +12,8 @@ use helium_proto::{ AdminAddKeyReqV1, AdminKeyResV1, AdminRemoveKeyReqV1, AuthorizationListReqV1, AuthorizationListResV1, AuthorizationVerifyReqV1, AuthorizationVerifyResV1, CarrierIncentivePromotionListReqV1, CarrierIncentivePromotionListResV1, EntityVerifyReqV1, - EntityVerifyResV1, GatewayInfoBatchReqV1, GatewayInfoReqV1, GatewayInfoResV1, - GatewayInfoStreamResV1, + EntityVerifyResV1, GatewayInfoBatchReqV1, GatewayInfoReqV1, GatewayInfoResV2, + GatewayInfoStreamResV2, }, Message, }; @@ -223,7 +223,7 @@ impl GatewayClient { signature: vec![], }; request.signature = request.sign(keypair)?; - let response = self.client.info(request).await?.into_inner(); + let response = self.client.info_v2(request).await?.into_inner(); response.verify(&self.server_pubkey)?; let info = response .info @@ -247,7 +247,7 @@ impl GatewayClient { let config_pubkey = self.server_pubkey.clone(); let stream = self .client - .info_batch(request) + .info_batch_v2(request) .await? .into_inner() .filter_map(|res| async move { res.ok() }) @@ -323,6 +323,6 @@ impl_verify!(AdminKeyResV1, signature); impl_verify!(AuthorizationVerifyResV1, signature); impl_verify!(AuthorizationListResV1, signature); impl_verify!(EntityVerifyResV1, signature); -impl_verify!(GatewayInfoResV1, signature); -impl_verify!(GatewayInfoStreamResV1, signature); +impl_verify!(GatewayInfoResV2, signature); +impl_verify!(GatewayInfoStreamResV2, signature); impl_verify!(CarrierIncentivePromotionListResV1, signature); diff --git a/mobile_config_cli/src/cmds/gateway.rs b/mobile_config_cli/src/cmds/gateway.rs index 68e45ab21..ffb5ecc2c 100644 --- a/mobile_config_cli/src/cmds/gateway.rs +++ b/mobile_config_cli/src/cmds/gateway.rs @@ -4,7 +4,7 @@ use angry_purple_tiger::AnimalName; use futures::StreamExt; use helium_crypto::PublicKey; use helium_proto::services::mobile_config::{ - GatewayInfo as GatewayInfoProto, GatewayMetadata as GatewayMetadataProto, + GatewayInfoV2 as GatewayInfoProto, GatewayMetadataV2 as GatewayMetadataProto, }; use mobile_config::gateway_info::DeviceType; use serde::Serialize; From 0cfd7838e8884047317dc4948f4d1b364a7f60c3 Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Fri, 21 Mar 2025 14:03:51 +0200 Subject: [PATCH 3/4] Use tracing::error to print error message --- Cargo.lock | 1 + mobile_config_cli/Cargo.toml | 2 ++ mobile_config_cli/src/client.rs | 4 ++-- mobile_config_cli/src/cmds/mod.rs | 9 +++++++++ mobile_config_cli/src/main.rs | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf4640121..cada4d499 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5072,6 +5072,7 @@ dependencies = [ "anyhow", "base64 0.21.7", "clap 4.4.8", + "custom-tracing", "dialoguer", "futures", "h3o", diff --git a/mobile_config_cli/Cargo.toml b/mobile_config_cli/Cargo.toml index f94ee5971..821c5d157 100644 --- a/mobile_config_cli/Cargo.toml +++ b/mobile_config_cli/Cargo.toml @@ -25,3 +25,5 @@ tokio = {workspace = true, features = ["macros", "rt-multi-thread"]} tokio-stream = {workspace = true} tonic = {workspace = true, features = ["tls", "tls-roots"]} tracing = {workspace = true} +custom-tracing = { path = "../custom_tracing" } + diff --git a/mobile_config_cli/src/client.rs b/mobile_config_cli/src/client.rs index a83cd45b3..5994a405b 100644 --- a/mobile_config_cli/src/client.rs +++ b/mobile_config_cli/src/client.rs @@ -255,8 +255,8 @@ impl GatewayClient { .filter_map(|(res, pubkey)| async move { match res.verify(&pubkey) { Ok(()) => Some(res), - Err(e) => { - eprintln!("Response verification failed. {e}"); + Err(err) => { + tracing::error!(?err, "Response verification failed"); None } } diff --git a/mobile_config_cli/src/cmds/mod.rs b/mobile_config_cli/src/cmds/mod.rs index 04d4b1f61..65baf823c 100644 --- a/mobile_config_cli/src/cmds/mod.rs +++ b/mobile_config_cli/src/cmds/mod.rs @@ -15,6 +15,7 @@ pub mod gateway; pub const ENV_CONFIG_HOST: &str = "HELIUM_CONFIG_HOST"; pub const ENV_CONFIG_PUBKEY: &str = "HELIUM_CONFIG_PUBKEY"; pub const ENV_KEYPAIR_BIN: &str = "HELIUM_KEYPAIR_BIN"; +pub const ENV_LOG_FILTER: &str = "HELIUM_LOG_FILTER"; #[derive(Debug, Parser)] #[command(name = "mobile-config")] @@ -49,6 +50,14 @@ pub struct Cli { #[arg(global = true, long)] pub print_command: bool, + + #[arg( + global = true, + long, + env = ENV_LOG_FILTER, + default_value = "Error" + )] + pub log_filter: String, } #[derive(Debug, Subcommand)] diff --git a/mobile_config_cli/src/main.rs b/mobile_config_cli/src/main.rs index dcb6b3fbd..a219dfbdb 100644 --- a/mobile_config_cli/src/main.rs +++ b/mobile_config_cli/src/main.rs @@ -8,6 +8,8 @@ use mobile_config_cli::{ async fn main() -> Result { let cli = Cli::parse(); + custom_tracing::init(cli.log_filter.clone(), custom_tracing::Settings::default()).await?; + if cli.print_command { println!("cli:#?"); } From 1df5a0094de604dab729808e988a9c5a7123353c Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Fri, 21 Mar 2025 14:38:45 +0200 Subject: [PATCH 4/4] Add DeploymentInfo --- mobile_config/src/gateway_info.rs | 10 +++++----- mobile_config_cli/src/cmds/gateway.rs | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mobile_config/src/gateway_info.rs b/mobile_config/src/gateway_info.rs index 30987badb..04ed91618 100644 --- a/mobile_config/src/gateway_info.rs +++ b/mobile_config/src/gateway_info.rs @@ -9,11 +9,11 @@ use helium_proto::services::mobile_config::{ GatewayMetadata as GatewayMetadataProto, GatewayMetadataV2 as GatewayMetadataProtoV2, WifiDeploymentInfo as WifiDeploymentInfoProto, }; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; pub type GatewayInfoStream = BoxStream<'static, GatewayInfo>; -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct WifiDeploymentInfo { /// Antenna ID pub antenna: u32, @@ -37,7 +37,7 @@ impl From for WifiDeploymentInfo { } } -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct CbrsDeploymentInfo { pub cbrs_radios_deployment_info: Vec, } @@ -63,7 +63,7 @@ impl From for CbrsRadioDeploymentInfo { } } -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct CbrsRadioDeploymentInfo { /// CBSD_ID pub radio_id: String, @@ -71,7 +71,7 @@ pub struct CbrsRadioDeploymentInfo { pub elevation: u32, } -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub enum DeploymentInfo { #[serde(rename = "wifiInfoV0")] WifiDeploymentInfo(WifiDeploymentInfo), diff --git a/mobile_config_cli/src/cmds/gateway.rs b/mobile_config_cli/src/cmds/gateway.rs index ffb5ecc2c..2cf2be26d 100644 --- a/mobile_config_cli/src/cmds/gateway.rs +++ b/mobile_config_cli/src/cmds/gateway.rs @@ -6,7 +6,7 @@ use helium_crypto::PublicKey; use helium_proto::services::mobile_config::{ GatewayInfoV2 as GatewayInfoProto, GatewayMetadataV2 as GatewayMetadataProto, }; -use mobile_config::gateway_info::DeviceType; +use mobile_config::gateway_info::{DeploymentInfo, DeviceType}; use serde::Serialize; use std::str::FromStr; @@ -23,6 +23,7 @@ pub struct GatewayInfo { #[derive(Debug, Serialize)] pub struct GatewayMetadata { location: String, + deployment_info: Option, lat: f64, lon: f64, } @@ -89,6 +90,7 @@ impl TryFrom for GatewayMetadata { location, lat: latlng.lat(), lon: latlng.lng(), + deployment_info: md.deployment_info.map(DeploymentInfo::from), }) } }