From 921fb57e9e2008a6394c4c9fdb508bafa64ff0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 20 Apr 2024 10:27:48 +0200 Subject: [PATCH 1/8] http: improve peer addr extraction logic --- crates/http/src/workers/socket/connection.rs | 77 +++++++++----------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/crates/http/src/workers/socket/connection.rs b/crates/http/src/workers/socket/connection.rs index c2d4089..787440c 100644 --- a/crates/http/src/workers/socket/connection.rs +++ b/crates/http/src/workers/socket/connection.rs @@ -14,7 +14,6 @@ use aquatic_http_protocol::response::{ FailureResponse, Response, ScrapeResponse, ScrapeStatistics, }; use arc_swap::ArcSwap; -use either::Either; use futures::stream::FuturesUnordered; use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt}; use futures_rustls::TlsAcceptor; @@ -110,7 +109,6 @@ pub(super) async fn run_connection( request_senders, valid_until, server_start_instant, - opt_peer_addr, peer_port, request_buffer, request_buffer_position: 0, @@ -119,7 +117,7 @@ pub(super) async fn run_connection( worker_index_string: worker_index.to_string(), }; - conn.run().await + conn.run(opt_peer_addr).await } else { let mut conn = Connection { config, @@ -127,7 +125,6 @@ pub(super) async fn run_connection( request_senders, valid_until, server_start_instant, - opt_peer_addr, peer_port, request_buffer, request_buffer_position: 0, @@ -136,7 +133,7 @@ pub(super) async fn run_connection( worker_index_string: worker_index.to_string(), }; - conn.run().await + conn.run(opt_peer_addr).await } } @@ -146,9 +143,6 @@ struct Connection { request_senders: Rc>, valid_until: Rc>, server_start_instant: ServerStartInstant, - // If we're running behind a reverse proxy, gets set as soon as we get a - // valid requiest. Otherwise, must be set before calling `run`. - opt_peer_addr: Option, peer_port: u16, request_buffer: Box<[u8; REQUEST_BUFFER_SIZE]>, request_buffer_position: usize, @@ -161,14 +155,21 @@ impl Connection where S: futures::AsyncRead + futures::AsyncWrite + Unpin + 'static, { - async fn run(&mut self) -> Result<(), ConnectionError> { + async fn run( + &mut self, + // Set unless running behind reverse proxy + opt_stable_peer_addr: Option, + ) -> Result<(), ConnectionError> { loop { - let response = match self.read_request().await? { - Either::Left(response) => Response::Failure(response), - Either::Right(request) => self.handle_request(request).await?, - }; + let (request, opt_peer_addr) = self.read_request().await?; - self.write_response(&response).await?; + let peer_addr = opt_stable_peer_addr + .or(opt_peer_addr) + .ok_or(anyhow::anyhow!("Could not extract peer addr"))?; + + let response = self.handle_request(request, peer_addr).await?; + + self.write_response(&response, peer_addr).await?; if matches!(response, Response::Failure(_)) || !self.config.network.keep_alive { break; @@ -178,7 +179,9 @@ where Ok(()) } - async fn read_request(&mut self) -> Result, ConnectionError> { + async fn read_request( + &mut self, + ) -> Result<(Request, Option), ConnectionError> { self.request_buffer_position = 0; loop { @@ -202,17 +205,19 @@ where match parse_request(&self.config, buffer_slice) { Ok((request, opt_peer_ip)) => { - if self.config.network.runs_behind_reverse_proxy { + let opt_peer_addr = if self.config.network.runs_behind_reverse_proxy { let peer_ip = opt_peer_ip .expect("logic error: peer ip must have been extracted at this point"); - self.opt_peer_addr = Some(CanonicalSocketAddr::new(SocketAddr::new( + Some(CanonicalSocketAddr::new(SocketAddr::new( peer_ip, self.peer_port, - ))); - } + ))) + } else { + None + }; - return Ok(Either::Right(request)); + return Ok((request, opt_peer_addr)); } Err(RequestParseError::MoreDataNeeded) => continue, Err(RequestParseError::RequiredPeerIpHeaderMissing(err)) => { @@ -220,12 +225,6 @@ where } Err(RequestParseError::Other(err)) => { ::log::debug!("Failed parsing request: {:#}", err); - - let response = FailureResponse { - failure_reason: "Invalid request".into(), - }; - - return Ok(Either::Left(response)); } } } @@ -238,11 +237,11 @@ where /// response /// - If it is a scrape requests, split it up, pass on the parts to /// relevant swarm workers and await a response - async fn handle_request(&mut self, request: Request) -> Result { - let peer_addr = self - .opt_peer_addr - .expect("peer addr should already have been extracted by now"); - + async fn handle_request( + &mut self, + request: Request, + peer_addr: CanonicalSocketAddr, + ) -> Result { *self.valid_until.borrow_mut() = ValidUntil::new( self.server_start_instant, self.config.cleaning.max_connection_idle, @@ -385,7 +384,11 @@ where } } - async fn write_response(&mut self, response: &Response) -> Result<(), ConnectionError> { + async fn write_response( + &mut self, + response: &Response, + peer_addr: CanonicalSocketAddr, + ) -> Result<(), ConnectionError> { // Write body and final newline to response buffer let mut position = RESPONSE_HEADER.len(); @@ -443,15 +446,7 @@ where Response::Failure(_) => "error", }; - // If we're behind a reverse proxy and we're sending an error - // response due to failing to parse a request, opt_peer_addr might - // not yet be set (and in that case, we don't know if the true peer - // connects over IPv4 or IPv6) - let ip_version_str = self - .opt_peer_addr - .as_ref() - .map(peer_addr_to_ip_version_str) - .unwrap_or("?"); + let ip_version_str = peer_addr_to_ip_version_str(&peer_addr); ::metrics::counter!( "aquatic_responses_total", From 79d8a3b6f374f52ebcb957d1f53024dadf55096f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 25 Apr 2024 22:31:02 +0200 Subject: [PATCH 2/8] http: don't always close connection after sending error response --- crates/http/src/workers/socket/connection.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/http/src/workers/socket/connection.rs b/crates/http/src/workers/socket/connection.rs index 787440c..c277ffc 100644 --- a/crates/http/src/workers/socket/connection.rs +++ b/crates/http/src/workers/socket/connection.rs @@ -171,7 +171,7 @@ where self.write_response(&response, peer_addr).await?; - if matches!(response, Response::Failure(_)) || !self.config.network.keep_alive { + if !self.config.network.keep_alive { break; } } From 0bf80dfea86e39e56fc52518da5645cdd8c048aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 25 Apr 2024 22:36:41 +0200 Subject: [PATCH 3/8] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf4ab65..7bbeec8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,9 @@ * Fix bug where clean up after closing connections wasn't always done * Quit whole application if any worker thread quits +* Fix panic when sending failure response when running with metrics behind + reverse proxy +* Don't always close connections after sending failure response ### aquatic_ws From 69294ea201a6d83893febbb35ebe4ac1c67eab5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 25 Apr 2024 22:36:47 +0200 Subject: [PATCH 4/8] Update rustls to v0.23 --- Cargo.lock | 223 ++++++++++++++++++++++++++++--- crates/common/Cargo.toml | 2 +- crates/http/Cargo.toml | 2 +- crates/http_load_test/Cargo.toml | 4 +- crates/ws/Cargo.toml | 4 +- crates/ws_load_test/Cargo.toml | 4 +- 6 files changed, 211 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed3a7b6..4ffc7ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -484,6 +484,33 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "aws-lc-rs" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5509d663b2c00ee421bda8d6a24d6c42e15970957de1701b8df9f6fbe5707df1" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d5d317212c2a78d86ba6622e969413c38847b62f48111f8b763af3dac2f9840" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + [[package]] name = "backtrace" version = "0.3.71" @@ -523,6 +550,29 @@ dependencies = [ "snafu", ] +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.60", + "which", +] + [[package]] name = "bitflags" version = "0.7.0" @@ -619,6 +669,19 @@ name = "cc" version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] [[package]] name = "cfg-if" @@ -653,6 +716,17 @@ dependencies = [ "half", ] +[[package]] +name = "clang-sys" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "3.2.25" @@ -696,7 +770,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -714,6 +788,15 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -938,6 +1021,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "duplicate" version = "1.0.0" @@ -1075,6 +1164,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.30" @@ -1146,14 +1241,14 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] name = "futures-rustls" -version = "0.25.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d8a2499f0fecc0492eb3e47eab4e92da7875e1028ad2528f214ac3346ca04e" +checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", "rustls", @@ -1237,10 +1332,16 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "time", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "glommio" version = "0.8.0" @@ -1360,6 +1461,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "http" version = "0.2.12" @@ -1557,6 +1667,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -1582,6 +1701,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "lexical-core" version = "0.8.5" @@ -1652,6 +1777,16 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if", + "windows-targets 0.52.4", +] + [[package]] name = "libm" version = "0.2.8" @@ -1814,6 +1949,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "nanorand" version = "0.7.0" @@ -2024,6 +2165,12 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -2047,7 +2194,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2124,6 +2271,16 @@ dependencies = [ "yansi", ] +[[package]] +name = "prettyplease" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +dependencies = [ + "proc-macro2", + "syn 2.0.60", +] + [[package]] name = "privdrop" version = "0.5.4" @@ -2160,9 +2317,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -2318,7 +2475,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2380,6 +2537,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.38.32" @@ -2395,12 +2558,13 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.3" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +checksum = "afabcee0551bd1aa3e18e5adbf2c0544722014b899adb31bd186ec638d3da97e" dependencies = [ + "aws-lc-rs", "log", - "ring", + "once_cell", "rustls-pki-types", "rustls-webpki", "subtle", @@ -2429,6 +2593,7 @@ version = "0.102.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -2503,7 +2668,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2537,6 +2702,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" @@ -2718,9 +2889,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -2771,7 +2942,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -2914,7 +3085,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -3083,7 +3254,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -3105,7 +3276,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3126,6 +3297,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.2.8" @@ -3334,7 +3517,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 2bd41a0..5f355e1 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -38,7 +38,7 @@ simplelog = { version = "0.12" } toml = "0.5" # rustls feature -rustls = { version = "0.22", optional = true } +rustls = { version = "0.23", optional = true } rustls-pemfile = { version = "2", optional = true } # prometheus feature diff --git a/crates/http/Cargo.toml b/crates/http/Cargo.toml index c9439ad..5b59872 100644 --- a/crates/http/Cargo.toml +++ b/crates/http/Cargo.toml @@ -34,7 +34,7 @@ cfg-if = "1" either = "1" futures = "0.3" futures-lite = "1" -futures-rustls = "0.25" +futures-rustls = "0.26" glommio = "0.8" httparse = "1" itoa = "1" diff --git a/crates/http_load_test/Cargo.toml b/crates/http_load_test/Cargo.toml index 2bce99c..124b1d8 100644 --- a/crates/http_load_test/Cargo.toml +++ b/crates/http_load_test/Cargo.toml @@ -22,14 +22,14 @@ aquatic_toml_config.workspace = true anyhow = "1" futures = "0.3" futures-lite = "1" -futures-rustls = "0.25" +futures-rustls = "0.26" hashbrown = "0.14" glommio = "0.8" log = "0.4" mimalloc = { version = "0.1", default-features = false } rand = { version = "0.8", features = ["small_rng"] } rand_distr = "0.4" -rustls = { version = "0.22", default-features = false, features = ["logging"] } # TLS 1.2 disabled +rustls = { version = "0.23", default-features = false, features = ["logging"] } # TLS 1.2 disabled serde = { version = "1", features = ["derive"] } [dev-dependencies] diff --git a/crates/ws/Cargo.toml b/crates/ws/Cargo.toml index 164b631..d84bf9d 100644 --- a/crates/ws/Cargo.toml +++ b/crates/ws/Cargo.toml @@ -37,7 +37,7 @@ arc-swap = "1" cfg-if = "1" futures = "0.3" futures-lite = "1" -futures-rustls = "0.25" +futures-rustls = "0.26" glommio = "0.8" hashbrown = { version = "0.14", features = ["serde"] } httparse = "1" @@ -46,7 +46,7 @@ log = "0.4" mimalloc = { version = "0.1", default-features = false, optional = true } privdrop = "0.5" rand = { version = "0.8", features = ["small_rng"] } -rustls = "0.22" +rustls = "0.23" rustls-pemfile = "2" serde = { version = "1", features = ["derive"] } signal-hook = { version = "0.3" } diff --git a/crates/ws_load_test/Cargo.toml b/crates/ws_load_test/Cargo.toml index 3691266..3c065e5 100644 --- a/crates/ws_load_test/Cargo.toml +++ b/crates/ws_load_test/Cargo.toml @@ -22,13 +22,13 @@ aquatic_ws_protocol.workspace = true anyhow = "1" async-tungstenite = "0.24" futures = "0.3" -futures-rustls = "0.25" +futures-rustls = "0.26" glommio = "0.8" log = "0.4" mimalloc = { version = "0.1", default-features = false } rand = { version = "0.8", features = ["small_rng"] } rand_distr = "0.4" -rustls = { version = "0.22" } +rustls = { version = "0.23" } serde = { version = "1", features = ["derive"] } serde_json = "1" tungstenite = "0.21" From efa10015e5ff5623347e0361d33f2ce04cb4e01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 25 Apr 2024 22:38:41 +0200 Subject: [PATCH 5/8] Upgrade async-tungstenite to v0.25 --- Cargo.lock | 4 ++-- crates/ws/Cargo.toml | 2 +- crates/ws_load_test/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ffc7ef..37e0e86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -456,9 +456,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-tungstenite" -version = "0.24.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3609af4bbf701ddaf1f6bb4e6257dff4ff8932327d0e685d3f653724c258b1ac" +checksum = "2cca750b12e02c389c1694d35c16539f88b8bbaa5945934fdc1b41a776688589" dependencies = [ "futures-io", "futures-util", diff --git a/crates/ws/Cargo.toml b/crates/ws/Cargo.toml index d84bf9d..45c941f 100644 --- a/crates/ws/Cargo.toml +++ b/crates/ws/Cargo.toml @@ -32,7 +32,7 @@ aquatic_toml_config.workspace = true aquatic_ws_protocol.workspace = true anyhow = "1" -async-tungstenite = "0.24" +async-tungstenite = "0.25" arc-swap = "1" cfg-if = "1" futures = "0.3" diff --git a/crates/ws_load_test/Cargo.toml b/crates/ws_load_test/Cargo.toml index 3c065e5..a56633c 100644 --- a/crates/ws_load_test/Cargo.toml +++ b/crates/ws_load_test/Cargo.toml @@ -20,7 +20,7 @@ aquatic_toml_config.workspace = true aquatic_ws_protocol.workspace = true anyhow = "1" -async-tungstenite = "0.24" +async-tungstenite = "0.25" futures = "0.3" futures-rustls = "0.26" glommio = "0.8" From ec95f7e73cd35f2c9b97565ea5fa04f680d4f896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 25 Apr 2024 22:39:21 +0200 Subject: [PATCH 6/8] Fix a ws Cargo.toml comment --- crates/ws/Cargo.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ws/Cargo.toml b/crates/ws/Cargo.toml index 45c941f..0c8a611 100644 --- a/crates/ws/Cargo.toml +++ b/crates/ws/Cargo.toml @@ -21,8 +21,9 @@ name = "aquatic_ws" default = ["prometheus", "mimalloc"] prometheus = ["metrics", "aquatic_common/prometheus"] metrics = ["dep:metrics", "dep:metrics-util"] -# Use mimalloc allocator for much better performance. Requires cmake and a -# C/C++ compiler +# Use mimalloc allocator for much better performance. +# +# Requires cmake and a C compiler mimalloc = ["dep:mimalloc"] [dependencies] From 6c4b2d384d5fc8291404181312b76c1e1db57dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 25 Apr 2024 22:41:13 +0200 Subject: [PATCH 7/8] Update metrics-exporter-prometheus to v0.14 --- Cargo.lock | 126 ++++++++++++++++++++++++++++++++------- crates/common/Cargo.toml | 2 +- 2 files changed, 104 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37e0e86..56299f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1377,6 +1377,25 @@ dependencies = [ "typenum", ] +[[package]] +name = "h2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.4.1" @@ -1470,17 +1489,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.1.0" @@ -1494,12 +1502,24 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", - "http 0.2.12", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", "pin-project-lite", ] @@ -1541,25 +1561,43 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.28" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", - "http 0.2.12", + "h2", + "http", "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", "socket2 0.5.6", "tokio", + "tower", "tower-service", "tracing", - "want", ] [[package]] @@ -1879,12 +1917,14 @@ dependencies = [ [[package]] name = "metrics-exporter-prometheus" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21" +checksum = "5d58e362dc7206e9456ddbcdbd53c71ba441020e62104703075a69151e38d85f" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", + "http-body-util", "hyper", + "hyper-util", "indexmap 2.2.6", "ipnet", "metrics", @@ -1892,6 +1932,7 @@ dependencies = [ "quanta", "thiserror", "tokio", + "tracing", ] [[package]] @@ -3010,13 +3051,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", + "bytes", "libc", "mio", + "num_cpus", "pin-project-lite", "socket2 0.5.6", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.11" @@ -3060,6 +3117,28 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + [[package]] name = "tower-service" version = "0.3.2" @@ -3072,6 +3151,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -3112,7 +3192,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http", "httparse", "log", "rand", diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 5f355e1..772b6e7 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -44,7 +44,7 @@ rustls-pemfile = { version = "2", optional = true } # prometheus feature metrics = { version = "0.22", optional = true } metrics-util = { version = "0.16", optional = true } -metrics-exporter-prometheus = { version = "0.13", optional = true, default-features = false, features = ["http-listener"] } +metrics-exporter-prometheus = { version = "0.14", optional = true, default-features = false, features = ["http-listener"] } tokio = { version = "1", optional = true, features = ["rt", "net", "time"] } # cpu pinning feature From b1848c361d26121ef3616d3852c5b592c2be41fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 25 Apr 2024 22:50:41 +0200 Subject: [PATCH 8/8] Update glommio to v0.9 --- Cargo.lock | 42 ++++++++++++-------------------- crates/http/Cargo.toml | 2 +- crates/http_load_test/Cargo.toml | 2 +- crates/ws/Cargo.toml | 2 +- crates/ws_load_test/Cargo.toml | 2 +- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56299f9..44c4de2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1344,13 +1344,13 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "glommio" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f09bf53139d5680da6325b4e79c6bc1518e94a65ab74df14b7e3693a8c78b" +checksum = "e1f8bc1fce949d18098dc0a4e861314e40351a0144ebf61e59bdb5254a2273b2" dependencies = [ "ahash 0.7.8", "backtrace", - "bitflags 1.3.2", + "bitflags 2.5.0", "bitmaps", "buddy-alloc", "cc", @@ -1364,7 +1364,7 @@ dependencies = [ "libc", "lockfree", "log", - "nix 0.23.2", + "nix 0.27.1", "pin-project-lite", "rlimit", "scoped-tls", @@ -1878,15 +1878,6 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.7.1" @@ -2014,19 +2005,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "nix" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "nix" version = "0.26.4" @@ -2040,6 +2018,18 @@ dependencies = [ "pin-utils", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "libc", + "memoffset 0.9.1", +] + [[package]] name = "nom" version = "7.1.3" diff --git a/crates/http/Cargo.toml b/crates/http/Cargo.toml index 5b59872..5cbd14d 100644 --- a/crates/http/Cargo.toml +++ b/crates/http/Cargo.toml @@ -35,7 +35,7 @@ either = "1" futures = "0.3" futures-lite = "1" futures-rustls = "0.26" -glommio = "0.8" +glommio = "0.9" httparse = "1" itoa = "1" libc = "0.2" diff --git a/crates/http_load_test/Cargo.toml b/crates/http_load_test/Cargo.toml index 124b1d8..63abaaa 100644 --- a/crates/http_load_test/Cargo.toml +++ b/crates/http_load_test/Cargo.toml @@ -24,7 +24,7 @@ futures = "0.3" futures-lite = "1" futures-rustls = "0.26" hashbrown = "0.14" -glommio = "0.8" +glommio = "0.9" log = "0.4" mimalloc = { version = "0.1", default-features = false } rand = { version = "0.8", features = ["small_rng"] } diff --git a/crates/ws/Cargo.toml b/crates/ws/Cargo.toml index 0c8a611..59bb1bc 100644 --- a/crates/ws/Cargo.toml +++ b/crates/ws/Cargo.toml @@ -39,7 +39,7 @@ cfg-if = "1" futures = "0.3" futures-lite = "1" futures-rustls = "0.26" -glommio = "0.8" +glommio = "0.9" hashbrown = { version = "0.14", features = ["serde"] } httparse = "1" indexmap = "2" diff --git a/crates/ws_load_test/Cargo.toml b/crates/ws_load_test/Cargo.toml index a56633c..8ff2bec 100644 --- a/crates/ws_load_test/Cargo.toml +++ b/crates/ws_load_test/Cargo.toml @@ -23,7 +23,7 @@ anyhow = "1" async-tungstenite = "0.25" futures = "0.3" futures-rustls = "0.26" -glommio = "0.8" +glommio = "0.9" log = "0.4" mimalloc = { version = "0.1", default-features = false } rand = { version = "0.8", features = ["small_rng"] }