From 4bac9b33cc4292f38e6357e933bba1f95b34f059 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 1 Sep 2024 11:09:36 +0000 Subject: [PATCH] propagate config error for cidr range Signed-off-by: Jason Volk --- src/service/globals/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index c82d3097..25e0f402 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -8,7 +8,7 @@ use std::{ time::Instant, }; -use conduit::{error, trace, Config, Result}; +use conduit::{err, error, trace, Config, Result}; use data::Data; use ipaddress::IPAddress; use regex::RegexSet; @@ -79,12 +79,10 @@ impl crate::Service for Service { let cidr_range_denylist: Vec<_> = config .ip_range_denylist .iter() - .map(|cidr| { - let cidr = IPAddress::parse(cidr).expect("valid cidr range"); - trace!("Denied CIDR range: {:?}", cidr); - cidr - }) - .collect(); + .map(IPAddress::parse) + .inspect(|cidr| trace!("Denied CIDR range: {cidr:?}")) + .collect::>() + .map_err(|e| err!(Config("ip_range_denylist", e)))?; let mut s = Self { db,