From b8540b25aa328e4e4c77a82f938570d756dbcde4 Mon Sep 17 00:00:00 2001 From: jmwample <8297368+jmwample@users.noreply.github.com> Date: Wed, 15 May 2024 21:42:18 -0600 Subject: [PATCH 1/2] move passthrough to examples in ptrs and outline others --- crates/ptrs/examples/README.md | 16 ++++++++++++++++ crates/ptrs/{src => examples}/passthrough.rs | 15 ++++++++++++--- crates/ptrs/examples/split.rs | 0 crates/ptrs/examples/udp.rs | 0 crates/ptrs/src/lib.rs | 3 --- 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 crates/ptrs/examples/README.md rename crates/ptrs/{src => examples}/passthrough.rs (98%) create mode 100644 crates/ptrs/examples/split.rs create mode 100644 crates/ptrs/examples/udp.rs diff --git a/crates/ptrs/examples/README.md b/crates/ptrs/examples/README.md new file mode 100644 index 0000000..d6c4995 --- /dev/null +++ b/crates/ptrs/examples/README.md @@ -0,0 +1,16 @@ + +# Minimal Example Transports. + + +**Passthrough** - Does nothing but forward traffic. + + +**Split** - (TODO) There's no protocol obfuscation, no +encryption, but the link between the client and server uses *two* TCP +connections, both of which are unidirectional: one is used only for +upstream and the other is used only for downstream. The server listens +on two ports, and when the client connects, it connects to both ports. + + +**UDP** - (TODO) Demonstrate that the ptrs model works for transports wrapping +unreliable channels (if they are designed to be). diff --git a/crates/ptrs/src/passthrough.rs b/crates/ptrs/examples/passthrough.rs similarity index 98% rename from crates/ptrs/src/passthrough.rs rename to crates/ptrs/examples/passthrough.rs index 003b0e1..6026ae0 100644 --- a/crates/ptrs/src/passthrough.rs +++ b/crates/ptrs/examples/passthrough.rs @@ -1,4 +1,13 @@ -use super::*; +use ptrs::{ + args, ClientBuilder, ClientTransport, FutureResult as F, PluggableTransport, ServerBuilder, + ServerTransport, +}; + +use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::time::Duration; + +use std::net::{SocketAddrV4, SocketAddrV6}; +use std::pin::Pin; pub struct Passthrough {} @@ -166,7 +175,7 @@ impl Passthrough { #[cfg(test)] mod design_tests { - use crate::info; + use ptrs::info; use tokio::{ io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}, net::TcpStream, @@ -180,7 +189,7 @@ mod design_tests { use std::time::Duration; use super::{BuilderC, BuilderS, Passthrough}; - use crate::{ + use ptrs::{ ClientBuilder, ClientTransport, FutureResult, diff --git a/crates/ptrs/examples/split.rs b/crates/ptrs/examples/split.rs new file mode 100644 index 0000000..e69de29 diff --git a/crates/ptrs/examples/udp.rs b/crates/ptrs/examples/udp.rs new file mode 100644 index 0000000..e69de29 diff --git a/crates/ptrs/src/lib.rs b/crates/ptrs/src/lib.rs index e80cee8..7d55ca8 100644 --- a/crates/ptrs/src/lib.rs +++ b/crates/ptrs/src/lib.rs @@ -237,6 +237,3 @@ pub(crate) type F = FutureResult; pub type TcpStreamFut = Pin>; pub type UdpSocketFut = Pin>; - -#[cfg(test)] -mod passthrough; From 3f8a341d7bc462cf6a09aeefcc3b0e8bb0b5379a Mon Sep 17 00:00:00 2001 From: jmwample <8297368+jmwample@users.noreply.github.com> Date: Mon, 1 Jul 2024 07:40:07 -0600 Subject: [PATCH 2/2] fix clippy and fmt complaints --- crates/ptrs/examples/{passthrough.rs => passthrough/lib.rs} | 1 + crates/ptrs/examples/split.rs | 3 +++ crates/ptrs/examples/udp.rs | 3 +++ 3 files changed, 7 insertions(+) rename crates/ptrs/examples/{passthrough.rs => passthrough/lib.rs} (99%) diff --git a/crates/ptrs/examples/passthrough.rs b/crates/ptrs/examples/passthrough/lib.rs similarity index 99% rename from crates/ptrs/examples/passthrough.rs rename to crates/ptrs/examples/passthrough/lib.rs index 6026ae0..97ead65 100644 --- a/crates/ptrs/examples/passthrough.rs +++ b/crates/ptrs/examples/passthrough/lib.rs @@ -836,3 +836,4 @@ mod design_tests { Ok(()) } } + diff --git a/crates/ptrs/examples/split.rs b/crates/ptrs/examples/split.rs index e69de29..26fd1b0 100644 --- a/crates/ptrs/examples/split.rs +++ b/crates/ptrs/examples/split.rs @@ -0,0 +1,3 @@ +fn main() { + todo!("example under construction"); +} diff --git a/crates/ptrs/examples/udp.rs b/crates/ptrs/examples/udp.rs index e69de29..26fd1b0 100644 --- a/crates/ptrs/examples/udp.rs +++ b/crates/ptrs/examples/udp.rs @@ -0,0 +1,3 @@ +fn main() { + todo!("example under construction"); +}