diff --git a/README.md b/README.md
index fc84364..86863c2 100644
--- a/README.md
+++ b/README.md
@@ -32,11 +32,25 @@ Coming soon.
Coming soon.
-# Building
+## Building
-The wireguard-rs project is targeting the current nightly.
-To build this project obtain nightly `cargo` and `rustc` through [rustup](https://rustup.rs/), then simply run:
+The wireguard-rs project is targeting the current nightly (although it should also build with stable Rust).
- cargo build --release
+To build wireguard-rs (on supported platforms):
-To compile wireguard-rs to your current platform.
+1. Obtain nightly `cargo` and `rustc` through [rustup](https://rustup.rs/)
+2. Clone the repository: `git clone https://git.zx2c4.com/wireguard-rs`.
+3. Run `cargo build --release` from inside the `wireguard-rs` directory.
+
+## Architecture
+
+This section is intended for those wishing to read/contribute to the code.
+
+WireGuard Rust has a similar separation of concerns as many other implementations of various cryptographic transports:
+separating the handshake code from the packet protector.
+The handshake module implements an authenticated key-exchange (NoiseIK),
+which provides key-material, which is then consumed by the router module (packet protector)
+responsible for the actual encapsulation of transport messages (IP packets).
+This is illustrated below:
+
+
diff --git a/architecture.svg b/architecture.svg
new file mode 100644
index 0000000..f62ca07
--- /dev/null
+++ b/architecture.svg
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/wireguard/router/device.rs b/src/wireguard/router/device.rs
index 7c90f22..1a12abb 100644
--- a/src/wireguard/router/device.rs
+++ b/src/wireguard/router/device.rs
@@ -26,31 +26,29 @@ use super::ParallelQueue;
pub struct DeviceInner> {
// inbound writer (TUN)
- pub inbound: T,
+ pub(super) inbound: T,
// outbound writer (Bind)
- pub outbound: RwLock<(bool, Option)>,
+ pub(super) outbound: RwLock<(bool, Option)>,
// routing
- pub recv: RwLock>>>, // receiver id -> decryption state
- pub table: RoutingTable>,
+ pub(super) recv: RwLock>>>, // receiver id -> decryption state
+ pub(super) table: RoutingTable>,
// work queue
- pub work: ParallelQueue>,
+ pub(super) work: ParallelQueue>,
}
pub struct EncryptionState {
- pub keypair: Arc, // keypair
- pub nonce: u64, // next available nonce
- pub death: Instant, // (birth + reject-after-time - keepalive-timeout - rekey-timeout)
+ pub(super) keypair: Arc, // keypair
+ pub(super) nonce: u64, // next available nonce
}
pub struct DecryptionState> {
- pub keypair: Arc,
- pub confirmed: AtomicBool,
- pub protector: Mutex,
- pub peer: Peer,
- pub death: Instant, // time when the key can no longer be used for decryption
+ pub(super) keypair: Arc,
+ pub(super) confirmed: AtomicBool,
+ pub(super) protector: Mutex,
+ pub(super) peer: Peer,
}
pub struct Device> {
diff --git a/src/wireguard/router/peer.rs b/src/wireguard/router/peer.rs
index 8248a55..d960da0 100644
--- a/src/wireguard/router/peer.rs
+++ b/src/wireguard/router/peer.rs
@@ -37,16 +37,22 @@ pub struct KeyWheel {
}
pub struct PeerInner> {
- pub device: Device,
- pub opaque: C::Opaque,
- pub outbound: Queue>,
- pub inbound: Queue>,
- pub staged_packets: Mutex; MAX_QUEUED_PACKETS], Wrapping>>,
- pub keys: Mutex,
- pub enc_key: Mutex