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/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/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 10fca6c14..5994a405b 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() }) @@ -255,7 +255,10 @@ impl GatewayClient { .filter_map(|(res, pubkey)| async move { match res.verify(&pubkey) { Ok(()) => Some(res), - Err(_) => None, + Err(err) => { + tracing::error!(?err, "Response verification failed"); + None + } } }) .flat_map(|res| stream::iter(res.gateways.into_iter())) @@ -320,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..2cf2be26d 100644 --- a/mobile_config_cli/src/cmds/gateway.rs +++ b/mobile_config_cli/src/cmds/gateway.rs @@ -4,9 +4,9 @@ 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 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), }) } } 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:#?"); }