summaryrefslogtreecommitdiffstats
path: root/src/wireguard/peer.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-11-06 13:50:38 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-11-06 13:50:38 +0100
commit293914e47b046f862608a1af91864b6b38336aa5 (patch)
treec6851f4c0e8cd38efdcbc2aa6999395f67f1e555 /src/wireguard/peer.rs
parentWork on Up/Down operation on WireGuard device (diff)
downloadwireguard-rs-293914e47b046f862608a1af91864b6b38336aa5.tar.xz
wireguard-rs-293914e47b046f862608a1af91864b6b38336aa5.zip
Implement disable/enable timers
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> {