aboutsummaryrefslogtreecommitdiff
path: root/src/proto.rs
diff options
context:
space:
mode:
authorHristo Venev <hristo@venev.name>2020-02-04 22:43:44 +0100
committerHristo Venev <hristo@venev.name>2020-02-04 22:43:44 +0100
commite6c406879696a53d40f175d11d14a55d9480a57e (patch)
tree4f91613dbd7f019f33117148177a8a17dc84a94a /src/proto.rs
parenta7cff9572d672d516569b4a55b4a0dbbeb3cb9e1 (diff)
More peer options in config.
endpoint and keepalive
Diffstat (limited to 'src/proto.rs')
-rw-r--r--src/proto.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/proto.rs b/src/proto.rs
index 9f9ea0a..5f168a9 100644
--- a/src/proto.rs
+++ b/src/proto.rs
@@ -11,6 +11,7 @@ pub struct Peer {
pub public_key: Key,
pub ipv4: Vec<Ipv4Net>,
pub ipv6: Vec<Ipv6Net>,
+ pub keepalive: u32,
}
#[serde(from = "ServerRepr", into = "ServerRepr")]
@@ -18,7 +19,6 @@ pub struct Peer {
pub struct Server {
pub peer: Peer,
pub endpoint: Endpoint,
- pub keepalive: u32,
}
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
@@ -29,23 +29,20 @@ struct ServerRepr {
ipv4: Vec<Ipv4Net>,
#[serde(default)]
ipv6: Vec<Ipv6Net>,
- endpoint: Endpoint,
#[serde(default)]
keepalive: u32,
+ endpoint: Endpoint,
}
impl From<Server> for ServerRepr {
#[inline]
fn from(v: Server) -> Self {
- let Server {
- peer,
- endpoint,
- keepalive,
- } = v;
+ let Server { peer, endpoint } = v;
let Peer {
public_key,
ipv4,
ipv6,
+ keepalive,
} = peer;
Self {
public_key,
@@ -64,17 +61,17 @@ impl From<ServerRepr> for Server {
public_key,
ipv4,
ipv6,
- endpoint,
keepalive,
+ endpoint,
} = v;
Self {
peer: Peer {
public_key,
ipv4,
ipv6,
+ keepalive,
},
endpoint,
- keepalive,
}
}
}
@@ -94,7 +91,9 @@ pub struct RoadWarriorRepr {
ipv4: Vec<Ipv4Net>,
#[serde(default)]
ipv6: Vec<Ipv6Net>,
- pub base: Key,
+ #[serde(default)]
+ keepalive: u32,
+ base: Key,
}
impl From<RoadWarrior> for RoadWarriorRepr {
@@ -105,11 +104,13 @@ impl From<RoadWarrior> for RoadWarriorRepr {
public_key,
ipv4,
ipv6,
+ keepalive,
} = peer;
Self {
public_key,
ipv4,
ipv6,
+ keepalive,
base,
}
}
@@ -122,6 +123,7 @@ impl From<RoadWarriorRepr> for RoadWarrior {
public_key,
ipv4,
ipv6,
+ keepalive,
base,
} = v;
Self {
@@ -129,6 +131,7 @@ impl From<RoadWarriorRepr> for RoadWarrior {
public_key,
ipv4,
ipv6,
+ keepalive,
},
base,
}