propagate config error for cidr range

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-09-01 11:09:36 +00:00
parent 60605e9579
commit 4bac9b33cc
1 changed files with 5 additions and 7 deletions

View File

@ -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::<Result<_, String>>()
.map_err(|e| err!(Config("ip_range_denylist", e)))?;
let mut s = Self {
db,