This commit is contained in:
Mateusz Gruszczyński committed 2026-11-15 13:45:15 +01:00
1 parent df0e39b899
commit 21aef61dd5
35 files changed
+1360 -100

No files matched your search

+13 -2
View File
@@ -3,7 +3,9 @@ impl Snapshot {
if let Some(value) = lookup(host) {
return Some(value);
}
let last_dot = host.rfind('.')?;
let Some(last_dot) = host.rfind('.') else {
return lookup(CATCH_ALL_HOST);
};
let mut wildcard = [0u8; 256];
wildcard[..2].copy_from_slice(b"*.");
for (index, _) in host.match_indices('.') {
@@ -23,7 +25,7 @@ impl Snapshot {
return Some(value);
}
}
None
lookup(CATCH_ALL_HOST)
}
pub fn host_allowed(&self, host: &str, peer: IpAddr) -> bool {
if self.host_acls.is_empty() {
@@ -431,6 +433,15 @@ pub fn normalize_host(value: &str) -> Result<String> {
);
Ok(host)
}
pub const CATCH_ALL_HOST: &str = "*";
pub fn normalize_frontend_host(value: &str) -> Result<String> {
if value.trim() == CATCH_ALL_HOST {
return Ok(CATCH_ALL_HOST.into());
}
normalize_host_pattern(value)
}
pub fn normalize_host_pattern(value: &str) -> Result<String> {
let value = value.trim();
if let Some(base) = value.strip_prefix("*.") {