mirror of
https://github.com/NLnetLabs/krill.git
synced 2026-10-01 13:54:53 +02:00
Show BGP vs ROA analysis in CLI. (#233)
This commit is contained in:
@@ -13,6 +13,7 @@ use crate::commons::api::{
|
||||
AllCertAuthIssues, CaRepoDetails, CertAuthIssues, ChildCaInfo, CurrentRepoState,
|
||||
ParentCaContact, PublisherDetails, PublisherList, Token,
|
||||
};
|
||||
use crate::commons::bgp::{RoaSummary, RoaTable};
|
||||
use crate::commons::remote::rfc8183;
|
||||
use crate::commons::util::httpclient;
|
||||
use crate::constants::KRILL_CLI_API_ENV;
|
||||
@@ -211,6 +212,19 @@ impl KrillClient {
|
||||
Ok(ApiResponse::Empty)
|
||||
}
|
||||
|
||||
CaCommand::RouteAuthorizationsBgpDetails(handle) => {
|
||||
let uri = format!("api/v1/cas/{}/routes/bgp", handle);
|
||||
let roa_table = self.get_json(&uri).await?;
|
||||
Ok(ApiResponse::RouteAuthorizationsBgpDetails(roa_table))
|
||||
}
|
||||
|
||||
CaCommand::RouteAuthorizationsBgpSummary(handle) => {
|
||||
let uri = format!("api/v1/cas/{}/routes/bgp", handle);
|
||||
let roa_table: RoaTable = self.get_json(&uri).await?;
|
||||
let summary: RoaSummary = roa_table.into();
|
||||
Ok(ApiResponse::RouteAuthorizationsBgpSummary(summary))
|
||||
}
|
||||
|
||||
CaCommand::Show(handle) => {
|
||||
let uri = format!("api/v1/cas/{}", handle);
|
||||
let ca_info = self.get_json(&uri).await?;
|
||||
|
||||
@@ -607,11 +607,29 @@ impl Options {
|
||||
app.subcommand(sub)
|
||||
}
|
||||
|
||||
fn make_cas_routes_bgp_sc<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
|
||||
let mut sub = SubCommand::with_name("bgp")
|
||||
.about("Show current authorizations in relation to known announcements.");
|
||||
|
||||
sub = Self::add_general_args(sub);
|
||||
sub = Self::add_my_ca_arg(sub);
|
||||
|
||||
sub = sub.arg(
|
||||
Arg::with_name("full")
|
||||
.long("full")
|
||||
.help("Show detailed view instead of summary")
|
||||
.required(false),
|
||||
);
|
||||
|
||||
app.subcommand(sub)
|
||||
}
|
||||
|
||||
fn make_cas_routes_sc<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
|
||||
let mut sub = SubCommand::with_name("roas").about("Manage ROAs for your CA.");
|
||||
|
||||
sub = Self::make_cas_routes_list_sc(sub);
|
||||
sub = Self::make_cas_routes_update_sc(sub);
|
||||
sub = Self::make_cas_routes_bgp_sc(sub);
|
||||
|
||||
app.subcommand(sub)
|
||||
}
|
||||
@@ -1287,11 +1305,26 @@ impl Options {
|
||||
Ok(Options::make(general_args, command))
|
||||
}
|
||||
|
||||
fn parse_matches_cas_routes_bgp(matches: &ArgMatches) -> Result<Options, Error> {
|
||||
let general_args = GeneralArgs::from_matches(matches)?;
|
||||
let my_ca = Self::parse_my_ca(matches)?;
|
||||
|
||||
let command = if matches.is_present("full") {
|
||||
Command::CertAuth(CaCommand::RouteAuthorizationsBgpDetails(my_ca))
|
||||
} else {
|
||||
Command::CertAuth(CaCommand::RouteAuthorizationsBgpSummary(my_ca))
|
||||
};
|
||||
|
||||
Ok(Options::make(general_args, command))
|
||||
}
|
||||
|
||||
fn parse_matches_cas_routes(matches: &ArgMatches) -> Result<Options, Error> {
|
||||
if let Some(m) = matches.subcommand_matches("list") {
|
||||
Self::parse_matches_cas_routes_list(m)
|
||||
} else if let Some(m) = matches.subcommand_matches("update") {
|
||||
Self::parse_matches_cas_routes_update(m)
|
||||
} else if let Some(m) = matches.subcommand_matches("bgp") {
|
||||
Self::parse_matches_cas_routes_bgp(m)
|
||||
} else {
|
||||
Err(Error::UnrecognisedSubCommand)
|
||||
}
|
||||
@@ -1618,12 +1651,19 @@ pub enum CaCommand {
|
||||
#[display(fmt = "activate key roll for ca: '{}'", _0)]
|
||||
KeyRollActivate(Handle),
|
||||
|
||||
// Authorizations
|
||||
#[display(fmt = "list ROAS for ca: '{}'", _0)]
|
||||
RouteAuthorizationsList(Handle),
|
||||
|
||||
#[display(fmt = "Update ROAS for ca: '{}' -> {}", _0, _1)]
|
||||
RouteAuthorizationsUpdate(Handle, RoaDefinitionUpdates),
|
||||
|
||||
#[display(fmt = "Show detailed ROA vs BGP analysis for ca: '{}'", _0)]
|
||||
RouteAuthorizationsBgpDetails(Handle),
|
||||
|
||||
#[display(fmt = "Show summary of ROA vs BGP analysis for ca: '{}'", _0)]
|
||||
RouteAuthorizationsBgpSummary(Handle),
|
||||
|
||||
// Show details for this CA
|
||||
#[display(fmt = "Show details for ca: '{}'", _0)]
|
||||
Show(Handle),
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::commons::api::{
|
||||
ParentCaContact, PublisherDetails, PublisherList, RepositoryContact, RoaDefinition, ServerInfo,
|
||||
StoredEffect,
|
||||
};
|
||||
use crate::commons::bgp::{RoaSummary, RoaTable};
|
||||
use crate::commons::eventsourcing::WithStorableDetails;
|
||||
use crate::commons::remote::api::ClientInfo;
|
||||
use crate::commons::remote::rfc8183;
|
||||
@@ -30,6 +31,8 @@ pub enum ApiResponse {
|
||||
CertAuthAction(CaCommandDetails),
|
||||
CertAuths(CertAuthList),
|
||||
RouteAuthorizations(Vec<RoaDefinition>),
|
||||
RouteAuthorizationsBgpDetails(RoaTable),
|
||||
RouteAuthorizationsBgpSummary(RoaSummary),
|
||||
|
||||
ParentCaContact(ParentCaContact),
|
||||
|
||||
@@ -69,6 +72,10 @@ impl ApiResponse {
|
||||
ApiResponse::CertAuthIssues(issues) => Ok(Some(issues.report(fmt)?)),
|
||||
ApiResponse::AllCertAuthIssues(issues) => Ok(Some(issues.report(fmt)?)),
|
||||
ApiResponse::RouteAuthorizations(auths) => Ok(Some(auths.report(fmt)?)),
|
||||
ApiResponse::RouteAuthorizationsBgpDetails(table) => Ok(Some(table.report(fmt)?)),
|
||||
ApiResponse::RouteAuthorizationsBgpSummary(summary) => {
|
||||
Ok(Some(summary.report(fmt)?))
|
||||
}
|
||||
ApiResponse::ParentCaContact(contact) => Ok(Some(contact.report(fmt)?)),
|
||||
ApiResponse::ChildInfo(info) => Ok(Some(info.report(fmt)?)),
|
||||
ApiResponse::PublisherList(list) => Ok(Some(list.report(fmt)?)),
|
||||
@@ -407,6 +414,18 @@ impl Report for Vec<RoaDefinition> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Report for RoaTable {
|
||||
fn text(&self) -> Result<String, ReportError> {
|
||||
Ok(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Report for RoaSummary {
|
||||
fn text(&self) -> Result<String, ReportError> {
|
||||
Ok(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Report for CaRepoDetails {
|
||||
fn text(&self) -> Result<String, ReportError> {
|
||||
let mut res = String::new();
|
||||
|
||||
Reference in New Issue
Block a user