pub vroutes: Vec<CidrString>,
}
-#[derive(Debug,Clone)]
+#[derive(Debug,Clone,Hash,Eq,PartialEq)]
pub enum SectionName {
Link { server: ServerName, client: ClientName },
Client(ClientName),
}
pub use SectionName as SN;
-type SectionMap = HashMap<SectionName, Option<String>>;
+type SectionMap = HashMap<String, Option<String>>;
pub struct Config {
opts: Opts,
#[derive(Default,Debug)]
struct Aggregate {
- sections: HashMap<String, SectionMap>,
+ sections: HashMap<SectionName, SectionMap>,
}
type OkAnyway<'f,A> = &'f dyn Fn(ErrorKind) -> Option<A>;
if let Ok(n@ ClientName(_)) = s.parse() { return SN::Client(n) }
let (server, client) = s.split_ascii_whitespace().collect_tuple()
.ok_or_else(|| anyhow!(
- "bad section name \
- (must be COMMON, DEFAULT, <server>, <client>, or <server> <client>"
+ "bad section name {:?} \
+ (must be COMMON, DEFAULT, <server>, <client>, or <server> <client>",
+ s
))?;
let server = server.parse().context("server name in link section name")?;
let client = client.parse().context("client name in link section name")?;
for (sn, vars) in map.drain() {
let sn = sn.parse().dcontext(&sn)?;
+ Extend::extend(
self.sections.entry(sn)
- .or_default()
- .extend(vars);
+ .or_default(),
+ vars);
}
None
}
use crate::prelude::*;
-#[derive(Debug,Clone)]
+#[derive(Debug,Clone,Hash,Eq,PartialEq)]
pub struct ServerName(pub String);
-#[derive(Debug,Clone,Copy)]
+#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
pub struct ClientName(pub Ipv4Addr);
impl FromStr for ClientName {