Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splits ignore empty skf into 2 commands with more docs #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/cmds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down Expand Up @@ -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)]
Expand Down
12 changes: 10 additions & 2 deletions src/cmds/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,22 @@ pub async fn update_packet_router(args: UpdatePacketRouter) -> Result<Msg> {
}
}

pub async fn update_ignore_empty_skf(args: SetIgnoreEmptySkf) -> Result<Msg> {
pub async fn allow_empty_skf(args: SetIgnoreEmptySkf) -> Result<Msg> {
set_ignore_empty_skf(args, false).await
}

pub async fn ignore_empty_skf(args: SetIgnoreEmptySkf) -> Result<Msg> {
set_ignore_empty_skf(args, true).await
}

pub async fn set_ignore_empty_skf(args: SetIgnoreEmptySkf, ignore: bool) -> Result<Msg> {
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!(
Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ pub async fn handle_cli(cli: Cli) -> Result<Msg> {
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,
Expand Down