diff --git a/src/engine.rs b/src/engine.rs index 5b03852f..47e19fed 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -30,6 +30,7 @@ use crossbeam_queue::{ArrayQueue, SegQueue}; use crossbeam_utils::thread; use log::{debug, error, info, warn}; use rpki::crypto::keys::KeyIdentifier; +#[allow(unused_imports)] use rpki::repository::aspa::{Aspa, AsProviderAttestation}; use rpki::repository::cert::{Cert, KeyUsage, ResourceCert}; use rpki::repository::crl::Crl; @@ -1390,32 +1391,35 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> { } /// Process an ASPA object. + #[allow(unused_variables)] fn process_aspa( &mut self, uri: &uri::Rsync, content: Bytes, manifest: &mut ValidPointManifest, ) -> Result<(), Failed> { - let aspa = match Aspa::decode( - content, self.run.validation.strict - ) { - Ok(aspa) => aspa, - Err(err) => { - warn!("{}: {}.", uri, err); - manifest.metrics.invalid_aspas += 1; - return Ok(()) - } - }; - match aspa.process( - self.cert.cert(), - self.run.validation.strict, - |cert| manifest.check_crl(cert) - ) { - Ok((cert, aspa)) => { - manifest.metrics.valid_aspas += 1; - self.processor.process_aspa(uri, cert, aspa)? - } - Err(err) => { - manifest.metrics.invalid_aspas += 1; - warn!("{}: {}.", uri, err) + #[cfg(feature = "aspa")] { + let aspa = match Aspa::decode( + content, self.run.validation.strict + ) { + Ok(aspa) => aspa, + Err(err) => { + warn!("{}: {}.", uri, err); + manifest.metrics.invalid_aspas += 1; + return Ok(()) + } + }; + match aspa.process( + self.cert.cert(), + self.run.validation.strict, + |cert| manifest.check_crl(cert) + ) { + Ok((cert, aspa)) => { + manifest.metrics.valid_aspas += 1; + self.processor.process_aspa(uri, cert, aspa)? + } + Err(err) => { + manifest.metrics.invalid_aspas += 1; + warn!("{}: {}.", uri, err) + } } } Ok(()) diff --git a/src/http/metrics.rs b/src/http/metrics.rs index 1ca2010e..25aed454 100644 --- a/src/http/metrics.rs +++ b/src/http/metrics.rs @@ -256,14 +256,16 @@ fn object_metrics<'a>( .label("state", "invalid") .value(metrics.invalid_roas); - target.multi(metric).label(group.label(), name) - .label("type", "aspa") - .label("state", "valid") - .value(metrics.valid_aspas); - target.multi(metric).label(group.label(), name) - .label("type", "aspa") - .label("state", "invalid") - .value(metrics.invalid_aspas); + #[cfg(feature = "aspa")] { + target.multi(metric).label(group.label(), name) + .label("type", "aspa") + .label("state", "valid") + .value(metrics.valid_aspas); + target.multi(metric).label(group.label(), name) + .label("type", "aspa") + .label("state", "invalid") + .value(metrics.invalid_aspas); + } target.multi(metric).label(group.label(), name) .label("type", "gbr") @@ -416,19 +418,20 @@ fn payload_metrics<'a>( .value(metrics.contributed); } - target.multi(valid_metric) - .label(group.label(), name) - .label("type", "aspas") - .value(metrics.aspas.valid); - target.multi(duplicate_metric) - .label(group.label(), name) - .label("type", "aspas") - .value(metrics.aspas.duplicate); - target.multi(contributed_metric) - .label(group.label(), name) - .label("type", "aspas") - .value(metrics.aspas.contributed); - + #[cfg(feature = "aspa")] { + target.multi(valid_metric) + .label(group.label(), name) + .label("type", "aspas") + .value(metrics.aspas.valid); + target.multi(duplicate_metric) + .label(group.label(), name) + .label("type", "aspas") + .value(metrics.aspas.duplicate); + target.multi(contributed_metric) + .label(group.label(), name) + .label("type", "aspas") + .value(metrics.aspas.contributed); + } } } diff --git a/src/http/status.rs b/src/http/status.rs index d7ca3b21..e43494cf 100644 --- a/src/http/status.rs +++ b/src/http/status.rs @@ -598,8 +598,10 @@ fn json_publication_metrics( target.member_raw("validROAs", metrics.valid_roas); target.member_raw("invalidROAs", metrics.invalid_roas); target.member_raw("validGBRs", metrics.valid_gbrs); - target.member_raw("invalidASPAs", metrics.invalid_aspas); - target.member_raw("validASPAs", metrics.valid_aspas); + #[cfg(feature = "aspa")] { + target.member_raw("invalidASPAs", metrics.invalid_aspas); + target.member_raw("validASPAs", metrics.valid_aspas); + } target.member_raw("invalidGBRs", metrics.invalid_gbrs); target.member_raw("otherObjects", metrics.others); } @@ -628,9 +630,11 @@ fn json_payload_metrics( target.member_object("routerKeys", |target| { json_vrps_metrics(target, &payload.router_keys, false) }); - target.member_object("aspas", |target| { - json_vrps_metrics(target, &payload.aspas, false) - }) + #[cfg(feature = "aspa")] { + target.member_object("aspas", |target| { + json_vrps_metrics(target, &payload.aspas, false) + }); + } }); }