diff --git a/Cargo.lock b/Cargo.lock index af842dc..bfc3a13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1241,8 +1241,8 @@ dependencies = [ "futures-util", "hex", "ptth_file_server", + "ptth_quic", "ptth_server", - "quic_demo", "rand", "reqwest", "rusty_ulid", @@ -1252,6 +1252,26 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "ptth_quic" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64", + "ctrlc", + "futures-util", + "hyper", + "quinn", + "rand", + "rcgen", + "reqwest", + "rmp-serde", + "structopt", + "tokio", + "tracing", + "tracing-subscriber", +] + [[package]] name = "ptth_quic_client_gui" version = "0.1.0" @@ -1259,7 +1279,7 @@ dependencies = [ "anyhow", "blake3", "fltk", - "quic_demo", + "ptth_quic", "quinn", "rand", "rand_chacha", @@ -1379,26 +1399,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "quic_demo" -version = "0.1.0" -dependencies = [ - "anyhow", - "base64", - "ctrlc", - "futures-util", - "hyper", - "quinn", - "rand", - "rcgen", - "reqwest", - "rmp-serde", - "structopt", - "tokio", - "tracing", - "tracing-subscriber", -] - [[package]] name = "quick-error" version = "2.0.1" diff --git a/Dockerfile b/Dockerfile index 76e46c5..06e0c7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ cargo new --bin crates/ptth_server && \ cargo new --bin crates/ptth_file_server_bin && \ cargo new --bin tools/ptth_tail && \ cargo new --bin crates/debug_proxy && \ -cargo new --bin prototypes/quic_demo +cargo new --bin crates/ptth_quic # copy over your manifests COPY ./Cargo.lock ./ @@ -28,7 +28,7 @@ COPY ./Cargo.toml ./ COPY ./crates/always_equal/Cargo.toml ./crates/always_equal/ COPY ./crates/ptth_core/Cargo.toml ./crates/ptth_core/ COPY ./crates/ptth_relay/Cargo.toml ./crates/ptth_relay/ -COPY ./prototypes/quic_demo/Cargo.toml ./prototypes/quic_demo/ +COPY ./crates/ptth_quic/Cargo.toml ./crates/ptth_quic/ # this build step will cache your dependencies RUN cargo build --release -p ptth_relay @@ -39,7 +39,7 @@ src/*.rs \ crates/always_equal/src/*.rs \ crates/ptth_core/src/*.rs \ crates/ptth_relay/src/*.rs \ -prototypes/quic_demo/src/*.rs +crates/ptth_quic/src/*.rs # Copy source tree # Yes, I tried a few variations on the syntax. Dockerfiles are just rough. @@ -49,7 +49,7 @@ COPY ./crates/always_equal ./crates/always_equal COPY ./crates/ptth_core ./crates/ptth_core COPY ./crates/ptth_relay ./crates/ptth_relay COPY ./handlebars/ ./handlebars -COPY ./prototypes/quic_demo ./prototypes/quic_demo +COPY ./crates/ptth_quic ./crates/ptth_quic # Bug in cargo's incremental build logic, triggered by # Docker doing something funny with mtimes? Maybe? diff --git a/crates/ptth_multi_call_server/Cargo.toml b/crates/ptth_multi_call_server/Cargo.toml index 2d22662..0ecf898 100644 --- a/crates/ptth_multi_call_server/Cargo.toml +++ b/crates/ptth_multi_call_server/Cargo.toml @@ -18,7 +18,7 @@ futures-util = "0.3.9" hex = "0.4.3" ptth_file_server = { path = "../ptth_file_server_bin" } ptth_server = { path = "../ptth_server" } -quic_demo = { path = "../ptth_quic" } +ptth_quic = { path = "../ptth_quic" } rand = "0.8.4" rusty_ulid = "0.10.1" sha2 = "0.9.8" diff --git a/crates/ptth_multi_call_server/src/main.rs b/crates/ptth_multi_call_server/src/main.rs index 57514f2..5dd35ea 100644 --- a/crates/ptth_multi_call_server/src/main.rs +++ b/crates/ptth_multi_call_server/src/main.rs @@ -43,7 +43,7 @@ async fn main () -> anyhow::Result <()> { shutdown_tx.send (true).expect ("Couldn't forward Ctrl+C signal"); })?; tracing::trace! ("Set Ctrl+C handler"); - quic_demo::executable_end_server::main (args, Some (shutdown_rx)).await?; + ptth_quic::executable_end_server::main (args, Some (shutdown_rx)).await?; Ok (()) } diff --git a/crates/ptth_quic/Cargo.toml b/crates/ptth_quic/Cargo.toml index 2ad6ff2..017f5ee 100644 --- a/crates/ptth_quic/Cargo.toml +++ b/crates/ptth_quic/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "quic_demo" +name = "ptth_quic" version = "0.1.0" authors = ["Trish"] edition = "2018" diff --git a/crates/ptth_quic/Dockerfile b/crates/ptth_quic/Dockerfile index 11b38a4..a0964fd 100644 --- a/crates/ptth_quic/Dockerfile +++ b/crates/ptth_quic/Dockerfile @@ -20,7 +20,7 @@ cargo new --bin crates/ptth_server && \ cargo new --bin crates/ptth_file_server_bin && \ cargo new --bin tools/ptth_tail && \ cargo new --bin crates/debug_proxy && \ -cargo new --bin prototypes/quic_demo +cargo new --bin crates/ptth_quic # copy over your manifests COPY ./Cargo.lock ./ @@ -28,10 +28,10 @@ COPY ./Cargo.toml ./ COPY ./crates/always_equal/Cargo.toml ./crates/always_equal/ COPY ./crates/ptth_core/Cargo.toml ./crates/ptth_core/ COPY ./crates/ptth_relay/Cargo.toml ./crates/ptth_relay/ -COPY ./prototypes/quic_demo/Cargo.toml ./prototypes/quic_demo/ +COPY ./crates/ptth_quic/Cargo.toml ./crates/ptth_quic/ # this build step will cache your dependencies -RUN cargo build --release -p quic_demo +RUN cargo build --release -p ptth_quic RUN \ rm \ @@ -39,7 +39,7 @@ src/*.rs \ crates/always_equal/src/*.rs \ crates/ptth_core/src/*.rs \ crates/ptth_relay/src/*.rs \ -prototypes/quic_demo/src/*.rs +crates/ptth_quic/src/*.rs # Copy source tree # Yes, I tried a few variations on the syntax. Dockerfiles are just rough. @@ -49,7 +49,7 @@ COPY ./crates/always_equal ./crates/always_equal COPY ./crates/ptth_core ./crates/ptth_core COPY ./crates/ptth_relay ./crates/ptth_relay COPY ./handlebars/ ./handlebars -COPY ./prototypes/quic_demo ./prototypes/quic_demo +COPY ./crates/ptth_quic ./crates/ptth_quic # Bug in cargo's incremental build logic, triggered by # Docker doing something funny with mtimes? Maybe? @@ -58,8 +58,8 @@ RUN touch crates/ptth_core/src/lib.rs # build for release # gate only on ptth_relay tests for now RUN \ -cargo build --release -p quic_demo --bin quic_demo_relay_server && \ -cargo test --release -p quic_demo --bin quic_demo_relay_server +cargo build --release -p ptth_quic --bin ptth_quic_relay_server && \ +cargo test --release -p ptth_quic --bin ptth_quic_relay_server # debian:buster-slim FROM debian@sha256:13f0764262a064b2dd9f8a828bbaab29bdb1a1a0ac6adc8610a0a5f37e514955 @@ -73,11 +73,11 @@ RUN addgroup --gid 10001 ptth_user && adduser --system --uid 10000 --gid 10001 p USER ptth_user WORKDIR /home/ptth_user -COPY --from=build /ptth/target/release/quic_demo_relay_server ./ +COPY --from=build /ptth/target/release/ptth_quic_relay_server ./ ARG git_version RUN \ echo -n "$git_version" > ./git_version.txt && \ -ln -s quic_demo_relay_server app +ln -s ptth_quic_relay_server app -CMD ["/usr/bin/tini", "--", "./quic_demo_relay_server"] +CMD ["/usr/bin/tini", "--", "./ptth_quic_relay_server"] diff --git a/crates/ptth_quic/README.md b/crates/ptth_quic/README.md index eed3171..b5828f5 100644 --- a/crates/ptth_quic/README.md +++ b/crates/ptth_quic/README.md @@ -3,9 +3,9 @@ There are 5 processes, so you'll need 5 terminal windows or screen / tmux sessions. Run the processes in this order: -1. QUIC relay server: `RUST_LOG=quic_demo_relay_server=debug cargo run --bin quic_demo_relay_server` -2. Server-side proxy: `RUST_LOG=quic_demo_end_server=debug cargo run --bin quic_demo_end_server` -3. Client-side proxy: `RUST_LOG=quic_demo_client cargo run --bin quic_demo_client` +1. QUIC relay server: `RUST_LOG=ptth_quic_relay_server=debug cargo run --bin ptth_quic_relay_server` +2. Server-side proxy: `RUST_LOG=ptth_quic_end_server=debug cargo run --bin ptth_quic_end_server` +3. Client-side proxy: `RUST_LOG=ptth_quic_client cargo run --bin ptth_quic_client` 4. TCP end server: `nc -l -p 30382` 5. TCP end client: `nc 127.0.0.1 30381` diff --git a/crates/ptth_quic/build_app_package.bash b/crates/ptth_quic/build_app_package.bash index f396d81..32df073 100755 --- a/crates/ptth_quic/build_app_package.bash +++ b/crates/ptth_quic/build_app_package.bash @@ -9,12 +9,12 @@ DOCKER_TAG="ptth_quic:latest" mkdir -p app_packages -git archive --format=tar "$GIT_COMMIT" | docker build -f prototypes/quic_demo/Dockerfile -t "$DOCKER_TAG" --build-arg "git_version=$GIT_COMMIT" - +git archive --format=tar "$GIT_COMMIT" | docker build -f crates/ptth_quic/Dockerfile -t "$DOCKER_TAG" --build-arg "git_version=$GIT_COMMIT" - docker run --rm "$DOCKER_TAG" \ tar -c \ app \ -quic_demo_relay_server \ +ptth_quic_relay_server \ | gzip > "app_packages/ptth_quic_relay_$GIT_COMMIT_SHORT.tar.gz" # sudo docker build -f app_package_Dockerfile -t ptth_app_host:latest . diff --git a/crates/ptth_quic/src/bin/quic_demo_client.rs b/crates/ptth_quic/src/bin/ptth_quic_client.rs similarity index 99% rename from crates/ptth_quic/src/bin/quic_demo_client.rs rename to crates/ptth_quic/src/bin/ptth_quic_client.rs index a015744..ab38277 100644 --- a/crates/ptth_quic/src/bin/quic_demo_client.rs +++ b/crates/ptth_quic/src/bin/ptth_quic_client.rs @@ -4,7 +4,7 @@ use tokio::{ sync::watch, }; -use quic_demo::{ +use ptth_quic::{ client_proxy::{ ForwardingParams, forward_port, diff --git a/crates/ptth_quic/src/bin/quic_demo_end_server.rs b/crates/ptth_quic/src/bin/ptth_quic_end_server.rs similarity index 82% rename from crates/ptth_quic/src/bin/quic_demo_end_server.rs rename to crates/ptth_quic/src/bin/ptth_quic_end_server.rs index 6453666..bd0ffc8 100644 --- a/crates/ptth_quic/src/bin/quic_demo_end_server.rs +++ b/crates/ptth_quic/src/bin/ptth_quic_end_server.rs @@ -4,7 +4,7 @@ use std::{ use tokio::sync::watch; -use quic_demo::prelude::*; +use ptth_quic::prelude::*; #[tokio::main] async fn main () -> anyhow::Result <()> { @@ -19,5 +19,5 @@ async fn main () -> anyhow::Result <()> { })?; trace! ("Set Ctrl+C handler"); - quic_demo::executable_end_server::main (&args, Some (shutdown_rx)).await + ptth_quic::executable_end_server::main (&args, Some (shutdown_rx)).await } diff --git a/crates/ptth_quic/src/bin/quic_demo_relay_server.rs b/crates/ptth_quic/src/bin/ptth_quic_relay_server.rs similarity index 99% rename from crates/ptth_quic/src/bin/quic_demo_relay_server.rs rename to crates/ptth_quic/src/bin/ptth_quic_relay_server.rs index 11c6ad8..ac39619 100644 --- a/crates/ptth_quic/src/bin/quic_demo_relay_server.rs +++ b/crates/ptth_quic/src/bin/ptth_quic_relay_server.rs @@ -15,7 +15,7 @@ use tokio::{ sync::watch, }; -use quic_demo::prelude::*; +use ptth_quic::prelude::*; use protocol::PeerId; #[derive (Debug, StructOpt)] diff --git a/crates/ptth_quic_client_gui/Cargo.toml b/crates/ptth_quic_client_gui/Cargo.toml index 5dfc18e..f485ac0 100644 --- a/crates/ptth_quic_client_gui/Cargo.toml +++ b/crates/ptth_quic_client_gui/Cargo.toml @@ -11,7 +11,7 @@ license = "AGPL-3.0" anyhow = "1.0.38" blake3 = "1.0.0" fltk = "1.2.8" -quic_demo = { path = "../ptth_quic" } +ptth_quic = { path = "../ptth_quic" } quinn = "0.7.2" rand = "0.8.4" rand_chacha = "0.3.1" diff --git a/crates/ptth_quic_client_gui/src/main.rs b/crates/ptth_quic_client_gui/src/main.rs index b75907f..b48bf05 100644 --- a/crates/ptth_quic_client_gui/src/main.rs +++ b/crates/ptth_quic_client_gui/src/main.rs @@ -19,7 +19,7 @@ use rand::{ use structopt::StructOpt; use tokio::runtime::Runtime; -use quic_demo::{ +use ptth_quic::{ client_proxy::*, prelude::*, protocol::PeerId, diff --git a/docs/how-to/test-ptth-quic.md b/docs/how-to/test-ptth-quic.md index ff92c1f..0504ef3 100644 --- a/docs/how-to/test-ptth-quic.md +++ b/docs/how-to/test-ptth-quic.md @@ -2,12 +2,12 @@ ## Initial setup -- Open 3 terminals in `prototypes/quic_demo` -- Use `export RUST_LOG=quic_demo_relay_server=debug` to enable debug logging +- Open 3 terminals in `crates/ptth_quic` +- Use `export RUST_LOG=ptth_quic_relay_server=debug` to enable debug logging for the terminal that will run the relay server (P3) -- Use `export RUST_LOG=quic_demo_end_server=debug` for the terminal that +- Use `export RUST_LOG=ptth_quic_end_server=debug` for the terminal that will run the end server (P4) -- Use `export RUST_LOG=quic_demo_client=debug` for the terminal that +- Use `export RUST_LOG=ptth_quic_client=debug` for the terminal that will run the client (P2) When the relay server is running, use curl to get the list of connected @@ -15,10 +15,10 @@ end servers: `curl 127.0.0.1:4004` ## Test loop - Happy path -- Start a relay `cargo run --bin quic_demo_relay_server` +- Start a relay `cargo run --bin ptth_quic_relay_server` - Verify that the relay has no end servers connected -- Start an end server `cargo run --bin quic_demo_end_server -- --debug-echo` +- Start an end server `cargo run --bin ptth_quic_end_server -- --debug-echo` - Verify that the end server connected -- Start a client `cargo run --bin quic_demo_client` +- Start a client `cargo run --bin ptth_quic_client` - Connect to the client and verify that the debug echo server is running `nc 127.0.0.1 30381`