aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-27 22:30:24 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-27 22:30:24 +0200
commita1b50aca26345756e79702b7039abf04eac7983c (patch)
treeeb917eb9767119397554587f665329f588ef24cd /src
parentUse confirmation status from keypair in dec-state (diff)
downloadwireguard-rs-a1b50aca26345756e79702b7039abf04eac7983c.tar.xz
wireguard-rs-a1b50aca26345756e79702b7039abf04eac7983c.zip
Add confirm_key stub
Diffstat (limited to 'src')
-rw-r--r--src/router/peer.rs10
-rw-r--r--src/router/workers.rs12
2 files changed, 16 insertions, 6 deletions
diff --git a/src/router/peer.rs b/src/router/peer.rs
index 9460f16..9451b2c 100644
--- a/src/router/peer.rs
+++ b/src/router/peer.rs
@@ -204,6 +204,16 @@ pub fn new_peer<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<T>>(
Peer(peer)
}
+impl<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<T>> PeerInner<T, S, R, K> {
+ pub fn confirm_key(&self, kp: Weak<KeyPair>) {
+ // upgrade key-pair to strong reference
+
+ // check it is the new unconfirmed key
+
+ // rotate key-wheel
+ }
+}
+
impl<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<T>> Peer<T, S, R, K> {
fn new(inner: PeerInner<T, S, R, K>) -> Peer<T, S, R, K> {
Peer(Arc::new(inner))
diff --git a/src/router/workers.rs b/src/router/workers.rs
index 98074e7..320f6a1 100644
--- a/src/router/workers.rs
+++ b/src/router/workers.rs
@@ -100,7 +100,7 @@ pub fn worker_inbound<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<
None => (),
Some(buf) => match buf.status {
Status::Done => {
- // cast
+ // parse / cast
let (header, packet) =
match LayoutVerified::new_from_prefix(&buf.msg[..]) {
Some(v) => v,
@@ -121,11 +121,11 @@ pub fn worker_inbound<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<
}
// check for confirms key
- if state.confirmed.swap(true, Ordering::SeqCst) {
- // TODO: confirm key
+ if !state.confirmed.swap(true, Ordering::SeqCst) {
+ peer.confirm_key(state.keypair.clone());
}
- // write packet to TUN device
+ // write packet to TUN device, TODO
// trigger callback
debug_assert!(
@@ -166,7 +166,7 @@ pub fn worker_outbound<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback
None => (),
Some(buf) => match buf.status {
Status::Done => {
- // cast
+ // parse / cast
let (header, packet) =
match LayoutVerified::new_from_prefix(&buf.msg[..]) {
Some(v) => v,
@@ -174,7 +174,7 @@ pub fn worker_outbound<T: Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback
};
let header: LayoutVerified<&[u8], TransportHeader> = header;
- // write to UDP device
+ // write to UDP device, TODO
let xmit = false;
// trigger callback