pub vroutes: Vec<CidrString>,
}
+#[derive(Debug,Clone)]
+pub enum SectionName {
+ Link { server: ServerName, client: ClientName },
+ Client(ClientName),
+ Server(ServerName), // includes SERVER, which is slightly special
+ Common,
+ Default,
+}
+pub use SectionName as SN;
+
type SectionMap = HashMap<String, Option<String>>;
pub struct Config {
}
}
+impl FromStr for SectionName {
+ type Err = AE;
+ #[throws(AE)]
+ fn from_str(s: &str) -> Self {
+ match s {
+ "COMMON" => return SN::Common,
+ "DEFAULT" => return SN::Default,
+ _ => { }
+ };
+ if let Ok(n@ ServerName(_)) = s.parse() { return SN::Server(n) }
+ 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>"
+ ))?;
+ let server = server.parse().context("server name in link section name")?;
+ let client = client.parse().context("client name in link section name")?;
+ SN::Link { server, client }
+ }
+}
+
impl Aggregate {
#[throws(AE)] // AE does not include path
fn read_file<A>(&mut self, path: &Path, anyway: OkAnyway<A>) -> Option<A>
#[derive(Debug,Clone,Copy)]
pub struct ClientName(pub Ipv4Addr);
-#[derive(Debug,Clone)]
-pub enum SectionName {
- Link { server: ServerName, client: ClientName },
- Client(ClientName),
- Server(ServerName), // includes SERVER, which is slightly special
- Common,
- Default,
-}
-pub use SectionName as SN;
-
impl FromStr for ClientName {
type Err = AE;
#[throws(AE)]
ServerName(s.into())
}
}
-
-impl FromStr for SectionName {
- type Err = AE;
- #[throws(AE)]
- fn from_str(s: &str) -> Self {
- match s {
- "COMMON" => return SN::Common,
- "DEFAULT" => return SN::Default,
- _ => { }
- };
- if let Ok(n@ ServerName(_)) = s.parse() { return SN::Server(n) }
- 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>"
- ))?;
- let server = server.parse().context("server name in link section name")?;
- let client = client.parse().context("client name in link section name")?;
- SN::Link { server, client }
- }
-}