aboutsummaryrefslogtreecommitdiffstats
path: root/src/wireguard/peer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wireguard/peer.rs')
-rw-r--r--src/wireguard/peer.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/wireguard/peer.rs b/src/wireguard/peer.rs
index 9f24dea..b77e8c6 100644
--- a/src/wireguard/peer.rs
+++ b/src/wireguard/peer.rs
@@ -4,12 +4,11 @@ use super::timers::{Events, Timers};
use super::HandshakeJob;
use super::bind::Bind;
-use super::bind::Reader as BindReader;
-use super::tun::{Reader, Tun};
+use super::tun::Tun;
use std::fmt;
use std::ops::Deref;
-use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
+use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::Arc;
use std::time::{Instant, SystemTime};
@@ -34,8 +33,7 @@ pub struct PeerInner<B: Bind> {
pub queue: Mutex<Sender<HandshakeJob<B::Endpoint>>>, // handshake queue
// stats and configuration
- pub pk: PublicKey, // public key, DISCUSS: avoid this. TODO: remove
- pub keepalive_interval: AtomicU64, // keepalive interval
+ pub pk: PublicKey, // public key, DISCUSS: avoid this. TODO: remove
pub rx_bytes: AtomicU64, // received bytes
pub tx_bytes: AtomicU64, // transmitted bytes
@@ -78,11 +76,20 @@ impl<T: Tun, B: Bind> Deref for Peer<T, B> {
}
impl<T: Tun, B: Bind> Peer<T, B> {
+ /// Bring the peer down. Causing:
+ ///
+ /// - Timers to be stopped and disabled.
+ /// - All keystate to be zeroed
pub fn down(&self) {
self.stop_timers();
+ self.router.down();
}
- pub fn up(&self) {}
+ /// Bring the peer up.
+ pub fn up(&self) {
+ self.router.up();
+ self.start_timers();
+ }
}
impl<B: Bind> PeerInner<B> {