Skip to content

Commit

Permalink
wip: implemented hyper-1.0 for http/1.1 and http/2. todo: http/3 and …
Browse files Browse the repository at this point in the history
…backend handler
  • Loading branch information
junkurihara committed Nov 18, 2023
1 parent f3e8f84 commit b639e79
Show file tree
Hide file tree
Showing 24 changed files with 1,133 additions and 1,274 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[submodule "submodules/h3"]
path = submodules/h3
url = [email protected]:junkurihara/h3.git
[submodule "submodules/quinn"]
path = submodules/quinn
url = [email protected]:junkurihara/quinn.git
[submodule "submodules/s2n-quic"]
path = submodules/s2n-quic
url = [email protected]:junkurihara/s2n-quic.git
[submodule "submodules/rusty-http-cache-semantics"]
path = submodules/rusty-http-cache-semantics
url = [email protected]:junkurihara/rusty-http-cache-semantics.git
2 changes: 1 addition & 1 deletion rpxy-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["http3-quinn", "cache"]
default = ["http3-s2n", "cache"]
http3-quinn = ["rpxy-lib/http3-quinn"]
http3-s2n = ["rpxy-lib/http3-s2n"]
cache = ["rpxy-lib/cache"]
Expand Down
33 changes: 15 additions & 18 deletions rpxy-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["http3-quinn", "sticky-cookie", "cache"]
default = ["http3-s2n", "sticky-cookie", "cache"]
http3-quinn = ["quinn", "h3", "h3-quinn", "socket2"]
http3-s2n = ["h3", "s2n-quic", "s2n-quic-rustls", "s2n-quic-h3"]
sticky-cookie = ["base64", "sha2", "chrono"]
Expand All @@ -25,7 +25,7 @@ rustc-hash = "1.1.0"
bytes = "1.5.0"
derive_builder = "0.12.0"
futures = { version = "0.3.29", features = ["alloc", "async-await"] }
tokio = { version = "1.33.0", default-features = false, features = [
tokio = { version = "1.34.0", default-features = false, features = [
"net",
"rt-multi-thread",
"time",
Expand All @@ -41,39 +41,35 @@ anyhow = "1.0.75"
thiserror = "1.0.50"

# http and tls
hyper = { version = "0.14.27", default-features = false, features = [
"server",
"http1",
"http2",
"stream",
] }
http = "1.0.0"
http-body-util = "0.1.0"
hyper = { version = "1.0.1", default-features = false }
hyper-util = { version = "0.1.0", features = ["full"] }
hyper-rustls = { version = "0.24.2", default-features = false, features = [
"tokio-runtime",
"webpki-tokio",
"http1",
"http2",
] }
tokio-rustls = { version = "0.24.1", features = ["early-data"] }
rustls = { version = "0.21.8", default-features = false }
rustls = { version = "0.21.9", default-features = false }
webpki = "0.22.4"
x509-parser = "0.15.1"

# logging
tracing = { version = "0.1.40" }

# http/3
# quinn = { version = "0.9.3", optional = true }
quinn = { path = "../submodules/quinn/quinn", optional = true } # Tentative to support rustls-0.21
quinn = { version = "0.10.2", optional = true }
h3 = { path = "../submodules/h3/h3/", optional = true }
# h3-quinn = { path = "./h3/h3-quinn/", optional = true }
h3-quinn = { path = "../submodules/h3-quinn/", optional = true } # Tentative to support rustls-0.21
# for UDP socket wit SO_REUSEADDR when h3 with quinn
socket2 = { version = "0.5.5", features = ["all"], optional = true }
s2n-quic = { path = "../submodules/s2n-quic/quic/s2n-quic/", default-features = false, features = [
h3-quinn = { path = "../submodules/h3/h3-quinn/", optional = true }
s2n-quic = { version = "1.31.0", default-features = false, features = [
"provider-tls-rustls",
], optional = true }
s2n-quic-h3 = { path = "../submodules/s2n-quic/quic/s2n-quic-h3/", optional = true }
s2n-quic-rustls = { path = "../submodules/s2n-quic/quic/s2n-quic-rustls/", optional = true }
s2n-quic-h3 = { path = "../submodules/s2n-quic-h3/", optional = true }
s2n-quic-rustls = { version = "0.31.0", optional = true }
# for UDP socket wit SO_REUSEADDR when h3 with quinn
socket2 = { version = "0.5.5", features = ["all"], optional = true }

# cache
http-cache-semantics = { path = "../submodules/rusty-http-cache-semantics/", optional = true }
Expand All @@ -90,3 +86,4 @@ sha2 = { version = "0.10.8", default-features = false, optional = true }


[dev-dependencies]
# http and tls
3 changes: 3 additions & 0 deletions rpxy-lib/src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ where

/// Shared context - Async task runtime handler
pub runtime_handle: tokio::runtime::Handle,

/// Shared context - Notify object to stop async tasks
pub term_notify: Option<Arc<tokio::sync::Notify>>,
}

/// Configuration parameters for proxy transport and request handlers
Expand Down
16 changes: 16 additions & 0 deletions rpxy-lib/src/handler/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use http::StatusCode;
use thiserror::Error;

pub type HttpResult<T> = std::result::Result<T, HttpError>;

/// Describes things that can go wrong in the handler
#[derive(Debug, Error)]
pub enum HttpError {}

impl From<HttpError> for StatusCode {
fn from(e: HttpError) -> StatusCode {
match e {
_ => StatusCode::INTERNAL_SERVER_ERROR,
}
}
}
Loading

0 comments on commit b639e79

Please sign in to comment.