diff options
author | Hristo Venev <hristo@venev.name> | 2019-03-18 13:42:37 +0200 |
---|---|---|
committer | Hristo Venev <hristo@venev.name> | 2019-03-18 13:42:37 +0200 |
commit | 87aa7ff470e93e412502cd5341f110fa74de03a1 (patch) | |
tree | bc24251bc4a98a049a1a9c451282ddca2e138c8c /src/proto.rs | |
parent | 761a87cc6e64990b9dd0e235047e1d1e7c7d6971 (diff) |
Implement road warrior support.
Diffstat (limited to 'src/proto.rs')
-rw-r--r-- | src/proto.rs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/proto.rs b/src/proto.rs index a3ee6e6..609dbd9 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -7,11 +7,28 @@ use crate::ip::{Endpoint, Ipv4Net, Ipv6Net}; #[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] pub struct Peer { pub public_key: String, + #[serde(default = "Vec::new")] + pub ipv4: Vec<Ipv4Net>, + #[serde(default = "Vec::new")] + pub ipv6: Vec<Ipv6Net>, +} + +#[serde(deny_unknown_fields)] +#[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] +pub struct Server { + #[serde(flatten)] + pub peer: Peer, pub endpoint: Endpoint, #[serde(default = "default_peer_keepalive")] pub keepalive: u32, - pub ipv4: Vec<Ipv4Net>, - pub ipv6: Vec<Ipv6Net>, +} + +#[serde(deny_unknown_fields)] +#[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] +pub struct RoadWarrior { + #[serde(flatten)] + pub peer: Peer, + pub base: String, } fn default_peer_keepalive() -> u32 { @@ -20,7 +37,10 @@ fn default_peer_keepalive() -> u32 { #[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] pub struct SourceConfig { - pub peers: Vec<Peer>, + #[serde(default = "Vec::new")] + pub servers: Vec<Server>, + #[serde(default = "Vec::new")] + pub road_warriors: Vec<RoadWarrior>, } #[derive(serde_derive::Serialize, serde_derive::Deserialize, Clone, PartialEq, Eq, Debug)] |