Skip to content

Commit

Permalink
start to lay the structure of the forwarded code
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenDC committed Jun 16, 2024
1 parent 9e033be commit 65a1732
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/net/forwarded/entry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use super::Node;
use crate::net::{address::Authority, Protocol};

pub struct ForwardedEntry {
by_node: Option<Node>,
for_node: Option<Node>,
host: Option<Authority>,
proto: Option<Protocol>,
}
22 changes: 22 additions & 0 deletions src/net/forwarded/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! rama support for the "Forwarded HTTP Extension"
//!
//! RFC: <https://datatracker.ietf.org/doc/html/rfc7239>

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<ForwardedEntry>,
}
12 changes: 12 additions & 0 deletions src/net/forwarded/node/mod.rs
Original file line number Diff line number Diff line change
@@ -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<NodePort>,
}
8 changes: 8 additions & 0 deletions src/net/forwarded/node/name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::net::forwarded::ObfuscatedString;
use std::net::IpAddr;

pub enum NodeName {
Unknown,
Ip(IpAddr),
ObfNode(ObfuscatedString),
}
6 changes: 6 additions & 0 deletions src/net/forwarded/node/port.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use crate::net::forwarded::ObfuscatedString;

pub enum NodePort {
Port(u16),
ObfPort(ObfuscatedString),
}
1 change: 1 addition & 0 deletions src/net/forwarded/obfuscated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub struct ObfuscatedString(String);
1 change: 1 addition & 0 deletions src/net/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! protocol agnostic network modules

pub mod address;
pub mod forwarded;
pub mod stream;
pub mod user;

Expand Down

0 comments on commit 65a1732

Please sign in to comment.