From d918ef14951eedb211e82c095c9d792ec94702c1 Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 9 Jul 2024 16:24:44 -0500 Subject: [PATCH 1/5] Update rustls --- Cargo.lock | 21 +++++++++++---------- Cargo.toml | 8 ++++---- src/main.rs | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c521a5..4e19b79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ "pin-project-lite", "rustls-pki-types", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls 0.26.0", "tokio-util", "tracing", ] @@ -423,7 +423,7 @@ dependencies = [ "rsa", "rsa-magic-public-key", "ructe", - "rustls 0.22.4", + "rustls 0.23.11", "rustls-channel-resolver", "rustls-pemfile 2.1.2", "serde", @@ -3304,11 +3304,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.4" +version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "log", + "once_cell", "ring", "rustls-pki-types", "rustls-webpki 0.102.5", @@ -3318,12 +3319,12 @@ dependencies = [ [[package]] name = "rustls-channel-resolver" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbd1941204442f051576a9a7ea8e8db074ad7fd43db1eb3378c3633f9f9e166" +checksum = "fede2a247359da6b4998f7723ec6468c2d6a577a5d8c17e54f21806426ad2290" dependencies = [ "nanorand", - "rustls 0.22.4", + "rustls 0.23.11", ] [[package]] @@ -3944,11 +3945,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.22.4", + "rustls 0.23.11", "rustls-pki-types", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 90b770c..80d243d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -actix-web = { version = "4.4.0", default-features = false, features = ["compress-brotli", "compress-gzip", "rustls-0_22"] } +actix-web = { version = "4.4.0", default-features = false, features = ["compress-brotli", "compress-gzip", "rustls-0_23"] } actix-webfinger = { version = "0.5.0", default-features = false } activitystreams = "0.7.0-alpha.25" activitystreams-ext = "0.1.0-alpha.3" @@ -54,14 +54,14 @@ pin-project-lite = "0.2.9" # pinned to metrics-util quanta = "0.12.0" rand = "0.8" -reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "stream"]} +reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "stream"] } reqwest-middleware = "0.2" reqwest-tracing = "0.4.5" ring = "0.17.5" rsa = "0.9" rsa-magic-public-key = "0.8.0" -rustls = "0.22.0" -rustls-channel-resolver = "0.2.0" +rustls = { version = "0.23.0", default-features = false, features = ["ring", "logging", "std", "tls12"] } +rustls-channel-resolver = "0.3.0" rustls-pemfile = "2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/src/main.rs b/src/main.rs index a871f0a..44c53ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -418,7 +418,7 @@ async fn server_main( .with_no_client_auth() .with_cert_resolver(cert_rx); server - .bind_rustls_0_22(bind_address, server_config)? + .bind_rustls_0_23(bind_address, server_config)? .run() .await?; From f1792c8eb3bca197b1c0efb4a0e0a6d75bedb41b Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 9 Jul 2024 16:26:00 -0500 Subject: [PATCH 2/5] Update dashmap --- Cargo.lock | 18 ++++++++++++++++-- Cargo.toml | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e19b79..fe63a4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ "color-eyre", "config", "console-subscriber", - "dashmap", + "dashmap 6.0.1", "dotenv", "futures-core", "http-signature-normalization-actix", @@ -1151,6 +1151,20 @@ dependencies = [ "parking_lot_core 0.9.10", ] +[[package]] +name = "dashmap" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core 0.9.10", +] + [[package]] name = "data-encoding" version = "2.6.0" @@ -2003,7 +2017,7 @@ dependencies = [ "const-str", "cssparser", "cssparser-color", - "dashmap", + "dashmap 5.5.3", "data-encoding", "getrandom", "itertools 0.10.5", diff --git a/Cargo.toml b/Cargo.toml index 80d243d..1aa2cb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ clap = { version = "4.0.0", features = ["derive"] } color-eyre = "0.6.2" config = { version = "0.14.0", default-features = false, features = ["toml", "json", "yaml"] } console-subscriber = { version = "0.2", optional = true } -dashmap = "5.1.0" +dashmap = "6.0.1" dotenv = "0.15.0" futures-core = "0.3.30" lru = "0.12.0" From a70e75665b869b1f06ce83b800165814fad0b781 Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 9 Jul 2024 16:26:33 -0500 Subject: [PATCH 3/5] Update console-subscriber --- Cargo.lock | 44 +++++++++----------------------------------- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe63a4c..b702b51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -926,22 +926,22 @@ dependencies = [ [[package]] name = "console-api" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" +checksum = "a257c22cd7e487dd4a13d413beabc512c5052f0bc048db0da6a84c3d8a6142fd" dependencies = [ "futures-core", "prost", "prost-types", - "tonic 0.10.2", + "tonic", "tracing-core", ] [[package]] name = "console-subscriber" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e" +checksum = "31c4cc54bae66f7d9188996404abdf7fdfa23034ef8e43478c8810828abad758" dependencies = [ "console-api", "crossbeam-channel", @@ -949,13 +949,14 @@ dependencies = [ "futures-task", "hdrhistogram", "humantime", + "prost", "prost-types", "serde", "serde_json", "thread_local", "tokio", "tokio-stream", - "tonic 0.10.2", + "tonic", "tracing", "tracing-core", "tracing-subscriber", @@ -2469,7 +2470,7 @@ dependencies = [ "prost", "thiserror", "tokio", - "tonic 0.11.0", + "tonic", ] [[package]] @@ -2481,7 +2482,7 @@ dependencies = [ "opentelemetry", "opentelemetry_sdk", "prost", - "tonic 0.11.0", + "tonic", ] [[package]] @@ -4026,33 +4027,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tonic" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" -dependencies = [ - "async-stream", - "async-trait", - "axum", - "base64 0.21.7", - "bytes", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost", - "tokio", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tonic" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index 1aa2cb3..d1944ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ base64 = "0.22" clap = { version = "4.0.0", features = ["derive"] } color-eyre = "0.6.2" config = { version = "0.14.0", default-features = false, features = ["toml", "json", "yaml"] } -console-subscriber = { version = "0.2", optional = true } +console-subscriber = { version = "0.3", optional = true } dashmap = "6.0.1" dotenv = "0.15.0" futures-core = "0.3.30" From 86cab5d2d9ac75cf39dd5ba8d448386e6a84f82b Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 9 Jul 2024 16:28:00 -0500 Subject: [PATCH 4/5] Update opentelemetry stack --- Cargo.lock | 36 +++++++++++------------------------- Cargo.toml | 8 ++++---- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b702b51..336b5a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2441,9 +2441,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opentelemetry" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900d57987be3f2aeb70d385fff9b27fb74c5723cc9a52d904d4f9c807a0667bf" +checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" dependencies = [ "futures-core", "futures-sink", @@ -2451,21 +2451,19 @@ dependencies = [ "once_cell", "pin-project-lite", "thiserror", - "urlencoding", ] [[package]] name = "opentelemetry-otlp" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a016b8d9495c639af2145ac22387dcb88e44118e45320d9238fbf4e7889abcb" +checksum = "a94c69209c05319cdf7460c6d4c055ed102be242a0a6245835d7bc42c6ec7f54" dependencies = [ "async-trait", "futures-core", "http 0.2.12", "opentelemetry", "opentelemetry-proto", - "opentelemetry-semantic-conventions", "opentelemetry_sdk", "prost", "thiserror", @@ -2475,9 +2473,9 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8fddc9b68f5b80dae9d6f510b88e02396f006ad48cac349411fbecc80caae4" +checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162" dependencies = [ "opentelemetry", "opentelemetry_sdk", @@ -2485,24 +2483,18 @@ dependencies = [ "tonic", ] -[[package]] -name = "opentelemetry-semantic-conventions" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9ab5bd6c42fb9349dcf28af2ba9a0667f697f9bdcca045d39f2cec5543e2910" - [[package]] name = "opentelemetry_sdk" -version = "0.22.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e90c7113be649e31e9a0f8b5ee24ed7a16923b322c3c5ab6367469c049d6b7e" +checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" dependencies = [ "async-trait", - "crossbeam-channel", "futures-channel", "futures-executor", "futures-util", "glob", + "lazy_static", "once_cell", "opentelemetry", "ordered-float", @@ -4165,9 +4157,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9be14ba1bbe4ab79e9229f7f89fab8d120b865859f10527f31c033e599d2284" +checksum = "f68803492bf28ab40aeccaecc7021096bd256baf7ca77c3d425d89b35a7be4e4" dependencies = [ "js-sys", "once_cell", @@ -4259,12 +4251,6 @@ dependencies = [ "serde", ] -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - [[package]] name = "utf-8" version = "0.7.6" diff --git a/Cargo.toml b/Cargo.toml index d1944ee..9859e53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,9 +47,9 @@ metrics-exporter-prometheus = { version = "0.15.0", default-features = false, fe metrics-util = "0.17.0" mime = "0.3.16" minify-html = "0.15.0" -opentelemetry = "0.22" -opentelemetry_sdk = { version = "0.22", features = ["rt-tokio"] } -opentelemetry-otlp = "0.15" +opentelemetry = "0.23" +opentelemetry_sdk = { version = "0.23", features = ["rt-tokio"] } +opentelemetry-otlp = "0.16" pin-project-lite = "0.2.9" # pinned to metrics-util quanta = "0.12.0" @@ -77,7 +77,7 @@ time = { version = "0.3.17", features = ["serde"] } tracing = "0.1" tracing-error = "0.2" tracing-log = "0.2" -tracing-opentelemetry = "0.23" +tracing-opentelemetry = "0.24" tracing-subscriber = { version = "0.3", features = [ "ansi", "env-filter", From 308a945283891c80e31efb8f584ed362c9169068 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 14 Apr 2024 20:54:01 -0500 Subject: [PATCH 5/5] Start upgrading to http1 --- Cargo.lock | 193 +++++++++++++++++++++++++++++++++++++------- Cargo.toml | 10 +-- src/admin/client.rs | 11 ++- src/extractors.rs | 4 + src/http1.rs | 18 +++++ src/main.rs | 1 + src/requests.rs | 6 +- src/routes/media.rs | 7 +- 8 files changed, 207 insertions(+), 43 deletions(-) create mode 100644 src/http1.rs diff --git a/Cargo.lock b/Cargo.lock index 336b5a5..95f60cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -416,7 +416,7 @@ dependencies = [ "pin-project-lite", "quanta", "rand", - "reqwest", + "reqwest 0.12.5", "reqwest-middleware", "reqwest-tracing", "ring", @@ -534,14 +534,14 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.30", "itoa", - "matchit", + "matchit 0.7.3", "memchr", "mime", "percent-encoding", "pin-project-lite", "rustversion", "serde", - "sync_wrapper", + "sync_wrapper 0.1.2", "tower", "tower-layer", "tower-service", @@ -1718,15 +1718,15 @@ dependencies = [ [[package]] name = "http-signature-normalization-reqwest" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86048ef6b1d59bcb2cdde0100bb16b1a29ce78ab6dd4a90706ba0791a2831b5a" +checksum = "b8822f7eab343cae1ce3bd3b6d0b9b58c72adaf3463627cfe150f8f5406f27aa" dependencies = [ "async-trait", - "base64 0.21.7", + "base64 0.22.1", "http-signature-normalization", "httpdate", - "reqwest", + "reqwest 0.12.5", "reqwest-middleware", "ring", "thiserror", @@ -1809,6 +1809,24 @@ dependencies = [ "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.1", + "hyper-util", + "rustls 0.23.11", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", + "webpki-roots 0.26.3", +] + [[package]] name = "hyper-timeout" version = "0.4.1" @@ -2141,6 +2159,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "matchit" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3c2fcf089c060eb333302d80c5f3ffa8297abecf220f788e4a09ef85f59420" + [[package]] name = "md5" version = "0.7.0" @@ -2923,6 +2947,53 @@ dependencies = [ "winapi", ] +[[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.11", + "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", + "ring", + "rustc-hash", + "rustls 0.23.11", + "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" @@ -3108,7 +3179,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.30", - "hyper-rustls", + "hyper-rustls 0.24.2", "ipnet", "js-sys", "log", @@ -3122,7 +3193,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-rustls 0.24.1", @@ -3133,38 +3204,82 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots", - "winreg", + "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.1", + "hyper-rustls 0.27.2", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls 0.23.11", + "rustls-pemfile 2.1.2", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "tokio", + "tokio-rustls 0.26.0", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots 0.26.3", + "winreg 0.52.0", ] [[package]] name = "reqwest-middleware" -version = "0.2.5" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a735987236a8e238bf0296c7e351b999c188ccc11477f311b82b55c93984216" +checksum = "39346a33ddfe6be00cbc17a34ce996818b97b230b87229f10114693becca1268" dependencies = [ "anyhow", "async-trait", - "http 0.2.12", - "reqwest", + "http 1.1.0", + "reqwest 0.12.5", "serde", - "task-local-extensions", "thiserror", + "tower-service", ] [[package]] name = "reqwest-tracing" -version = "0.4.8" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190838e54153d7a7e2ea98851304b3ce92daeabf14c54d32b01b84a3e636f683" +checksum = "71a37668dccbd75e045f26811891dd939f28c38d3b7ca572a4fce4bc462b83ec" dependencies = [ "anyhow", "async-trait", "getrandom", - "matchit", - "reqwest", + "http 1.1.0", + "matchit 0.8.3", + "reqwest 0.12.5", "reqwest-middleware", - "task-local-extensions", "tracing", ] @@ -3695,6 +3810,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 = "system-configuration" version = "0.5.1" @@ -3734,15 +3855,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "task-local-extensions" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba323866e5d033818e3240feeb9f7db2c4296674e4d9e16b97b7bf8f490434e8" -dependencies = [ - "pin-utils", -] - [[package]] name = "teloxide" version = "0.12.2" @@ -3787,7 +3899,7 @@ dependencies = [ "once_cell", "pin-project", "rc-box", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "serde_with_macros", @@ -4411,6 +4523,15 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "webpki-roots" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi" version = "0.3.9" @@ -4620,6 +4741,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 = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 9859e53..da316d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,9 +54,9 @@ pin-project-lite = "0.2.9" # pinned to metrics-util quanta = "0.12.0" rand = "0.8" -reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "stream"] } -reqwest-middleware = "0.2" -reqwest-tracing = "0.4.5" +reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "stream"]} +reqwest-middleware = { version = "0.3", default-features = false, features = ["json"] } +reqwest-tracing = "0.5.0" ring = "0.17.5" rsa = "0.9" rsa-magic-public-key = "0.8.0" @@ -92,12 +92,12 @@ default-features = false features = ["error-logging", "metrics", "tokio"] [dependencies.http-signature-normalization-actix] -version = "0.11.0" +version = "0.11.1" default-features = false features = ["server", "ring"] [dependencies.http-signature-normalization-reqwest] -version = "0.11.0" +version = "0.12.0" default-features = false features = ["middleware", "ring"] diff --git a/src/admin/client.rs b/src/admin/client.rs index 88151e1..af61e1e 100644 --- a/src/admin/client.rs +++ b/src/admin/client.rs @@ -5,7 +5,6 @@ use crate::{ error::{Error, ErrorKind}, extractors::XApiToken, }; -use actix_web::http::header::Header; use reqwest_middleware::ClientWithMiddleware; use serde::de::DeserializeOwned; @@ -87,13 +86,17 @@ async fn get_results( let res = client .get(iri.as_str()) - .header(XApiToken::name(), x_api_token.to_string()) + .header(XApiToken::http1_name(), x_api_token.to_string()) .send() .await .map_err(|e| ErrorKind::SendRequest(iri.to_string(), e.to_string()))?; if !res.status().is_success() { - return Err(ErrorKind::Status(iri.to_string(), res.status()).into()); + return Err(ErrorKind::Status( + iri.to_string(), + crate::http1::status_to_http02(res.status()), + ) + .into()); } let t = res @@ -116,7 +119,7 @@ async fn post_domains( let res = client .post(iri.as_str()) - .header(XApiToken::name(), x_api_token.to_string()) + .header(XApiToken::http1_name(), x_api_token.to_string()) .json(&Domains { domains }) .send() .await diff --git a/src/extractors.rs b/src/extractors.rs index d179906..4545199 100644 --- a/src/extractors.rs +++ b/src/extractors.rs @@ -163,6 +163,10 @@ impl XApiToken { pub(crate) fn new(token: String) -> Self { Self(token) } + + pub(crate) const fn http1_name() -> reqwest::header::HeaderName { + reqwest::header::HeaderName::from_static("x-api-token") + } } impl Header for XApiToken { diff --git a/src/http1.rs b/src/http1.rs new file mode 100644 index 0000000..510c830 --- /dev/null +++ b/src/http1.rs @@ -0,0 +1,18 @@ +pub(crate) fn name_to_http02( + name: &reqwest::header::HeaderName, +) -> actix_web::http::header::HeaderName { + actix_web::http::header::HeaderName::from_bytes(name.as_ref()) + .expect("headername conversions always work") +} + +pub(crate) fn value_to_http02( + value: &reqwest::header::HeaderValue, +) -> actix_web::http::header::HeaderValue { + actix_web::http::header::HeaderValue::from_bytes(value.as_bytes()) + .expect("headervalue conversions always work") +} + +pub(crate) fn status_to_http02(status: reqwest::StatusCode) -> actix_web::http::StatusCode { + actix_web::http::StatusCode::from_u16(status.as_u16()) + .expect("statuscode conversions always work") +} diff --git a/src/main.rs b/src/main.rs index 44c53ec..e3fdddb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,7 @@ mod db; mod error; mod extractors; mod future; +mod http1; mod jobs; mod middleware; mod requests; diff --git a/src/requests.rs b/src/requests.rs index 63faa3c..f9f122b 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -233,7 +233,11 @@ impl Requests { } } - return Err(ErrorKind::Status(parsed_url.to_string(), status).into()); + return Err(ErrorKind::Status( + parsed_url.to_string(), + crate::http1::status_to_http02(status), + ) + .into()); } // only actually succeed a breaker on 2xx response diff --git a/src/routes/media.rs b/src/routes/media.rs index 686ab22..f2758bb 100644 --- a/src/routes/media.rs +++ b/src/routes/media.rs @@ -23,10 +23,13 @@ pub(crate) async fn route( .fetch_response(&url, BreakerStrategy::Allow404AndBelow) .await?; - let mut response = HttpResponse::build(res.status()); + let mut response = HttpResponse::build(crate::http1::status_to_http02(res.status())); for (name, value) in res.headers().iter().filter(|(h, _)| *h != "connection") { - response.insert_header((name.clone(), value.clone())); + response.insert_header(( + crate::http1::name_to_http02(name), + crate::http1::value_to_http02(value), + )); } return Ok(response.body(BodyStream::new(limit_stream(