diff --git a/gday/README.md b/gday/README.md new file mode 100644 index 0000000..e69de29 diff --git a/gday_contact_exchange_protocol/README.md b/gday_contact_exchange_protocol/README.md new file mode 100644 index 0000000..fe545dd --- /dev/null +++ b/gday_contact_exchange_protocol/README.md @@ -0,0 +1,32 @@ +# gday_contact_exchange_protocol + +This protocol lets two users exchange their public and (optionally) private socket addresses via a server. +On it's own, this crate doesn't do anything other than define a shared protocol, and functions to +send and receive messages of this protocol. + +## Process + +Using this protocol goes something like this: + +1. Peer A connects to a server via the internet + and requests a new room with `room_code` using [`ClientMsg::CreateRoom`]. + +2. The server replies to peer A with [`ServerMsg::RoomCreated`] or [`ServerMsg::ErrorRoomTaken`] + depending on if this `room_code` is in use. + +3. Peer A externally tells peer B their `room_code` (by phone call, text message, carrier pigeon, etc.). + +4. Both peers send this `room_code` and optionally their local/private socket addresses to the server + via [`ClientMsg::SendAddr`] messages. The server determines their public addresses from the internet connections. + The server replies with [`ServerMsg::ReceivedAddr`] after each of these messages. + +5. Both peers send [`ClientMsg::DoneSending`] once they are ready to receive the contact info of each other. + +6. The server immediately replies to [`ClientMsg::DoneSending`] + with [`ServerMsg::ClientContact`] which contains the [`FullContact`] of this peer. + +7. Once both peers are ready, the server sends (on the same stream where [`ClientMsg::DoneSending`] came from) + each peer [`ServerMsg::PeerContact`] which contains the [`FullContact`] of the other peer.. + +8. On their own, the peers use this info to connect directly to each other by using + [hole punching](https://en.wikipedia.org/wiki/Hole_punching_(networking)). diff --git a/gday_contact_exchange_protocol/src/lib.rs b/gday_contact_exchange_protocol/src/lib.rs index 6e2db68..58a0f15 100644 --- a/gday_contact_exchange_protocol/src/lib.rs +++ b/gday_contact_exchange_protocol/src/lib.rs @@ -29,6 +29,7 @@ //! 8. On their own, the peers use this info to connect directly to each other by using //! [hole punching](https://en.wikipedia.org/wiki/Hole_punching_(networking)). //! +#![doc = include_str!("../README.md")] #![forbid(unsafe_code)] #![warn(clippy::all)] diff --git a/gday_encryption/README.md b/gday_encryption/README.md new file mode 100644 index 0000000..e69de29 diff --git a/gday_encryption/benches/benchmark.rs b/gday_encryption/benches/benchmark.rs index 7b911b2..8064d72 100644 --- a/gday_encryption/benches/benchmark.rs +++ b/gday_encryption/benches/benchmark.rs @@ -16,11 +16,11 @@ pub fn encryption_bench(c: &mut Criterion) { rng.fill_bytes(&mut key); // generate random encrypted data - let mut random_data = vec![0; 10_000_000]; + let mut random_data = vec![0; 1_000_000]; rng.fill_bytes(&mut random_data); - let mut encrypted_data = vec![0; 20_000_000]; + let mut encrypted_data = vec![0; 2_000_000]; - c.bench_function("EncryptedStream write 10,000,000 bytes", |b| { + c.bench_function("EncryptedStream write 1,000,000 bytes", |b| { b.iter(|| { let mut encryptor: EncryptedStream<&mut [u8]> = EncryptedStream::new(&mut encrypted_data[..], &key, &nonce); @@ -40,7 +40,7 @@ pub fn decryption_bench(c: &mut Criterion) { rng.fill_bytes(&mut key); // generate random encrypted data - let mut random_data = vec![0; 10_000_000]; + let mut random_data = vec![0; 1_000_000]; rng.fill_bytes(&mut random_data); let mut encrypted_data = Vec::new(); let mut encryptor: EncryptedStream<&mut Vec> = @@ -49,9 +49,9 @@ pub fn decryption_bench(c: &mut Criterion) { encryptor.flush().unwrap(); // read this encrypted data - let mut read_data = vec![0; 10_000_000]; + let mut read_data = vec![0; 1_000_000]; - c.bench_function("EncryptedStream read 10,000,000 bytes", |b| { + c.bench_function("EncryptedStream read 1,000,000 bytes", |b| { b.iter(|| { let mut decryptor = EncryptedStream::new(&encrypted_data[..], &key, &nonce); EncryptedStream::read_exact(black_box(&mut decryptor), black_box(&mut read_data)) diff --git a/gday_encryption/src/test.rs b/gday_encryption/src/test.rs index b39255f..2b2805f 100644 --- a/gday_encryption/src/test.rs +++ b/gday_encryption/src/test.rs @@ -44,7 +44,7 @@ fn test_small_messages() { for msg in test_data { stream.write_all(msg).unwrap(); - stream.flush_write_buf().unwrap(); + stream.flush().unwrap(); let mut buf = vec![0; msg.len()]; stream.read_exact(&mut buf).unwrap(); assert_eq!(buf, msg[..]); diff --git a/gday_encryption_async/README.md b/gday_encryption_async/README.md new file mode 100644 index 0000000..e69de29 diff --git a/gday_file_offer_protocol/README.md b/gday_file_offer_protocol/README.md new file mode 100644 index 0000000..e69de29 diff --git a/gday_hole_punch/README.md b/gday_hole_punch/README.md new file mode 100644 index 0000000..e69de29 diff --git a/gday_server/README.md b/gday_server/README.md new file mode 100644 index 0000000..e69de29