From 227f790d8e27c088e321619b1422fc4094ad0b07 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 6 Jul 2024 18:45:32 +0700 Subject: [PATCH] Update axum/reqwest for hyper 1.0 --- Cargo.lock | 394 +++++++++++++++++--- Cargo.toml | 9 +- cargo/licenses.json | 197 +++++----- rslib/Cargo.toml | 1 + rslib/src/sync/collection/tests.rs | 1 + rslib/src/sync/http_client/io_monitor.rs | 2 +- rslib/src/sync/http_server/mod.rs | 24 +- rslib/src/sync/request/header_and_stream.rs | 17 +- rslib/src/sync/request/mod.rs | 12 +- rslib/src/sync/response.rs | 6 +- 10 files changed, 487 insertions(+), 176 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1d4e9c43..93470d74b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,6 +117,7 @@ dependencies = [ "async-trait", "axum", "axum-client-ip", + "axum-extra", "blake3", "bytes", "chrono", @@ -136,7 +137,7 @@ dependencies = [ "futures", "hex", "htmlescape", - "hyper", + "hyper 0.14.29", "id_tree", "inflections", "itertools 0.12.1", @@ -155,7 +156,7 @@ dependencies = [ "pulldown-cmark 0.9.6", "rand 0.8.5", "regex", - "reqwest", + "reqwest 0.12.5", "rusqlite", "rustls-pemfile 2.1.2", "scopeguard", @@ -426,20 +427,20 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", "axum-macros", - "bitflags 1.3.2", "bytes", "futures-util", - "headers", - "http 0.2.12", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -452,18 +453,19 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-client-ip" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef117890a418b7832678d9ea1e1c08456dd7b2fd1dadb9676cd6f0fe7eb4b21" +checksum = "72188bed20deb981f3a4a9fe674e5980fd9e9c2bd880baa94715ad5d60d64c67" dependencies = [ "axum", "forwarded-header-value", @@ -472,26 +474,53 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", + "tracing", +] + +[[package]] +name = "axum-extra" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0be6ea09c9b96cb5076af0de2e383bd2bc0c18f827cf1967bdd353e0b910d733" +dependencies = [ + "axum", + "axum-core", + "bytes", + "futures-util", + "headers 0.4.0", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "mime", + "pin-project-lite", + "serde", + "tower", + "tower-layer", + "tower-service", + "tracing", ] [[package]] name = "axum-macros" -version = "0.3.8" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62" +checksum = "00c055ee2d014ae5981ce1016374e8213682aa14d9bf40e48ab48b5f3ef20eaa" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -2469,13 +2498,28 @@ checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ "base64 0.21.7", "bytes", - "headers-core", + "headers-core 0.2.0", "http 0.2.12", "httpdate", "mime", "sha1", ] +[[package]] +name = "headers" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" +dependencies = [ + "base64 0.21.7", + "bytes", + "headers-core 0.3.0", + "http 1.1.0", + "httpdate", + "mime", + "sha1", +] + [[package]] name = "headers-core" version = "0.2.0" @@ -2485,6 +2529,15 @@ dependencies = [ "http 0.2.12", ] +[[package]] +name = "headers-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" +dependencies = [ + "http 1.1.0", +] + [[package]] name = "heck" version = "0.4.1" @@ -2601,10 +2654,27 @@ dependencies = [ ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "pin-project-lite", +] [[package]] name = "http-types" @@ -2657,7 +2727,7 @@ dependencies = [ "futures-util", "h2", "http 0.2.12", - "http-body", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -2669,6 +2739,26 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -2677,10 +2767,29 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper", + "hyper 0.14.29", "rustls 0.21.12", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.4.0", + "hyper-util", + "rustls 0.23.10", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", + "webpki-roots 0.26.3", ] [[package]] @@ -2690,12 +2799,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.29", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.4.0", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.4.0", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -3078,7 +3223,7 @@ dependencies = [ "mdbook", "pulldown-cmark 0.8.0", "regex", - "reqwest", + "reqwest 0.11.27", "serde", "thiserror", "url", @@ -3094,7 +3239,7 @@ dependencies = [ "lazy_static", "linkcheck", "regex", - "reqwest", + "reqwest 0.12.5", "strum 0.26.3", "tokio", ] @@ -3404,16 +3549,15 @@ dependencies = [ [[package]] name = "multer" -version = "2.1.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" dependencies = [ "bytes", "encoding_rs", "futures-util", - "http 0.2.12", + "http 1.1.0", "httparse", - "log", "memchr", "mime", "spin 0.9.8", @@ -4415,6 +4559,53 @@ dependencies = [ "memchr", ] +[[package]] +name = "quinn" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls 0.23.10", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +dependencies = [ + "bytes", + "rand 0.8.5", + "ring 0.17.8", + "rustc-hash", + "rustls 0.23.10", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -4693,10 +4884,54 @@ dependencies = [ "futures-util", "h2", "http 0.2.12", - "http-body", - "hyper", - "hyper-rustls", - "hyper-tls", + "http-body 0.4.6", + "hyper 0.14.29", + "hyper-rustls 0.24.2", + "hyper-tls 0.5.0", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls 0.21.12", + "rustls-pemfile 1.0.4", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-rustls 0.24.1", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots 0.25.4", + "winreg 0.50.0", +] + +[[package]] +name = "reqwest" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.0", + "hyper-rustls 0.27.2", + "hyper-tls 0.6.0", + "hyper-util", "ipnet", "js-sys", "log", @@ -4706,17 +4941,18 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.12", + "quinn", + "rustls 0.23.10", "rustls-native-certs", - "rustls-pemfile 1.0.4", + "rustls-pemfile 2.1.2", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", - "system-configuration", + "sync_wrapper 1.0.1", "tokio", "tokio-native-tls", - "tokio-rustls", + "tokio-rustls 0.26.0", "tokio-socks", "tokio-util", "tower-service", @@ -4725,8 +4961,8 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.25.4", - "winreg 0.50.0", + "webpki-roots 0.26.3", + "winreg 0.52.0", ] [[package]] @@ -4806,7 +5042,7 @@ dependencies = [ "clap", "flate2", "junction", - "reqwest", + "reqwest 0.12.5", "sha2", "tar", "termcolor", @@ -4883,13 +5119,28 @@ dependencies = [ ] [[package]] -name = "rustls-native-certs" -version = "0.6.3" +name = "rustls" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +dependencies = [ + "once_cell", + "ring 0.17.8", + "rustls-pki-types", + "rustls-webpki 0.102.5", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", - "rustls-pemfile 1.0.4", + "rustls-pemfile 2.1.2", + "rustls-pki-types", "schannel", "security-framework", ] @@ -5486,6 +5737,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "synstructure" version = "0.13.1" @@ -5783,6 +6040,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.10", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-socks" version = "0.5.1" @@ -5885,17 +6153,15 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.6.0", "bytes", - "futures-core", - "futures-util", - "http 0.2.12", - "http-body", - "http-range-header", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "pin-project-lite", "tower-layer", "tower-service", @@ -6006,7 +6272,7 @@ dependencies = [ "hex", "log", "once_cell", - "reqwest", + "reqwest 0.11.27", "sha2", "tempfile", "url", @@ -6352,9 +6618,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "headers", + "headers 0.3.9", "http 0.2.12", - "hyper", + "hyper 0.14.29", "log", "mime", "mime_guess", @@ -6885,6 +7151,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wiremock" version = "0.5.22" @@ -6898,7 +7174,7 @@ dependencies = [ "futures", "futures-timer", "http-types", - "hyper", + "hyper 0.14.29", "log", "once_cell", "regex", diff --git a/Cargo.toml b/Cargo.toml index 0834fef43..27eda27d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,8 +60,9 @@ apple-bundles = "0.17.0" async-compression = { version = "0.4.11", features = ["zstd", "tokio"] } async-stream = "0.3.5" async-trait = "0.1.80" -axum = { version = "0.6.20", features = ["multipart", "macros", "headers"] } -axum-client-ip = "0.4.2" +axum = { version = "0.7", features = ["multipart", "macros"] } +axum-client-ip = "0.6" +axum-extra = { version = "0.9.3", features = ["typed-header"] } blake3 = "1.5.1" bytes = "1.6.0" camino = "1.1.7" @@ -109,7 +110,7 @@ pulldown-cmark = "0.9.6" pyo3 = { version = "0.20.3", features = ["extension-module", "abi3", "abi3-py39"] } rand = "0.8.5" regex = "1.10.5" -reqwest = { version = "0.11.27", default-features = false, features = ["json", "socks", "stream", "multipart"] } +reqwest = { version = "0.12", default-features = false, features = ["json", "socks", "stream", "multipart"] } rusqlite = { version = "0.30.0", features = ["trace", "functions", "collation", "bundled"] } rustls-pemfile = "2.1.2" scopeguard = "1.2.0" @@ -129,7 +130,7 @@ tempfile = "3.10.1" termcolor = "1.4.1" tokio = { version = "1.38", features = ["fs", "rt-multi-thread", "macros", "signal"] } tokio-util = { version = "0.7.11", features = ["io"] } -tower-http = { version = "0.4.4", features = ["trace"] } +tower-http = { version = "0.5", features = ["trace"] } tracing = { version = "0.1.40", features = ["max_level_trace", "release_max_level_debug"] } tracing-appender = "0.2.3" tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] } diff --git a/cargo/licenses.json b/cargo/licenses.json index 3d1d2a01f..5615cb0bc 100644 --- a/cargo/licenses.json +++ b/cargo/licenses.json @@ -226,7 +226,7 @@ }, { "name": "axum", - "version": "0.6.20", + "version": "0.7.5", "authors": null, "repository": "https://github.com/tokio-rs/axum", "license": "MIT", @@ -235,7 +235,7 @@ }, { "name": "axum-client-ip", - "version": "0.4.2", + "version": "0.6.0", "authors": null, "repository": "https://github.com/imbolc/axum-client-ip", "license": "MIT", @@ -244,16 +244,25 @@ }, { "name": "axum-core", - "version": "0.3.4", + "version": "0.4.3", "authors": null, "repository": "https://github.com/tokio-rs/axum", "license": "MIT", "license_file": null, "description": "Core types and traits for axum" }, + { + "name": "axum-extra", + "version": "0.9.3", + "authors": null, + "repository": "https://github.com/tokio-rs/axum", + "license": "MIT", + "license_file": null, + "description": "Extra utilities for axum" + }, { "name": "axum-macros", - "version": "0.3.8", + "version": "0.4.1", "authors": null, "repository": "https://github.com/tokio-rs/axum", "license": "MIT", @@ -1657,7 +1666,7 @@ }, { "name": "headers", - "version": "0.3.9", + "version": "0.4.0", "authors": "Sean McArthur ", "repository": "https://github.com/hyperium/headers", "license": "MIT", @@ -1666,7 +1675,7 @@ }, { "name": "headers-core", - "version": "0.2.0", + "version": "0.3.0", "authors": "Sean McArthur ", "repository": "https://github.com/hyperium/headers", "license": "MIT", @@ -1754,6 +1763,15 @@ "license_file": null, "description": "A set of types for representing HTTP requests and responses." }, + { + "name": "http", + "version": "1.1.0", + "authors": "Alex Crichton |Carl Lerche |Sean McArthur ", + "repository": "https://github.com/hyperium/http", + "license": "Apache-2.0 OR MIT", + "license_file": null, + "description": "A set of types for representing HTTP requests and responses." + }, { "name": "http-body", "version": "0.4.6", @@ -1764,13 +1782,22 @@ "description": "Trait representing an asynchronous, streaming, HTTP request or response body." }, { - "name": "http-range-header", - "version": "0.3.1", - "authors": null, - "repository": "https://github.com/MarcusGrass/parse-range-headers", + "name": "http-body", + "version": "1.0.0", + "authors": "Carl Lerche |Lucio Franco |Sean McArthur ", + "repository": "https://github.com/hyperium/http-body", "license": "MIT", "license_file": null, - "description": "No-dep range header parser" + "description": "Trait representing an asynchronous, streaming, HTTP request or response body." + }, + { + "name": "http-body-util", + "version": "0.1.2", + "authors": "Carl Lerche |Lucio Franco |Sean McArthur ", + "repository": "https://github.com/hyperium/http-body", + "license": "MIT", + "license_file": null, + "description": "Combinators and adapters for HTTP request or response bodies." }, { "name": "http-types", @@ -1808,9 +1835,18 @@ "license_file": null, "description": "A fast and correct HTTP library." }, + { + "name": "hyper", + "version": "1.4.0", + "authors": "Sean McArthur ", + "repository": "https://github.com/hyperium/hyper", + "license": "MIT", + "license_file": null, + "description": "A fast and correct HTTP library." + }, { "name": "hyper-rustls", - "version": "0.24.2", + "version": "0.27.2", "authors": null, "repository": "https://github.com/rustls/hyper-rustls", "license": "Apache-2.0 OR ISC OR MIT", @@ -1819,13 +1855,22 @@ }, { "name": "hyper-tls", - "version": "0.5.0", + "version": "0.6.0", "authors": "Sean McArthur ", "repository": "https://github.com/hyperium/hyper-tls", "license": "Apache-2.0 OR MIT", "license_file": null, "description": "Default TLS implementation for use with hyper" }, + { + "name": "hyper-util", + "version": "0.1.6", + "authors": "Sean McArthur ", + "repository": "https://github.com/hyperium/hyper-util", + "license": "MIT", + "license_file": null, + "description": "hyper utilities" + }, { "name": "iana-time-zone", "version": "0.1.60", @@ -2269,9 +2314,9 @@ }, { "name": "multer", - "version": "2.1.0", + "version": "3.1.0", "authors": "Rousan Ali ", - "repository": "https://github.com/rousan/multer-rs", + "repository": "https://github.com/rwf2/multer", "license": "MIT", "license_file": null, "description": "An async parser for `multipart/form-data` content-type in Rust." @@ -2915,6 +2960,33 @@ "license_file": null, "description": "VERY fast encoder/decoder for QOI (Quite Okay Image) format" }, + { + "name": "quinn", + "version": "0.11.2", + "authors": null, + "repository": "https://github.com/quinn-rs/quinn", + "license": "Apache-2.0 OR MIT", + "license_file": null, + "description": "Versatile QUIC transport protocol implementation" + }, + { + "name": "quinn-proto", + "version": "0.11.3", + "authors": null, + "repository": "https://github.com/quinn-rs/quinn", + "license": "Apache-2.0 OR MIT", + "license_file": null, + "description": "State machine for the QUIC transport protocol" + }, + { + "name": "quinn-udp", + "version": "0.5.2", + "authors": null, + "repository": "https://github.com/quinn-rs/quinn", + "license": "Apache-2.0 OR MIT", + "license_file": null, + "description": "UDP sockets with ECN information for the QUIC transport protocol" + }, { "name": "quote", "version": "1.0.36", @@ -3151,7 +3223,7 @@ }, { "name": "reqwest", - "version": "0.11.27", + "version": "0.12.5", "authors": "Sean McArthur ", "repository": "https://github.com/seanmonstar/reqwest", "license": "Apache-2.0 OR MIT", @@ -3230,15 +3302,6 @@ "license_file": null, "description": "Safe Rust bindings to POSIX/Unix/Linux/Winsock-like syscalls" }, - { - "name": "rustls", - "version": "0.21.12", - "authors": null, - "repository": "https://github.com/rustls/rustls", - "license": "Apache-2.0 OR ISC OR MIT", - "license_file": null, - "description": "Rustls is a modern TLS library written in Rust." - }, { "name": "rustls", "version": "0.22.4", @@ -3249,23 +3312,23 @@ "description": "Rustls is a modern TLS library written in Rust." }, { - "name": "rustls-native-certs", - "version": "0.6.3", + "name": "rustls", + "version": "0.23.10", "authors": null, - "repository": "https://github.com/ctz/rustls-native-certs", + "repository": "https://github.com/rustls/rustls", + "license": "Apache-2.0 OR ISC OR MIT", + "license_file": null, + "description": "Rustls is a modern TLS library written in Rust." + }, + { + "name": "rustls-native-certs", + "version": "0.7.1", + "authors": null, + "repository": "https://github.com/rustls/rustls-native-certs", "license": "Apache-2.0 OR ISC OR MIT", "license_file": null, "description": "rustls-native-certs allows rustls to use the platform native certificate store" }, - { - "name": "rustls-pemfile", - "version": "1.0.4", - "authors": null, - "repository": "https://github.com/rustls/pemfile", - "license": "Apache-2.0 OR ISC OR MIT", - "license_file": null, - "description": "Basic .pem file parser for keys and certificates" - }, { "name": "rustls-pemfile", "version": "2.1.2", @@ -3284,15 +3347,6 @@ "license_file": null, "description": "Shared types for the rustls PKI ecosystem" }, - { - "name": "rustls-webpki", - "version": "0.101.7", - "authors": null, - "repository": "https://github.com/rustls/webpki", - "license": "ISC", - "license_file": null, - "description": "Web PKI X.509 Certificate Verification." - }, { "name": "rustls-webpki", "version": "0.102.5", @@ -3383,15 +3437,6 @@ "license_file": null, "description": "A RAII scope guard that will run a given closure when it goes out of scope, even if the code between panics (assuming unwinding panic). Defines the macros `defer!`, `defer_on_unwind!`, `defer_on_success!` as shorthands for guards with one of the implemented strategies." }, - { - "name": "sct", - "version": "0.7.1", - "authors": "Joseph Birr-Pixton ", - "repository": "https://github.com/rustls/sct.rs", - "license": "Apache-2.0 OR ISC OR MIT", - "license_file": null, - "description": "Certificate transparency SCT verification library" - }, { "name": "security-framework", "version": "2.11.0", @@ -3788,6 +3833,15 @@ "license_file": null, "description": "A tool for enlisting the compiler’s help in proving the absence of concurrency" }, + { + "name": "sync_wrapper", + "version": "1.0.1", + "authors": "Actyx AG ", + "repository": "https://github.com/Actyx/sync_wrapper", + "license": "Apache-2.0", + "license_file": null, + "description": "A tool for enlisting the compiler's help in proving the absence of concurrency" + }, { "name": "synstructure", "version": "0.13.1", @@ -3806,24 +3860,6 @@ "license_file": null, "description": "Simplified interface to libc::sysctl" }, - { - "name": "system-configuration", - "version": "0.5.1", - "authors": "Mullvad VPN", - "repository": "https://github.com/mullvad/system-configuration-rs", - "license": "Apache-2.0 OR MIT", - "license_file": null, - "description": "Bindings to SystemConfiguration framework for macOS" - }, - { - "name": "system-configuration-sys", - "version": "0.5.0", - "authors": "Mullvad VPN", - "repository": "https://github.com/mullvad/system-configuration-rs", - "license": "Apache-2.0 OR MIT", - "license_file": null, - "description": "Low level bindings to SystemConfiguration framework for macOS" - }, { "name": "tch", "version": "0.15.0", @@ -3997,7 +4033,7 @@ }, { "name": "tokio-rustls", - "version": "0.24.1", + "version": "0.26.0", "authors": null, "repository": "https://github.com/rustls/tokio-rustls", "license": "Apache-2.0 OR MIT", @@ -4060,7 +4096,7 @@ }, { "name": "tower-http", - "version": "0.4.4", + "version": "0.5.2", "authors": "Tower Maintainers ", "repository": "https://github.com/tower-rs/tower-http", "license": "MIT", @@ -4526,15 +4562,6 @@ "license_file": null, "description": "Drop-in replacement for std::time for Wasm in browsers" }, - { - "name": "webpki-roots", - "version": "0.25.4", - "authors": null, - "repository": "https://github.com/rustls/webpki-roots", - "license": "MPL-2.0", - "license_file": null, - "description": "Mozilla's CA root certificates for use with webpki" - }, { "name": "webpki-roots", "version": "0.26.3", @@ -4861,7 +4888,7 @@ }, { "name": "winreg", - "version": "0.50.0", + "version": "0.52.0", "authors": "Igor Shaula ", "repository": "https://github.com/gentoo90/winreg-rs", "license": "MIT", diff --git a/rslib/Cargo.toml b/rslib/Cargo.toml index 5e93ea2f9..c61fef7a8 100644 --- a/rslib/Cargo.toml +++ b/rslib/Cargo.toml @@ -47,6 +47,7 @@ async-compression.workspace = true async-trait.workspace = true axum.workspace = true axum-client-ip.workspace = true +axum-extra.workspace = true blake3.workspace = true bytes.workspace = true chrono.workspace = true diff --git a/rslib/src/sync/collection/tests.rs b/rslib/src/sync/collection/tests.rs index 998ed57e2..991b895ac 100644 --- a/rslib/src/sync/collection/tests.rs +++ b/rslib/src/sync/collection/tests.rs @@ -89,6 +89,7 @@ where base_folder: base_folder.path().into(), ip_header: default_ip_header(), }) + .await .unwrap(); tokio::spawn(server_fut.instrument(Span::current())); // when not using ephemeral servers, tests need to be serialized diff --git a/rslib/src/sync/http_client/io_monitor.rs b/rslib/src/sync/http_client/io_monitor.rs index f6bc4423d..13679f664 100644 --- a/rslib/src/sync/http_client/io_monitor.rs +++ b/rslib/src/sync/http_client/io_monitor.rs @@ -269,7 +269,7 @@ mod test { let mock_server = MockServer::start().await; Mock::given(method("POST")) .and(path("/")) - .respond_with(ResponseTemplate::new(200).insert_header(ORIGINAL_SIZE.clone(), "0")) + .respond_with(ResponseTemplate::new(200).insert_header(ORIGINAL_SIZE.as_str(), "0")) .mount(&mock_server) .await; let monitor = IoMonitor::new(); diff --git a/rslib/src/sync/http_server/mod.rs b/rslib/src/sync/http_server/mod.rs index 1b4c0ee80..786d75eb6 100644 --- a/rslib/src/sync/http_server/mod.rs +++ b/rslib/src/sync/http_server/mod.rs @@ -9,9 +9,9 @@ mod user; use std::collections::HashMap; use std::future::Future; +use std::future::IntoFuture; use std::net::IpAddr; use std::net::SocketAddr; -use std::net::TcpListener; use std::path::Path; use std::path::PathBuf; use std::pin::Pin; @@ -31,6 +31,7 @@ use snafu::whatever; use snafu::OptionExt; use snafu::ResultExt; use snafu::Whatever; +use tokio::net::TcpListener; use tracing::Span; use crate::error; @@ -224,7 +225,7 @@ impl SimpleServer { }) } - pub fn make_server( + pub async fn make_server( config: SyncServerConfig, ) -> error::Result<(SocketAddr, ServerFuture), Whatever> { let server = Arc::new( @@ -232,6 +233,7 @@ impl SimpleServer { ); let address = &format!("{}:{}", config.host, config.port); let listener = TcpListener::bind(address) + .await .with_whatever_context(|_| format!("couldn't bind to {address}"))?; let addr = listener.local_addr().unwrap(); let server = with_logging_layer( @@ -242,12 +244,14 @@ impl SimpleServer { .layer(DefaultBodyLimit::max(*MAXIMUM_SYNC_PAYLOAD_BYTES)) .layer(config.ip_header.into_extension()), ); - let future = axum::Server::from_tcp(listener) - .whatever_context("listen failed")? - .serve(server.into_make_service_with_connect_info::()) - .with_graceful_shutdown(async { - let _ = tokio::signal::ctrl_c().await; - }); + let future = axum::serve( + listener, + server.into_make_service_with_connect_info::(), + ) + .with_graceful_shutdown(async { + let _ = tokio::signal::ctrl_c().await; + }) + .into_future(); tracing::info!(%addr, "listening"); Ok((addr, Box::pin(future))) } @@ -258,10 +262,10 @@ impl SimpleServer { let config = envy::prefixed("SYNC_") .from_env::() .whatever_context("reading SYNC_* env vars")?; - let (_addr, server_fut) = SimpleServer::make_server(config)?; + let (_addr, server_fut) = SimpleServer::make_server(config).await?; server_fut.await.whatever_context("await server")?; Ok(()) } } -pub type ServerFuture = Pin> + Send>>; +pub type ServerFuture = Pin> + Send>>; diff --git a/rslib/src/sync/request/header_and_stream.rs b/rslib/src/sync/request/header_and_stream.rs index 07878ece2..917bd1ce4 100644 --- a/rslib/src/sync/request/header_and_stream.rs +++ b/rslib/src/sync/request/header_and_stream.rs @@ -7,11 +7,10 @@ use std::io::ErrorKind; use std::marker::PhantomData; use std::net::IpAddr; -use axum::extract::BodyStream; -use axum::headers::Header; -use axum::headers::HeaderName; -use axum::headers::HeaderValue; use axum::http::StatusCode; +use axum_extra::headers::Header; +use axum_extra::headers::HeaderName; +use axum_extra::headers::HeaderValue; use bytes::Bytes; use futures::Stream; use futures::TryStreamExt; @@ -29,12 +28,14 @@ use crate::sync::request::MAXIMUM_SYNC_PAYLOAD_BYTES_UNCOMPRESSED; use crate::sync::version::SyncVersion; impl SyncRequest { - pub(super) async fn from_header_and_stream( + pub(super) async fn from_header_and_stream( sync_header: SyncHeader, - body_stream: BodyStream, + body_stream: S, ip: IpAddr, ) -> HttpResult> where + S: Stream> + Unpin, + E: Display, T: DeserializeOwned, { sync_header.sync_version.ensure_supported()?; @@ -132,7 +133,7 @@ impl Header for SyncHeader { &SYNC_HEADER_NAME } - fn decode<'i, I>(values: &mut I) -> Result + fn decode<'i, I>(values: &mut I) -> Result where Self: Sized, I: Iterator, @@ -141,7 +142,7 @@ impl Header for SyncHeader { .next() .and_then(|value| value.to_str().ok()) .and_then(|s| serde_json::from_str(s).ok()) - .ok_or_else(axum::headers::Error::invalid) + .ok_or_else(axum_extra::headers::Error::invalid) } fn encode>(&self, _values: &mut E) { diff --git a/rslib/src/sync/request/mod.rs b/rslib/src/sync/request/mod.rs index a6f9ea8d8..3e876ab5b 100644 --- a/rslib/src/sync/request/mod.rs +++ b/rslib/src/sync/request/mod.rs @@ -10,16 +10,15 @@ use std::marker::PhantomData; use std::net::IpAddr; use async_trait::async_trait; -use axum::extract::BodyStream; +use axum::body::Body; use axum::extract::FromRequest; use axum::extract::Multipart; use axum::http::Request; +use axum::http::StatusCode; use axum::RequestPartsExt; -use axum::TypedHeader; use axum_client_ip::SecureClientIp; +use axum_extra::TypedHeader; use header_and_stream::SyncHeader; -use hyper::Body; -use hyper::StatusCode; use once_cell::sync::Lazy; use serde::de::DeserializeOwned; use serde::Serialize; @@ -127,9 +126,10 @@ where let req = Request::from_parts(parts, body); if let Some(TypedHeader(sync_header)) = sync_header { - let stream = BodyStream::from_request(req, state) + let stream = Body::from_request(req, state) .await - .expect("infallible"); + .expect("infallible") + .into_data_stream(); SyncRequest::from_header_and_stream(sync_header, stream, ip).await } else { let multi = Multipart::from_request(req, state) diff --git a/rslib/src/sync/response.rs b/rslib/src/sync/response.rs index 09c51b3d8..843dd1447 100644 --- a/rslib/src/sync/response.rs +++ b/rslib/src/sync/response.rs @@ -3,10 +3,10 @@ use std::marker::PhantomData; -use axum::body::StreamBody; -use axum::headers::HeaderName; +use axum::body::Body; use axum::response::IntoResponse; use axum::response::Response; +use axum_extra::headers::HeaderName; use serde::de::DeserializeOwned; use serde::Serialize; @@ -39,7 +39,7 @@ impl SyncResponse { pub fn make_response(self, sync_version: SyncVersion) -> Response { if sync_version.is_zstd() { let header = (&ORIGINAL_SIZE, self.data.len().to_string()); - let body = StreamBody::new(encode_zstd_body(self.data)); + let body = Body::from_stream(encode_zstd_body(self.data)); ([header], body).into_response() } else { self.data.into_response()