From: Ian Jackson Date: Sat, 7 Aug 2021 17:35:06 +0000 (+0100) Subject: config: Use SKL::None for `link` and fix `server=` X-Git-Tag: hippotat/1.0.0~272 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=9ff953509245685c075a5ab93a3e652215781885;p=hippotat.git config: Use SKL::None for `link` and fix `server=` We don't want to allow `link=` in the actual config files at all, so we should set its SKL to None. Conversely, `server` needs to be tolerated in the special `ServerName` section even though it doesn't appear in the InstanceConfig struct. Signed-off-by: Ian Jackson --- diff --git a/src/config.rs b/src/config.rs index d771a10..1dab223 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,7 +10,7 @@ use configparser::ini::Ini; // xxx ignores empty sections, fix or replace #[derive(Debug,Clone)] pub struct InstanceConfig { // Exceptional settings - #[special(special_link, SKL::ServerName)] pub link: LinkName, + #[special(special_link, SKL::None)] pub link: LinkName, pub secret: Secret, #[special(special_ipif, SKL::PerClient)] pub ipif: String, @@ -260,9 +260,13 @@ impl Aggregate { let sn = sn.parse().dcontext(&sn)?; for key in vars.keys() { - let skl = self.keys_allowed.get(key.as_str()).ok_or_else( - || anyhow!("unknown configuration key {:?}", key) - )?; + let skl = if key == "server" { + SKL::ServerName + } else { + *self.keys_allowed.get(key.as_str()).ok_or_else( + || anyhow!("unknown configuration key {:?}", key) + )? + }; if ! skl.contains(&sn) { throw!(anyhow!("configuration key {:?} not applicable \ in this kind of section: {}", key, &sn)) @@ -672,7 +676,8 @@ impl<'c> ResolveContext<'c> { } #[throws(AE)] - pub fn special_link(&self, _key: &'static str, _skl: SKL) -> LinkName { + pub fn special_link(&self, _key: &'static str, skl: SKL) -> LinkName { + assert_eq!(skl, SKL::None); self.link.clone() } }