Upgrade hyper-reverse-proxy to fix websocket forwarding
This commit is contained in:
parent
56796e91b8
commit
71c9b8dbf5
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -1051,8 +1051,9 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper-reverse-proxy"
|
name = "hyper-reverse-proxy"
|
||||||
version = "0.5.2-dev"
|
version = "0.5.2-dev"
|
||||||
source = "git+https://code.betamike.com/micropelago/hyper-reverse-proxy.git?branch=master#1dc4618994a5e9bc5de2083b911b1b08da7c081f"
|
source = "git+https://code.betamike.com/micropelago/hyper-reverse-proxy.git?rev=1a9e3430dd7a9d3579ebe183abed6596a414c5bf#1a9e3430dd7a9d3579ebe183abed6596a414c5bf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"http-body-util",
|
||||||
"hyper 1.2.0",
|
"hyper 1.2.0",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
12
Cargo.toml
12
Cargo.toml
@ -3,8 +3,6 @@ name = "domani"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3.7"
|
tempdir = "0.3.7"
|
||||||
|
|
||||||
@ -37,7 +35,6 @@ log = "0.4.19"
|
|||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
serde_yaml = "0.9.22"
|
serde_yaml = "0.9.22"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
hyper-reverse-proxy = "0.5.2-dev"
|
|
||||||
gemini = "0.0.5"
|
gemini = "0.0.5"
|
||||||
bytes = "1.4.0"
|
bytes = "1.4.0"
|
||||||
gix-hash = "0.14.1"
|
gix-hash = "0.14.1"
|
||||||
@ -49,11 +46,14 @@ http-body-util = "0.1.0"
|
|||||||
http-body = "1.0.0"
|
http-body = "1.0.0"
|
||||||
awaitgroup = "0.7.0"
|
awaitgroup = "0.7.0"
|
||||||
|
|
||||||
|
# The micropelago fork of hyper-reverse-proxy supports hyper v1, and fixes some
|
||||||
|
# bugs from upstream (which appears to be unmaintained).
|
||||||
|
[dependencies.hyper-reverse-proxy]
|
||||||
|
git = "https://code.betamike.com/micropelago/hyper-reverse-proxy.git"
|
||||||
|
rev = "1a9e3430dd7a9d3579ebe183abed6596a414c5bf"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
|
||||||
# The micropelago fork of tokio-rustls allows for gemini proxying
|
# The micropelago fork of tokio-rustls allows for gemini proxying
|
||||||
tokio-rustls = { git = "https://code.betamike.com/micropelago/tokio-rustls.git", branch = "start-handshake-into-inner" }
|
tokio-rustls = { git = "https://code.betamike.com/micropelago/tokio-rustls.git", branch = "start-handshake-into-inner" }
|
||||||
|
|
||||||
# The micropelago fork of hyper-reverse-proxy supports hyper v1, and fixes some
|
|
||||||
# bugs from upstream (which appears to be unmaintained).
|
|
||||||
hyper-reverse-proxy = { git = "https://code.betamike.com/micropelago/hyper-reverse-proxy.git", branch = "master" }
|
|
||||||
|
@ -205,6 +205,10 @@
|
|||||||
toolchain = mkToolchain buildSystem targetSystem;
|
toolchain = mkToolchain buildSystem targetSystem;
|
||||||
in
|
in
|
||||||
pkgs.mkShell ({
|
pkgs.mkShell ({
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.nmap
|
||||||
|
pkgs.websocat
|
||||||
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export CARGO_HOME=$(pwd)/.cargo
|
export CARGO_HOME=$(pwd)/.cargo
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ pub fn new_client() -> Client {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResponseBody = http_body_util::combinators::UnsyncBoxBody<hyper::body::Bytes, std::io::Error>;
|
||||||
|
|
||||||
pub async fn serve_http_request(
|
pub async fn serve_http_request(
|
||||||
proxy_client: &Client,
|
proxy_client: &Client,
|
||||||
proxy_addr: &str,
|
proxy_addr: &str,
|
||||||
@ -22,7 +24,7 @@ pub async fn serve_http_request(
|
|||||||
client_ip: net::IpAddr,
|
client_ip: net::IpAddr,
|
||||||
mut req: hyper::Request<Incoming>,
|
mut req: hyper::Request<Incoming>,
|
||||||
req_is_https: bool,
|
req_is_https: bool,
|
||||||
) -> unexpected::Result<hyper::Response<Incoming>> {
|
) -> unexpected::Result<hyper::Response<ResponseBody>> {
|
||||||
for (name, value) in headers {
|
for (name, value) in headers {
|
||||||
if value.is_empty() {
|
if value.is_empty() {
|
||||||
req.headers_mut().remove(name);
|
req.headers_mut().remove(name);
|
||||||
|
@ -13,7 +13,7 @@ async fn serve_conn<Conn>(
|
|||||||
remote_addr: net::SocketAddr,
|
remote_addr: net::SocketAddr,
|
||||||
req_is_https: bool,
|
req_is_https: bool,
|
||||||
) where
|
) where
|
||||||
Conn: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin + 'static,
|
Conn: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin + Send + 'static,
|
||||||
{
|
{
|
||||||
log::debug!("[{remote_addr}] Handling incoming connection (is_https:{req_is_https})");
|
log::debug!("[{remote_addr}] Handling incoming connection (is_https:{req_is_https})");
|
||||||
let service = crate::service::http::HyperServiceImpl::new(
|
let service = crate::service::http::HyperServiceImpl::new(
|
||||||
@ -39,7 +39,7 @@ async fn serve_conn<Conn>(
|
|||||||
.keep_alive_interval(Some(Duration::from_secs(10)))
|
.keep_alive_interval(Some(Duration::from_secs(10)))
|
||||||
.keep_alive_timeout(Duration::from_secs(5));
|
.keep_alive_timeout(Duration::from_secs(5));
|
||||||
|
|
||||||
let mut conn = pin::pin!(builder.serve_connection(TokioIo::new(conn), service));
|
let mut conn = pin::pin!(builder.serve_connection_with_upgrades(TokioIo::new(conn), service));
|
||||||
|
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
res = conn.as_mut() => {
|
res = conn.as_mut() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user