StartTunnel random subnet and also 80 to 5443 (#3082)

* random subnet and also 80 to 5443

* fix getNext

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>
This commit is contained in:
Matt Hill
2025-12-19 23:25:58 -07:00
committed by GitHub
parent f41710c892
commit 2d0251e585
4 changed files with 106 additions and 17 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()))
})?