From dee23969f5b1cfce7b352d6782a86cac062ec12e Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Thu, 21 Nov 2019 17:12:00 +0100 Subject: Daemonization --- src/configuration/uapi/get.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/configuration/uapi') 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(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())?; } -- cgit v1.2.3-59-g8ed1b