aboutsummaryrefslogtreecommitdiffstats
path: root/src/peer.rs
diff options
context:
space:
mode:
authorJake McGinty <me@jake.su>2018-02-22 17:35:50 +0000
committerJake McGinty <me@jake.su>2018-02-22 17:36:08 +0000
commiteb268e7c350043075fd7a49fdb3a68573bddd1ca (patch)
treea580635f5be607b25044ff5388c90c8a2fcdcbf4 /src/peer.rs
parentsquish unnecessary memcpy (diff)
downloadwireguard-rs-eb268e7c350043075fd7a49fdb3a68573bddd1ca.tar.xz
wireguard-rs-eb268e7c350043075fd7a49fdb3a68573bddd1ca.zip
support removing peers
Diffstat (limited to 'src/peer.rs')
-rw-r--r--src/peer.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/peer.rs b/src/peer.rs
index 5cd0487..118ba23 100644
--- a/src/peer.rs
+++ b/src/peer.rs
@@ -160,6 +160,14 @@ impl Peer {
self.sessions.current.is_some()
}
+ pub fn get_mapped_indices(&self) -> Vec<u32> {
+ let mut indices = Vec::with_capacity(3);
+ if let Some(ref session) = self.sessions.past { indices.push(session.our_index); }
+ if let Some(ref session) = self.sessions.current { indices.push(session.our_index); }
+ if let Some(ref session) = self.sessions.next { indices.push(session.our_index); }
+ indices
+ }
+
pub fn initiate_new_session(&mut self, private_key: &[u8]) -> Result<(SocketAddr, Vec<u8>, u32, Option<u32>), Error> {
let noise = noise::build_initiator(private_key, &self.info.pub_key, &self.info.psk)?;
let mut session = Session::from(noise);