aboutsummaryrefslogtreecommitdiffstats
path: root/src/wireguard/wireguard.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-31 19:17:20 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-31 19:17:20 +0100
commit38cbe50223ed956e50fad3e8286f8a6d2410e3d1 (patch)
treeb64bb7346ec43ceed0a66516e9fd1822075c14ea /src/wireguard/wireguard.rs
parentWork on timer semantics (diff)
downloadwireguard-rs-38cbe50223ed956e50fad3e8286f8a6d2410e3d1.tar.xz
wireguard-rs-38cbe50223ed956e50fad3e8286f8a6d2410e3d1.zip
Add derived_session
Diffstat (limited to 'src/wireguard/wireguard.rs')
-rw-r--r--src/wireguard/wireguard.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/wireguard/wireguard.rs b/src/wireguard/wireguard.rs
index e308c50..674c96f 100644
--- a/src/wireguard/wireguard.rs
+++ b/src/wireguard/wireguard.rs
@@ -42,6 +42,7 @@ pub struct PeerInner<B: Bind> {
pub id: u64,
// handshake state
+ pub walltime_last_handshake: Mutex<SystemTime>,
pub last_handshake_sent: Mutex<Instant>, // instant for last handshake
pub handshake_queued: AtomicBool, // is a handshake job currently queued for the peer?
pub queue: Mutex<Sender<HandshakeJob<B::Endpoint>>>, // handshake queue
@@ -244,6 +245,7 @@ impl<T: Tun, B: Bind> Wireguard<T, B> {
let state = Arc::new(PeerInner {
id: rng.gen(),
pk,
+ walltime_last_handshake: Mutex::new(SystemTime::UNIX_EPOCH),
last_handshake_sent: Mutex::new(self.state.start - TIME_HORIZON),
handshake_queued: AtomicBool::new(false),
queue: Mutex::new(self.state.queue.lock().clone()),
@@ -443,9 +445,16 @@ impl<T: Tun, B: Bind> Wireguard<T, B> {
peer.state.sent_handshake_response();
}
- // add resulting keypair to peer
+ // add any new keypair to peer
keypair.map(|kp| {
- debug!("{} : handshake worker, new keypair", wg);
+ debug!(
+ "{} : handshake worker, new keypair for {}",
+ wg, peer
+ );
+
+ // this means that a handshake response was processed or sent
+ peer.timers_session_derieved();
+
// free any unused ids
for id in peer.router.add_keypair(kp) {
state.device.release(id);