From 65a173238ca679cc2fa2a70f425d11d946513ea0 Mon Sep 17 00:00:00 2001 From: glendc Date: Sun, 16 Jun 2024 22:44:43 +0200 Subject: [PATCH] start to lay the structure of the forwarded code --- src/net/forwarded/entry.rs | 9 +++++++++ src/net/forwarded/mod.rs | 22 ++++++++++++++++++++++ src/net/forwarded/node/mod.rs | 12 ++++++++++++ src/net/forwarded/node/name.rs | 8 ++++++++ src/net/forwarded/node/port.rs | 6 ++++++ src/net/forwarded/obfuscated.rs | 1 + src/net/mod.rs | 1 + 7 files changed, 59 insertions(+) create mode 100644 src/net/forwarded/entry.rs create mode 100644 src/net/forwarded/mod.rs create mode 100644 src/net/forwarded/node/mod.rs create mode 100644 src/net/forwarded/node/name.rs create mode 100644 src/net/forwarded/node/port.rs create mode 100644 src/net/forwarded/obfuscated.rs diff --git a/src/net/forwarded/entry.rs b/src/net/forwarded/entry.rs new file mode 100644 index 00000000..cee8cf2b --- /dev/null +++ b/src/net/forwarded/entry.rs @@ -0,0 +1,9 @@ +use super::Node; +use crate::net::{address::Authority, Protocol}; + +pub struct ForwardedEntry { + by_node: Option, + for_node: Option, + host: Option, + proto: Option, +} diff --git a/src/net/forwarded/mod.rs b/src/net/forwarded/mod.rs new file mode 100644 index 00000000..e80dcbe1 --- /dev/null +++ b/src/net/forwarded/mod.rs @@ -0,0 +1,22 @@ +//! rama support for the "Forwarded HTTP Extension" +//! +//! RFC: + +use super::{address::Authority, Protocol}; +use std::net::IpAddr; + +mod obfuscated; +#[doc(inline)] +pub use obfuscated::ObfuscatedString; + +mod node; +#[doc(inline)] +pub use node::{Node, NodeName, NodePort}; + +mod entry; +#[doc(inline)] +pub use entry::ForwardedEntry; + +pub struct Forwarded { + entries: Vec, +} diff --git a/src/net/forwarded/node/mod.rs b/src/net/forwarded/node/mod.rs new file mode 100644 index 00000000..342e081a --- /dev/null +++ b/src/net/forwarded/node/mod.rs @@ -0,0 +1,12 @@ +mod name; +#[doc(inline)] +pub use name::NodeName; + +mod port; +#[doc(inline)] +pub use port::NodePort; + +pub struct Node { + name: NodeName, + port: Option, +} diff --git a/src/net/forwarded/node/name.rs b/src/net/forwarded/node/name.rs new file mode 100644 index 00000000..a040374d --- /dev/null +++ b/src/net/forwarded/node/name.rs @@ -0,0 +1,8 @@ +use crate::net::forwarded::ObfuscatedString; +use std::net::IpAddr; + +pub enum NodeName { + Unknown, + Ip(IpAddr), + ObfNode(ObfuscatedString), +} diff --git a/src/net/forwarded/node/port.rs b/src/net/forwarded/node/port.rs new file mode 100644 index 00000000..2d0ff214 --- /dev/null +++ b/src/net/forwarded/node/port.rs @@ -0,0 +1,6 @@ +use crate::net::forwarded::ObfuscatedString; + +pub enum NodePort { + Port(u16), + ObfPort(ObfuscatedString), +} diff --git a/src/net/forwarded/obfuscated.rs b/src/net/forwarded/obfuscated.rs new file mode 100644 index 00000000..fdabc162 --- /dev/null +++ b/src/net/forwarded/obfuscated.rs @@ -0,0 +1 @@ +pub struct ObfuscatedString(String); diff --git a/src/net/mod.rs b/src/net/mod.rs index 7bef6f3a..12e0c185 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -1,6 +1,7 @@ //! protocol agnostic network modules pub mod address; +pub mod forwarded; pub mod stream; pub mod user;