From a140786d535e12297ff7304766c1213d9d685dae Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Fri, 21 May 2021 13:00:09 +0900 Subject: [PATCH] client: fix add-cidr when confirm is 'no' --- client/src/main.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index 2d7474f..3bc458c 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -544,22 +544,24 @@ fn add_cidr(interface: &InterfaceName, opts: AddCidrOpts) -> Result<(), Error> { let api = Api::new(&server); let cidrs: Vec = api.http("GET", "/admin/cidrs")?; - let cidr_request = prompts::add_cidr(&cidrs, &opts)?; + if let Some(cidr_request) = prompts::add_cidr(&cidrs, &opts)? { + log::info!("Creating CIDR..."); + let cidr: Cidr = api.http_form("POST", "/admin/cidrs", cidr_request)?; - log::info!("Creating CIDR..."); - let cidr: Cidr = api.http_form("POST", "/admin/cidrs", cidr_request)?; + eprintdoc!( + " + CIDR \"{cidr_name}\" added. - eprintdoc!( - " - CIDR \"{cidr_name}\" added. + Right now, peers within {cidr_name} can only see peers in the same CIDR + , and in the special \"infra\" CIDR that includes the innernet server peer. - Right now, peers within {cidr_name} can only see peers in the same CIDR - , and in the special \"infra\" CIDR that includes the innernet server peer. - - You'll need to add more associations for peers in diffent CIDRs to communicate. - ", - cidr_name = cidr.name.bold() - ); + You'll need to add more associations for peers in diffent CIDRs to communicate. + ", + cidr_name = cidr.name.bold() + ); + } else { + log::info!("exited without creating CIDR."); + } Ok(()) }