fix getNext

This commit is contained in:
Aiden McClelland
2025-12-19 12:35:06 -07:00
parent 30b1654666
commit 04196df976
3 changed files with 68 additions and 14 deletions

View File

@@ -160,6 +160,16 @@ pub async fn add_subnet(
.db
.mutate(|db| {
let map = db.as_wg_mut().as_subnets_mut();
if let Some(s) = map
.keys()?
.into_iter()
.find(|s| s != &subnet && (s.contains(&subnet) || subnet.contains(s)))
{
return Err(Error::new(
eyre!("{subnet} overlaps with existing subnet {s}"),
ErrorKind::InvalidRequest,
));
}
map.upsert(&subnet, || {
Ok(WgSubnetConfig::new(InternedString::default()))
})?