aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-23 14:14:08 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-23 14:14:08 +0200
commit3e829c04d1edfde1966a0d3f7f330fadd7ca9cd8 (patch)
tree5e749f39590eeedf56430c6cacf0a16af0fb2550 /src
parentWork on pure WireGuard test (diff)
downloadwireguard-rs-3e829c04d1edfde1966a0d3f7f330fadd7ca9cd8.tar.xz
wireguard-rs-3e829c04d1edfde1966a0d3f7f330fadd7ca9cd8.zip
Fixed Ordering::Acquire -> Ordering::SeqCst typo
Diffstat (limited to 'src')
-rw-r--r--src/platform/dummy/bind.rs2
-rw-r--r--src/platform/dummy/tun.rs8
-rw-r--r--src/wireguard/tests.rs2
-rw-r--r--src/wireguard/timers.rs8
4 files changed, 12 insertions, 8 deletions
diff --git a/src/platform/dummy/bind.rs b/src/platform/dummy/bind.rs
index 5010597..984b886 100644
--- a/src/platform/dummy/bind.rs
+++ b/src/platform/dummy/bind.rs
@@ -7,7 +7,7 @@ use std::sync::Arc;
use std::sync::Mutex;
use super::super::bind::*;
-use super::super::Endpoint;
+
use super::UnitEndpoint;
pub struct VoidOwner {}
diff --git a/src/platform/dummy/tun.rs b/src/platform/dummy/tun.rs
index 9fe9480..fb87d2f 100644
--- a/src/platform/dummy/tun.rs
+++ b/src/platform/dummy/tun.rs
@@ -1,3 +1,4 @@
+use std::cmp::min;
use std::error::Error;
use std::fmt;
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -84,9 +85,10 @@ impl Reader for TunReader {
fn read(&self, buf: &mut [u8], offset: usize) -> Result<usize, Self::Error> {
match self.rx.recv() {
- Ok(m) => {
- buf[offset..].copy_from_slice(&m[..]);
- Ok(m.len())
+ Ok(msg) => {
+ let n = min(buf.len() - offset, msg.len());
+ buf[offset..offset + n].copy_from_slice(&msg[..n]);
+ Ok(n)
}
Err(_) => Err(TunError::Disconnected),
}
diff --git a/src/wireguard/tests.rs b/src/wireguard/tests.rs
index 0dc9296..7c87056 100644
--- a/src/wireguard/tests.rs
+++ b/src/wireguard/tests.rs
@@ -109,4 +109,6 @@ fn test_pure_wireguard() {
"192.168.2.20".parse().unwrap(), // src
"192.168.1.10".parse().unwrap(), // dst
);
+
+ fake1.write(packet_p1_to_p2);
}
diff --git a/src/wireguard/timers.rs b/src/wireguard/timers.rs
index 40717f8..5ebc746 100644
--- a/src/wireguard/timers.rs
+++ b/src/wireguard/timers.rs
@@ -100,7 +100,7 @@ impl <B: bind::Bind>PeerInner<B> {
*/
pub fn sent_handshake_initiation(&self) {
*self.last_handshake.lock() = SystemTime::now();
- self.handshake_queued.store(false, Ordering::Acquire);
+ self.handshake_queued.store(false, Ordering::SeqCst);
self.timers_any_authenticated_packet_traversal();
self.timers_any_authenticated_packet_sent();
}
@@ -150,8 +150,8 @@ impl Timers {
let peer = peer.clone();
runner.timer(move || {
info!(
- "Retrying handshake with {}, because we stopped hearing back after {} seconds",
- peer,
+ "Retrying handshake with {}, because we stopped hearing back after {} seconds",
+ peer,
(KEEPALIVE_TIMEOUT + REKEY_TIMEOUT).as_secs()
);
peer.new_handshake();
@@ -256,7 +256,7 @@ impl<T: tun::Tun, B: bind::Bind> Callbacks for Events<T, B> {
/* Called every time the router detects that a key is required,
* but no valid key-material is available for the particular peer.
- *
+ *
* The message is called continuously
* (e.g. for every packet that must be encrypted, until a key becomes available)
*/