From 63173742604694695b28463d6eef29df75b4dfc2 Mon Sep 17 00:00:00 2001 From: Michael Jeffrey Date: Wed, 8 Nov 2023 17:22:09 -0700 Subject: [PATCH] splits ignore empty skf into 2 commands with more docs --- src/cmds/mod.rs | 10 +++++++--- src/cmds/route.rs | 12 ++++++++++-- src/main.rs | 5 ++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/cmds/mod.rs b/src/cmds/mod.rs index ec7d910..6f840eb 100644 --- a/src/cmds/mod.rs +++ b/src/cmds/mod.rs @@ -267,7 +267,13 @@ pub enum RouteUpdateCommand { RemoveGwmpRegion(RemoveGwmpRegion), /// Set the Route Protocol to PacketRouter (GRPC) PacketRouter(UpdatePacketRouter), - /// Set route `ignore_empty_skf` boolean + /// Permissive: set `ignore_empty_skf` to false (default) + /// + /// A Packet with no Session Key Filters for it's DevAddr WILL be routed. + AllowEmptySkf(SetIgnoreEmptySkf), + /// Restrictive: set `ignore_empty_skf` to true + /// + /// A Packet with no Session Key Filter for it's DevAddr WILL NOT be routed. IgnoreEmptySkf(SetIgnoreEmptySkf), } @@ -387,8 +393,6 @@ pub struct RemoveGwmpRegion { pub struct SetIgnoreEmptySkf { #[arg(short, long)] pub route_id: String, - #[arg(short, long)] - pub ignore: bool, #[arg(from_global)] pub keypair: PathBuf, #[arg(from_global)] diff --git a/src/cmds/route.rs b/src/cmds/route.rs index dc6f725..498b558 100644 --- a/src/cmds/route.rs +++ b/src/cmds/route.rs @@ -324,14 +324,22 @@ pub async fn update_packet_router(args: UpdatePacketRouter) -> Result { } } -pub async fn update_ignore_empty_skf(args: SetIgnoreEmptySkf) -> Result { +pub async fn allow_empty_skf(args: SetIgnoreEmptySkf) -> Result { + set_ignore_empty_skf(args, false).await +} + +pub async fn ignore_empty_skf(args: SetIgnoreEmptySkf) -> Result { + set_ignore_empty_skf(args, true).await +} + +pub async fn set_ignore_empty_skf(args: SetIgnoreEmptySkf, ignore: bool) -> Result { let mut client = client::RouteClient::new(&args.config_host, &args.config_pubkey).await?; let keypair = args.keypair.to_keypair()?; let mut route = client.get(&args.route_id, &keypair).await?; let old_route = route.clone(); - route.ignore_empty_skf = args.ignore; + route.ignore_empty_skf = ignore; if !args.commit { return Msg::dry_run(format!( diff --git a/src/main.rs b/src/main.rs index 55d02d4..7b293fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,9 +41,8 @@ pub async fn handle_cli(cli: Cli) -> Result { RouteUpdateCommand::AddGwmpRegion(args) => route::add_gwmp_region(args).await, RouteUpdateCommand::RemoveGwmpRegion(args) => route::remove_gwmp_region(args).await, RouteUpdateCommand::PacketRouter(args) => route::update_packet_router(args).await, - RouteUpdateCommand::IgnoreEmptySkf(args) => { - route::update_ignore_empty_skf(args).await - } + RouteUpdateCommand::AllowEmptySkf(args) => route::allow_empty_skf(args).await, + RouteUpdateCommand::IgnoreEmptySkf(args) => route::ignore_empty_skf(args).await, }, RouteCommands::Euis { command } => match command { cmds::EuiCommands::List(args) => euis::list_euis(args).await,