aboutsummaryrefslogtreecommitdiffstats
path: root/src/configuration/uapi
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-11-21 17:12:00 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-11-21 17:12:00 +0100
commitdee23969f5b1cfce7b352d6782a86cac062ec12e (patch)
tree15360be6307d32515f9d1be1efcba3dc470c42d9 /src/configuration/uapi
parentClean dependencies and imports (diff)
downloadwireguard-rs-dee23969f5b1cfce7b352d6782a86cac062ec12e.tar.xz
wireguard-rs-dee23969f5b1cfce7b352d6782a86cac062ec12e.zip
Daemonization
Diffstat (limited to 'src/configuration/uapi')
-rw-r--r--src/configuration/uapi/get.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/configuration/uapi/get.rs b/src/configuration/uapi/get.rs
index f0746b3..9e6ab36 100644
--- a/src/configuration/uapi/get.rs
+++ b/src/configuration/uapi/get.rs
@@ -32,24 +32,23 @@ pub fn serialize<C: Configuration, W: io::Write>(writer: &mut W, config: &C) ->
let mut peers = config.get_peers();
while let Some(p) = peers.pop() {
write("public_key", hex::encode(p.public_key.as_bytes()))?;
+ write("preshared_key", hex::encode(p.preshared_key))?;
write("rx_bytes", p.rx_bytes.to_string())?;
write("tx_bytes", p.tx_bytes.to_string())?;
write(
- "last_handshake_time_sec",
- p.last_handshake_time_nsec.to_string(),
- )?;
- write(
- "last_handshake_time_nsec",
- p.last_handshake_time_nsec.to_string(),
- )?;
- write(
"persistent_keepalive_interval",
p.persistent_keepalive_interval.to_string(),
)?;
+
+ if let Some((secs, nsecs)) = p.last_handshake_time {
+ write("last_handshake_time_sec", secs.to_string())?;
+ write("last_handshake_time_nsec", nsecs.to_string())?;
+ }
+
if let Some(endpoint) = p.endpoint {
write("endpoint", endpoint.into_address().to_string())?;
}
- write("preshared_key", hex::encode(p.preshared_key))?;
+
for (ip, cidr) in p.allowed_ips {
write("allowed_ip", ip.to_string() + "/" + &cidr.to_string())?;
}