This commit is contained in:
Mateusz Gruszczyński committed 2026-11-08 09:46:32 +01:00
1 parent 34490fd5fc
commit 6ef01212ec
21 files changed
+204 -77

No files matched your search

+21 -8
View File
@@ -65,7 +65,8 @@ pub fn compile_with_active(
php_profiles
.insert(profile.id.clone(), profile.php.clone())
.is_none(),
"duplicate PHP-FPM profile id"
"duplicate PHP-FPM profile id {:?}: every profile needs a unique ID",
profile.id
);
}
ensure!(
@@ -120,7 +121,8 @@ pub fn compile_with_active(
);
ensure!(
web_services.insert(service.id.clone(), compiled).is_none(),
"duplicate Web Service id"
"duplicate Web Service id {:?}: every Web Service needs a unique ID",
service.id
);
}
ensure!(config.vhosts.len() <= 64, "too many vhosts (max 64)");
@@ -145,7 +147,11 @@ pub fn compile_with_active(
validate_source(&route.source)?;
}
}
ensure!(vhost_ids.insert(host.id.clone()), "duplicate vhost id");
ensure!(
vhost_ids.insert(host.id.clone()),
"duplicate vhost id {:?}: every vhost needs a unique ID",
host.id
);
}
ensure!(
config.redirects.len() <= 64,
@@ -158,7 +164,8 @@ pub fn compile_with_active(
.with_context(|| format!("redirect {}", redirect.id))?;
ensure!(
redirect_ids.insert(redirect.id.clone()),
"duplicate redirect id"
"duplicate redirect id {:?}: every redirect needs a unique ID",
redirect.id
);
}
ensure!(
@@ -171,7 +178,8 @@ pub fn compile_with_active(
.with_context(|| format!("404 host {}", host.id))?;
ensure!(
not_found_ids.insert(host.id.clone()),
"duplicate 404 host id"
"duplicate 404 host id {:?}: every 404 host needs a unique ID",
host.id
);
}
let effective_tls = crate::tls::for_all_frontends(
@@ -279,7 +287,11 @@ pub fn compile_with_active(
let mut acl_profiles: HashMap<String, (Option<CompiledAcl>, crate::rate_limit::CountryAccess)> =
HashMap::new();
for profile in &mut config.acl_profiles {
ensure!(valid_id(&profile.id), "invalid ACL profile id");
ensure!(
valid_id(&profile.id),
"invalid ACL profile id {:?}: use 1-64 letters, digits, '-' or '_'",
profile.id
);
ensure!(
!profile.name.trim().is_empty()
&& profile.name.len() <= 96
@@ -293,7 +305,8 @@ pub fn compile_with_active(
acl_profiles
.insert(profile.id.clone(), (acl, profile.country_access.clone()))
.is_none(),
"duplicate ACL profile id"
"duplicate ACL profile id {:?}: every ACL profile needs a unique ID",
profile.id
);
}
crate::acl::dynamic::configured_hostnames(&config)?;
@@ -380,7 +393,7 @@ fn normalize_prefix(prefix: &mut String) -> Result<()> {
&& !prefix.contains('?')
&& !prefix.contains('#')
&& !prefix.bytes().any(|b| b <= 32 || b == 127),
"invalid path prefix"
"invalid path prefix: it must start with '/', be at most 512 bytes and contain no '?', '#', spaces or control characters"
);
if prefix.len() > 1 {
*prefix = prefix.trim_end_matches('/').to_owned();