[core] Share links and repo layout: HMAC tokens with epoch, prefix check, exact hosts/<hostname>.toml, error codes; edge config v2
This commit is contained in:
@@ -377,9 +377,8 @@ fn check_host(file: &str, raw: RawHost, site: Option<&Site>, errors: &mut Vec<E>
|
||||
reason,
|
||||
}),
|
||||
Ok(()) => {
|
||||
// One TOML per host, named after it: `hosts/<hostname>.toml`.
|
||||
let base = file.rsplit(['/', '\\']).next().unwrap_or(file);
|
||||
if base != format!("{}.toml", raw.hostname) {
|
||||
// One TOML per host, named after it: exactly `hosts/<hostname>.toml`.
|
||||
if file != format!("hosts/{}.toml", raw.hostname) {
|
||||
errors.push(E::FileNameMismatch {
|
||||
file: f(),
|
||||
hostname: raw.hostname.clone(),
|
||||
@@ -481,9 +480,7 @@ fn check_host(file: &str, raw: RawHost, site: Option<&Site>, errors: &mut Vec<E>
|
||||
.bytes()
|
||||
.all(|c| c.is_ascii_graphic() && !b"{}#".contains(&c));
|
||||
if !ok_path {
|
||||
errors.push(bad(
|
||||
r::HEALTH_PATH,
|
||||
));
|
||||
errors.push(bad(r::HEALTH_PATH));
|
||||
return None;
|
||||
}
|
||||
match u32::try_from(hc.interval_secs) {
|
||||
@@ -594,14 +591,16 @@ fn check_rules(
|
||||
file: f(),
|
||||
header: header.clone(),
|
||||
reason,
|
||||
field: at(if reason == r::RULE_NEITHER { "value" } else { "" }),
|
||||
field: at(if reason == r::RULE_NEITHER {
|
||||
"value"
|
||||
} else {
|
||||
""
|
||||
}),
|
||||
};
|
||||
match (r.action, r.value, r.secret) {
|
||||
(RawAction::Remove, None, None) => out.push(HeaderRule::Remove { name: r.name }),
|
||||
(RawAction::Remove, _, _) => errors.push(bad(r::RULE_REMOVE_VALUE)),
|
||||
(RawAction::Set, Some(_), Some(_)) => {
|
||||
errors.push(bad(r::RULE_BOTH))
|
||||
}
|
||||
(RawAction::Set, Some(_), Some(_)) => errors.push(bad(r::RULE_BOTH)),
|
||||
(RawAction::Set, None, None) => errors.push(bad(r::RULE_NEITHER)),
|
||||
(RawAction::Set, Some(v), None) => match check_header_value(&v) {
|
||||
Ok(()) => out.push(HeaderRule::Set {
|
||||
|
||||
Reference in New Issue
Block a user