Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #1308

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
435 changes: 276 additions & 159 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ codegen-units = 1

[workspace.dependencies]
defer = "0.1.0"
env_logger = "0.10.0"
futures = "0.3.28"
env_logger = "0.10.2"
futures = "0.3.30"
gix = "0.54.1"
hyper-reverse-proxy = "0.5.1"
lazy_static = "1.4.0"
libc = "0.2.148"
regex = "1.9.5"
libc = "0.2.153"
regex = "1.10.3"
rs_tracing= { version = "1.1.0", features = ["rs_tracing"] }
serde = { version = "1.0.188", features = ["std", "derive"] }
serde_json = "1.0.107"
serde_yaml = "0.9.25"
toml = "0.8.1"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
serde = { version = "1.0.197", features = ["std", "derive"] }
serde_json = "1.0.114"
serde_yaml = "0.9.32"
toml = "0.8.10"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[workspace.dependencies.git2]
default-features = false
version = "0.18.1"
version = "0.18.2"

[workspace.dependencies.juniper]
version = "0.15.11"
version = "0.15.12"
default-features = false
features = ["expose-test-schema"]

[workspace.dependencies.tokio]
version = "1.32.0"
version = "1.36.0"
features = [
"fs",
"rt-multi-thread",
Expand All @@ -54,19 +54,19 @@ features = [
]

[workspace.dependencies.tokio-util]
version = "0.7.9"
version = "0.7.10"
features = ["compat"]

[workspace.dependencies.reqwest]
version = "0.11.20"
version = "0.11.25"
default-features = false
features = ["blocking", "json"]

[workspace.dependencies.tracing]
version = "0.1.37"
version = "0.1.40"
features = ["max_level_trace", "release_max_level_trace"]

[workspace.dependencies.clap]
version = "4.4.6"
version = "4.5.2"
features = ["derive", "help", "std", "usage"]
default-features = false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV PATH=/usr/local/cargo/bin:${PATH}

ARG ARCH
ARG RUSTUP_VERSION=1.26.0
ARG RUST_VERSION=1.74
ARG RUST_VERSION=1.75.0
ARG RUST_ARCH=${ARCH}-unknown-linux-musl

# https://github.com/sfackler/rust-openssl/issues/1462
Expand Down
10 changes: 7 additions & 3 deletions hyper_cgi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ repository = "https://github.com/josh-project/josh"
readme = "README.md"

[dependencies]
bytes = "1.5.0"
futures = { workspace = true }
tokio = { workspace = true }
tokio-util = { workspace = true }
hyper = { version = "0.14.27", features = ["stream", "tcp", "server", "http1"] }
hyper = { version = "1.2.0", features = ["server", "http1"] }
hyper-util = { version = "0.1.3" }
http-body = "1.0.0"
http-body-util = "0.1.0"

clap = { version = "4.4.6", optional = true }
base64 = { version = "0.21.4", optional = true }
clap = { version = "4.5.2", optional = true }
base64 = { version = "0.21.7", optional = true }
rand = { version = "0.8.5", optional = true, features = ["std"] }
lazy_static = { version = "1.4.0", optional = true }
hyper-reverse-proxy = { workspace = true }
Expand Down
76 changes: 46 additions & 30 deletions hyper_cgi/src/bin/hyper-cgi-test-server.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#[macro_use]
extern crate lazy_static;
use bytes::Bytes;
use core::iter;
use core::str::from_utf8;
use http_body_util::Full;
use hyper::server::conn::http1;
use hyper::service::service_fn;
use hyper_util::rt::{TokioIo, TokioTimer};
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use std::str::FromStr;
use std::net::SocketAddr;
use tokio::net::TcpListener;

use futures::FutureExt;

use hyper::server::Server;
use hyper::body::Incoming;

// Import the base64 crate Engine trait anonymously so we can
// call its methods without adding to the namespace.
Expand Down Expand Up @@ -44,7 +50,7 @@ pub struct ServerState {
users: Vec<(String, String)>,
}

pub fn parse_auth(req: &hyper::Request<hyper::Body>) -> Option<(String, String)> {
pub fn parse_auth(req: &hyper::Request<Incoming>) -> Option<(String, String)> {
let line = some_or!(
req.headers()
.get("authorization")
Expand All @@ -69,9 +75,9 @@ pub fn parse_auth(req: &hyper::Request<hyper::Body>) -> Option<(String, String)>
}

fn auth_response(
req: &hyper::Request<hyper::Body>,
req: &hyper::Request<Incoming>,
users: &Vec<(String, String)>,
) -> Option<hyper::Response<hyper::Body>> {
) -> Option<hyper::Response<Full<Bytes>>> {
if users.len() == 0 {
return None;
}
Expand All @@ -83,7 +89,7 @@ fn auth_response(
let builder = hyper::Response::builder()
.header("WWW-Authenticate", "Basic realm=User Visible Realm")
.status(hyper::StatusCode::UNAUTHORIZED);
return Some(builder.body(hyper::Body::empty()).unwrap());
return Some(builder.body(Full::new(Bytes::new())).unwrap());
}
};

Expand All @@ -102,17 +108,16 @@ fn auth_response(
.status(hyper::StatusCode::UNAUTHORIZED);
return Some(
builder
.body(hyper::Body::empty())
.body(Full::new(Bytes::new()))
.unwrap_or(hyper::Response::default()),
);
}

async fn call(
serv: std::sync::Arc<std::sync::Mutex<ServerState>>,
req: hyper::Request<hyper::Body>,
) -> hyper::Response<hyper::Body> {
req: hyper::Request<Incoming>,
) -> hyper::Response<Full<Bytes>> {
println!("call {:?}", req.uri().path());
let mut req = req;

let path = req.uri().path();

Expand All @@ -133,21 +138,22 @@ async fn call(
for (u, p) in serv.lock().unwrap().users.iter() {
if username == *u {
password = p.clone();
return builder.body(hyper::Body::from(password)).unwrap();
return builder.body(Full::new(Bytes::from(password))).unwrap();
}
}
serv.lock()
.unwrap()
.users
.push((username, password.clone()));
println!("users: {:?}", serv.lock().unwrap().users);
return builder.body(hyper::Body::from(password)).unwrap();
return builder.body(Full::new(Bytes::from(password))).unwrap();
}

if let Some(response) = auth_response(&req, &serv.lock().unwrap().users) {
return response;
}

/*
if let Some(proxy) = &ARGS.get_one::<String>("proxy") {
for proxy in proxy.split(",") {
if let [proxy_path, proxy_target] = proxy.split("=").collect::<Vec<_>>().as_slice() {
Expand All @@ -159,13 +165,14 @@ async fn call(
Ok(response) => response,
Err(error) => hyper::Response::builder()
.status(hyper::StatusCode::INTERNAL_SERVER_ERROR)
.body(hyper::Body::from(format!("Proxy error: {:?}", error)))
.body(format!("Proxy error: {:?}", error))
.unwrap(),
};
}
}
}
}
*/

let workdir = std::path::PathBuf::from(
ARGS.get_one::<String>("dir")
Expand All @@ -184,34 +191,43 @@ async fn call(
}

#[tokio::main]
async fn main() {
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let server_state = std::sync::Arc::new(std::sync::Mutex::new(ServerState { users: vec![] }));

let make_service = hyper::service::make_service_fn(move |_| {
let server_state = server_state.clone();

let service = hyper::service::service_fn(move |_req| {
let server_state = server_state.clone();

call(server_state, _req).map(Ok::<_, hyper::http::Error>)
});

futures::future::ok::<_, hyper::http::Error>(service)
});

let addr = format!(
let addr: SocketAddr = format!(
"0.0.0.0:{}",
ARGS.get_one::<String>("port")
.unwrap_or(&"8000".to_owned())
.to_owned()
)
.parse()
.unwrap();
let server = Server::bind(&addr).serve(make_service);

let listener = TcpListener::bind(addr).await?;
println!("Now listening on {}", addr);
let server_state = server_state.clone();

loop {
let (tcp, _) = listener.accept().await?;
let io = TokioIo::new(tcp);
let server_state = server_state.clone();

if let Err(e) = server.await {
eprintln!("server error: {}", e);
tokio::task::spawn(async move {
if let Err(err) = http1::Builder::new()
.timer(TokioTimer::new())
.serve_connection(
io,
service_fn(move |_req| {
let server_state = server_state.clone();

call(server_state, _req).map(Ok::<_, hyper::http::Error>)
}),
)
.await
{
println!("Error serving connection: {:?}", err);
}
});
}
}

Expand Down
Loading