From 3bd83fb0c1cfa43213f2cbce7dbb6b1e5ff0d1b9 Mon Sep 17 00:00:00 2001 From: Glen De Cauwsemaecker Date: Thu, 20 Feb 2025 21:27:04 +0100 Subject: [PATCH] bump MSRV to 1.85 (edition 2024) + fix all issues that come from it --- .github/workflows/CI.yml | 2 +- CONTRIBUTING.md | 4 +- Cargo.toml | 4 +- README.md | 4 +- benches/h2.rs | 7 +- benches/http_core_body.rs | 2 +- benches/http_core_end_to_end.rs | 23 +- benches/http_core_pipeline.rs | 2 +- benches/http_core_server.rs | 2 +- docs/book/src/crate.md | 2 +- examples/http_conn_state.rs | 6 +- examples/http_connect_proxy.rs | 6 +- examples/http_form.rs | 6 +- examples/http_high_level_client.rs | 8 +- examples/http_key_value_store.rs | 8 +- examples/http_listener_hello.rs | 2 +- examples/http_mitm_proxy.rs | 8 +- examples/http_rate_limit.rs | 6 +- examples/http_service_fs.rs | 2 +- examples/http_service_hello.rs | 9 +- examples/http_service_match.rs | 6 +- examples/http_telemetry.rs | 9 +- examples/http_user_agent_classifier.rs | 4 +- examples/http_web_service_dir_and_api.rs | 8 +- examples/https_connect_proxy.rs | 8 +- examples/mtls_tunnel_and_service.rs | 4 +- examples/tcp_listener_layers.rs | 4 +- examples/tls_boring_dynamic_certs.rs | 6 +- examples/tls_boring_termination.rs | 6 +- examples/tls_termination.rs | 4 +- fuzz/Cargo.toml | 2 +- fuzz/fuzz_targets/h2_e2e.rs | 4 +- rama-cli/README.md | 2 +- rama-cli/src/cmd/echo/mod.rs | 14 +- rama-cli/src/cmd/fp/data.rs | 8 +- rama-cli/src/cmd/fp/endpoints.rs | 10 +- rama-cli/src/cmd/fp/mod.rs | 14 +- rama-cli/src/cmd/http/mod.rs | 14 +- rama-cli/src/cmd/ip/mod.rs | 4 +- rama-cli/src/cmd/proxy/mod.rs | 8 +- rama-core/README.md | 2 +- rama-core/src/combinators/mod.rs | 2 +- rama-core/src/graceful.rs | 2 +- rama-core/src/layer/add_extension.rs | 2 +- rama-core/src/layer/consume_err.rs | 2 +- rama-core/src/layer/get_extension.rs | 2 +- rama-core/src/layer/hijack.rs | 2 +- rama-core/src/layer/layer_fn.rs | 2 +- rama-core/src/layer/limit/layer.rs | 2 +- rama-core/src/layer/limit/mod.rs | 4 +- .../src/layer/limit/policy/concurrent.rs | 2 +- rama-core/src/layer/limit/policy/matcher.rs | 2 +- rama-core/src/layer/limit/policy/mod.rs | 6 +- rama-core/src/layer/mod.rs | 2 +- rama-core/src/layer/timeout/layer.rs | 4 +- rama-core/src/matcher/ext.rs | 2 +- rama-core/src/matcher/iter.rs | 2 +- rama-core/src/matcher/mfn.rs | 2 +- rama-core/src/matcher/mod.rs | 4 +- rama-core/src/matcher/op_and.rs | 2 +- rama-core/src/matcher/op_not.rs | 2 +- rama-core/src/matcher/op_or.rs | 2 +- rama-core/src/service/svc.rs | 2 +- rama-core/src/username/mod.rs | 6 +- rama-core/src/username/parse.rs | 2 +- rama-dns/README.md | 2 +- rama-dns/src/chain.rs | 45 +-- rama-dns/src/hickory.rs | 2 +- rama-dns/src/in_memory.rs | 70 ++-- rama-error/README.md | 2 +- rama-haproxy/README.md | 2 +- rama-haproxy/src/client/layer.rs | 43 ++- rama-haproxy/src/client/mod.rs | 2 +- rama-haproxy/src/protocol/v1/error.rs | 29 +- rama-haproxy/src/protocol/v1/mod.rs | 11 +- rama-haproxy/src/protocol/v2/builder.rs | 4 +- rama-haproxy/src/protocol/v2/error.rs | 53 ++- rama-haproxy/src/protocol/v2/mod.rs | 4 +- rama-haproxy/src/server/layer.rs | 15 +- rama-http-backend/README.md | 2 +- rama-http-backend/src/client/conn.rs | 8 +- rama-http-backend/src/client/mod.rs | 4 +- .../src/client/proxy/layer/proxy_address.rs | 14 +- .../client/proxy/layer/proxy_auth_header.rs | 2 +- .../proxy/layer/proxy_connector/connector.rs | 2 +- .../proxy/layer/proxy_connector/service.rs | 6 +- rama-http-backend/src/client/svc.rs | 4 +- rama-http-backend/src/server/hyper_conn.rs | 2 +- .../src/server/layer/upgrade/layer.rs | 4 +- .../src/server/layer/upgrade/service.rs | 2 +- rama-http-backend/src/server/service.rs | 2 +- rama-http-core/README.md | 2 +- rama-http-core/examples/h2_client.rs | 2 +- rama-http-core/examples/h2_example.rs | 2 +- rama-http-core/examples/h2_server.rs | 2 +- rama-http-core/src/body/incoming.rs | 4 +- rama-http-core/src/client/conn/http1.rs | 4 +- rama-http-core/src/client/dispatch.rs | 2 +- rama-http-core/src/common/watch.rs | 2 +- rama-http-core/src/ext/mod.rs | 2 +- rama-http-core/src/h2/client.rs | 2 +- rama-http-core/src/h2/error.rs | 6 +- rama-http-core/src/h2/frame/data.rs | 2 +- rama-http-core/src/h2/frame/headers.rs | 8 +- rama-http-core/src/h2/frame/mod.rs | 2 +- rama-http-core/src/h2/frame/settings.rs | 2 +- rama-http-core/src/h2/hpack/decoder.rs | 2 +- rama-http-core/src/h2/hpack/encoder.rs | 4 +- rama-http-core/src/h2/hpack/test/fuzz.rs | 2 +- rama-http-core/src/h2/proto/connection.rs | 9 +- rama-http-core/src/h2/proto/ping_pong.rs | 2 +- .../src/h2/proto/streams/flow_control.rs | 8 +- rama-http-core/src/h2/proto/streams/recv.rs | 4 +- rama-http-core/src/h2/proto/streams/send.rs | 4 +- .../src/h2/proto/streams/streams.rs | 11 +- rama-http-core/src/h2/server.rs | 2 +- rama-http-core/src/h2/share.rs | 2 +- rama-http-core/src/headers.rs | 2 +- rama-http-core/src/proto/h1/conn.rs | 4 +- rama-http-core/src/proto/h1/decode.rs | 4 +- rama-http-core/src/proto/h1/dispatch.rs | 14 +- rama-http-core/src/proto/h1/encode.rs | 12 +- rama-http-core/src/proto/h1/io.rs | 8 +- rama-http-core/src/proto/h1/role.rs | 52 ++- rama-http-core/src/proto/h2/client.rs | 8 +- rama-http-core/src/proto/h2/mod.rs | 12 +- rama-http-core/src/proto/h2/server.rs | 16 +- rama-http-core/src/proto/mod.rs | 4 +- rama-http-core/src/server/conn/auto.rs | 6 +- rama-http-core/src/service.rs | 2 +- rama-http-core/tests/h2-fuzz/Cargo.toml | 2 +- rama-http-core/tests/h2-fuzz/src/main.rs | 6 +- rama-http-core/tests/h2-support/Cargo.toml | 2 +- rama-http-core/tests/h2-support/src/frames.rs | 2 +- .../tests/h2-support/src/future_ext.rs | 2 +- rama-http-core/tests/h2-support/src/mock.rs | 4 +- .../tests/h2-support/src/prelude.rs | 6 +- rama-http-core/util/genfixture/Cargo.toml | 2 +- rama-http-core/util/genhuff/Cargo.toml | 2 +- rama-http-types/README.md | 2 +- rama-http-types/src/proto/h1/headers/map.rs | 4 +- rama-http-types/src/proto/h1/headers/name.rs | 4 +- rama-http-types/src/proto/h2/pseudo_header.rs | 2 +- rama-http-types/src/response/csv.rs | 4 +- rama-http-types/src/response/form.rs | 2 +- rama-http-types/src/response/into_response.rs | 6 +- .../src/response/into_response_parts.rs | 2 +- rama-http-types/src/response/json.rs | 2 +- rama-http-types/src/response/redirect.rs | 2 +- rama-http/README.md | 2 +- rama-http/src/headers/forwarded/via.rs | 6 +- .../src/headers/forwarded/x_forwarded_for.rs | 6 +- rama-http/src/headers/util/csv.rs | 2 +- rama-http/src/io/request.rs | 2 +- rama-http/src/io/response.rs | 2 +- .../layer/auth/async_require_authorization.rs | 4 +- .../src/layer/auth/require_authorization.rs | 4 +- rama-http/src/layer/body_limit.rs | 4 +- rama-http/src/layer/classify/mod.rs | 5 +- .../classify/status_in_range_is_error.rs | 16 +- rama-http/src/layer/collect_body.rs | 4 +- rama-http/src/layer/compression/body.rs | 2 +- rama-http/src/layer/compression/layer.rs | 2 +- rama-http/src/layer/compression/predicate.rs | 2 +- rama-http/src/layer/compression/service.rs | 8 +- rama-http/src/layer/cors/allow_headers.rs | 2 +- rama-http/src/layer/cors/allow_methods.rs | 4 +- .../src/layer/cors/allow_private_network.rs | 4 +- rama-http/src/layer/cors/expose_headers.rs | 2 +- rama-http/src/layer/cors/mod.rs | 2 +- rama-http/src/layer/cors/tests.rs | 2 +- rama-http/src/layer/cors/vary.rs | 2 +- rama-http/src/layer/decompression/body.rs | 2 +- .../src/layer/decompression/request/mod.rs | 4 +- .../layer/decompression/request/service.rs | 16 +- rama-http/src/layer/decompression/service.rs | 6 +- rama-http/src/layer/dns/dns_resolve/layer.rs | 4 +- .../src/layer/dns/dns_resolve/service.rs | 10 +- .../layer/dns/dns_resolve/username_parser.rs | 2 +- rama-http/src/layer/follow_redirect/mod.rs | 8 +- .../src/layer/follow_redirect/policy/and.rs | 32 +- .../policy/filter_credentials.rs | 20 +- .../layer/follow_redirect/policy/limited.rs | 16 +- .../src/layer/follow_redirect/policy/mod.rs | 4 +- .../src/layer/follow_redirect/policy/or.rs | 32 +- .../follow_redirect/policy/same_origin.rs | 18 +- .../src/layer/forwarded/get_forwarded.rs | 6 +- .../src/layer/forwarded/set_forwarded.rs | 6 +- rama-http/src/layer/header_config.rs | 6 +- rama-http/src/layer/header_option_value.rs | 4 +- rama-http/src/layer/normalize_path.rs | 2 +- rama-http/src/layer/opentelemetry.rs | 117 ++++--- rama-http/src/layer/propagate_headers.rs | 2 +- rama-http/src/layer/proxy_auth.rs | 4 +- rama-http/src/layer/remove_header/mod.rs | 2 +- rama-http/src/layer/remove_header/request.rs | 2 +- rama-http/src/layer/remove_header/response.rs | 2 +- rama-http/src/layer/request_id.rs | 6 +- .../src/layer/required_header/request.rs | 4 +- .../src/layer/required_header/response.rs | 4 +- rama-http/src/layer/retry/mod.rs | 12 +- rama-http/src/layer/retry/tests.rs | 6 +- rama-http/src/layer/sensitive_headers.rs | 16 +- .../src/layer/set_header/request/header.rs | 2 +- rama-http/src/layer/set_header/request/mod.rs | 2 +- .../src/layer/set_header/response/header.rs | 2 +- .../src/layer/set_header/response/mod.rs | 4 +- rama-http/src/layer/trace/layer.rs | 32 +- rama-http/src/layer/trace/on_eos.rs | 2 +- rama-http/src/layer/trace/on_failure.rs | 2 +- rama-http/src/layer/trace/on_response.rs | 2 +- rama-http/src/layer/trace/service.rs | 60 ++-- rama-http/src/layer/traffic_writer/mod.rs | 4 +- rama-http/src/layer/traffic_writer/request.rs | 4 +- .../src/layer/traffic_writer/response.rs | 4 +- rama-http/src/layer/ua.rs | 6 +- rama-http/src/layer/util/compression.rs | 4 +- .../layer/validate_request/accept_header.rs | 3 +- .../validate_request_header.rs | 4 +- rama-http/src/lib.rs | 5 +- rama-http/src/matcher/domain.rs | 2 +- rama-http/src/matcher/header.rs | 2 +- rama-http/src/matcher/method.rs | 2 +- rama-http/src/matcher/mod.rs | 8 +- rama-http/src/matcher/path/de.rs | 8 +- rama-http/src/matcher/path/mod.rs | 2 +- rama-http/src/matcher/uri.rs | 2 +- rama-http/src/matcher/version.rs | 2 +- rama-http/src/service/client/ext.rs | 10 +- rama-http/src/service/fs/serve_dir/future.rs | 4 +- rama-http/src/service/fs/serve_dir/mod.rs | 4 +- .../src/service/fs/serve_dir/open_file.rs | 4 +- rama-http/src/service/fs/serve_dir/tests.rs | 24 +- rama-http/src/service/fs/serve_file.rs | 4 +- rama-http/src/service/redirect.rs | 2 +- .../service/web/endpoint/extract/authority.rs | 2 +- .../web/endpoint/extract/body/bytes.rs | 2 +- .../service/web/endpoint/extract/body/csv.rs | 4 +- .../service/web/endpoint/extract/body/json.rs | 4 +- .../service/web/endpoint/extract/body/text.rs | 4 +- .../src/service/web/endpoint/extract/host.rs | 2 +- .../service/web/endpoint/extract/method.rs | 2 +- .../src/service/web/endpoint/extract/mod.rs | 2 +- .../service/web/endpoint/extract/option.rs | 2 +- .../web/endpoint/extract/typed_header.rs | 2 +- rama-http/src/service/web/endpoint/mod.rs | 6 +- rama-http/src/service/web/endpoint/service.rs | 2 +- rama-http/src/service/web/k8s.rs | 4 +- rama-http/src/service/web/mod.rs | 4 +- rama-http/src/service/web/service.rs | 12 +- rama-http/src/utils/header_value.rs | 2 +- rama-macros/README.md | 2 +- rama-net/README.md | 2 +- rama-net/src/address/authority.rs | 2 +- rama-net/src/address/domain_address.rs | 2 +- rama-net/src/address/host.rs | 2 +- rama-net/src/address/proxy.rs | 2 +- rama-net/src/client/conn.rs | 16 +- rama-net/src/fingerprint/ja3.rs | 97 +++++- rama-net/src/fingerprint/ja4/http.rs | 2 +- rama-net/src/fingerprint/ja4/tls.rs | 317 ++++++++++++++++-- rama-net/src/forwarded/element/parser.rs | 4 +- rama-net/src/forwarded/mod.rs | 22 +- rama-net/src/forwarded/node.rs | 89 +++-- rama-net/src/forwarded/obfuscated.rs | 26 +- rama-net/src/http/request_context.rs | 6 +- rama-net/src/proto.rs | 5 +- rama-net/src/stream/layer/opentelemetry.rs | 118 ++++--- rama-net/src/stream/layer/tracker/bytes.rs | 5 +- rama-net/src/stream/matcher/ip.rs | 2 +- rama-net/src/stream/matcher/loopback.rs | 2 +- rama-net/src/stream/matcher/mod.rs | 14 +- rama-net/src/stream/matcher/port.rs | 2 +- rama-net/src/stream/matcher/private_ip.rs | 2 +- rama-net/src/stream/matcher/socket.rs | 2 +- rama-net/src/stream/read.rs | 2 +- rama-net/src/stream/service/echo.rs | 2 +- rama-net/src/tls/client/config.rs | 2 +- rama-net/src/tls/client/hello/mod.rs | 16 +- rama-net/src/tls/client/parser.rs | 12 +- rama-net/src/tls/enums/mod.rs | 2 +- rama-net/src/tls/server/config.rs | 2 +- rama-net/src/transport.rs | 6 +- rama-net/src/user/auth.rs | 2 +- rama-net/src/user/credentials/basic.rs | 4 +- rama-net/src/user/credentials/bearer.rs | 2 +- rama-proxy/README.md | 2 +- rama-proxy/src/lib.rs | 2 +- rama-proxy/src/proxydb/csv.rs | 18 +- rama-proxy/src/proxydb/internal.rs | 6 +- rama-proxy/src/proxydb/layer.rs | 12 +- rama-proxy/src/proxydb/mod.rs | 42 ++- rama-proxy/src/proxydb/update.rs | 62 ++-- rama-proxy/src/username.rs | 19 +- rama-socks5/README.md | 2 +- rama-tcp/README.md | 2 +- rama-tcp/src/client/connect.rs | 22 +- rama-tcp/src/client/mod.rs | 2 +- rama-tcp/src/client/request.rs | 2 +- rama-tcp/src/client/service/connector.rs | 2 +- rama-tcp/src/client/service/forward.rs | 12 +- rama-tcp/src/client/service/select.rs | 18 +- rama-tcp/src/server/listener.rs | 4 +- rama-tls/README.md | 2 +- rama-tls/src/boring/client/connector.rs | 4 +- rama-tls/src/boring/client/connector_data.rs | 30 +- rama-tls/src/boring/server/acceptor_data.rs | 19 +- rama-tls/src/boring/server/service.rs | 6 +- rama-tls/src/keylog.rs | 2 +- rama-tls/src/lib.rs | 4 +- rama-tls/src/rustls/client/connector.rs | 4 +- rama-tls/src/rustls/client/connector_data.rs | 8 +- rama-tls/src/rustls/key_log.rs | 2 +- rama-tls/src/rustls/server/acceptor_data.rs | 8 +- rama-tls/src/rustls/server/service.rs | 6 +- rama-tls/src/rustls/verify.rs | 2 +- rama-ua/README.md | 2 +- rama-ua/src/info.rs | 15 +- rama-ua/src/parse.rs | 4 +- rama-ua/src/parse_tests.rs | 14 +- rama-udp/README.md | 2 +- rama-utils/README.md | 2 +- src/cli/args.rs | 91 ++--- src/cli/service/echo.rs | 12 +- src/cli/service/ip.rs | 10 +- src/http.rs | 6 +- src/lib.rs | 4 +- tests/http-core/client.rs | 26 +- .../examples/example_tests/utils/mod.rs | 2 +- tests/http-core/h2/client_request.rs | 4 +- tests/http-core/h2/hammer.rs | 2 +- tests/http-core/h2/ping_pong.rs | 2 +- tests/http-core/h2/prioritization.rs | 4 +- tests/http-core/h2/server.rs | 8 +- tests/http-core/server.rs | 10 +- tests/http-core/support/mod.rs | 6 +- .../examples/example_tests/http_conn_state.rs | 2 +- .../example_tests/http_connect_proxy.rs | 6 +- .../examples/example_tests/http_form.rs | 2 +- .../example_tests/http_health_check.rs | 2 +- .../examples/example_tests/http_k8s_health.rs | 2 +- .../example_tests/http_key_value_store.rs | 2 +- .../example_tests/http_listener_hello.rs | 4 +- .../examples/example_tests/http_mitm_proxy.rs | 8 +- .../examples/example_tests/http_rate_limit.rs | 2 +- .../examples/example_tests/http_service_fs.rs | 2 +- .../example_tests/http_service_hello.rs | 2 +- .../example_tests/http_service_match.rs | 2 +- .../examples/example_tests/http_telemetry.rs | 2 +- .../http_user_agent_classifier.rs | 4 +- .../http_web_service_dir_and_api.rs | 2 +- .../example_tests/https_connect_proxy.rs | 6 +- .../example_tests/mtls_tunnel_and_service.rs | 4 +- .../example_tests/tcp_listener_hello.rs | 2 +- .../example_tests/tcp_listener_layers.rs | 2 +- .../example_tests/tls_boring_dynamic_certs.rs | 6 +- .../example_tests/tls_boring_termination.rs | 2 +- .../examples/example_tests/tls_termination.rs | 2 +- .../examples/example_tests/utils/mod.rs | 8 +- 359 files changed, 1831 insertions(+), 1282 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2a2737078..50d597f50 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,7 +4,7 @@ env: CARGO_TERM_COLOR: always RUST_TOOLCHAIN: stable RUST_TOOLCHAIN_NIGHTLY: nightly - RUST_TOOLCHAIN_MSRV: 1.84.0 + RUST_TOOLCHAIN_MSRV: 1.85.0 RUST_TOOLCHAIN_BETA: beta on: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ddd2ca226..fc570e02c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,10 +48,10 @@ just qa Before you can do this you do require the following to be installed: -* `Rust`, version 1.84 or beyond: +* `Rust`, version 1.85 or beyond: * `just` (to run _just_ (config) files): * `cargo hack`: Once this is all done you should be able to run `just qa`. When all these pass you can be pretty certain that all tests in the GitHub CI step -will also succeed. The difference still though is that GitHub Action will also run some of these tests on the MSRV (`1.84`) and three platforms in total: MacOS, Linux and Windows. +will also succeed. The difference still though is that GitHub Action will also run some of these tests on the MSRV (`1.85`) and three platforms in total: MacOS, Linux and Windows. diff --git a/Cargo.toml b/Cargo.toml index 550af6344..1a19d1041 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,13 +27,13 @@ members = [ [workspace.package] version = "0.2.0-alpha.7" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" repository = "https://github.com/plabayo/rama" homepage = "https://ramaproxy.org" keywords = ["io", "async", "non-blocking", "service", "rama"] categories = ["asynchronous", "network-programming", "web-programming", "web-programming::http-client", "web-programming::http-server"] authors = ["Glen De Cauwsemaecker "] -rust-version = "1.84.0" +rust-version = "1.85.0" [workspace.dependencies] async-compression = "0.4" diff --git a/README.md b/README.md index f9e0e1132..3bef4aac8 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions @@ -389,7 +389,7 @@ support as many as we reasonably can. ### Minimum supported Rust version -Rama's MSRV is `1.84`. +Rama's MSRV is `1.85`. [Using GitHub Actions we also test](https://github.com/plabayo/rama/blob/main/.github/workflows/CI.yml) if `rama` on that version still works on the stable and beta versions of _rust_ as well. diff --git a/benches/h2.rs b/benches/h2.rs index a4b2f0cbb..521330277 100644 --- a/benches/h2.rs +++ b/benches/h2.rs @@ -1,14 +1,13 @@ +use rama::http::Request; use rama::http::core::h2::{ - client, + RecvStream, client, server::{self, SendResponse}, - RecvStream, }; -use rama::http::Request; use bytes::Bytes; use tokio::net::{TcpListener, TcpStream}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; use std::{ error::Error, diff --git a/benches/http_core_body.rs b/benches/http_core_body.rs index 3fb9f0494..5bda2ff5e 100644 --- a/benches/http_core_body.rs +++ b/benches/http_core_body.rs @@ -1,8 +1,8 @@ #![deny(warnings)] use bytes::Buf; -use futures_util::stream; use futures_util::StreamExt; +use futures_util::stream; use rama::http::dep::http_body::Frame; use rama::http::dep::http_body_util::{BodyExt, StreamBody}; diff --git a/benches/http_core_end_to_end.rs b/benches/http_core_end_to_end.rs index 76b728ed8..191f1a999 100644 --- a/benches/http_core_end_to_end.rs +++ b/benches/http_core_end_to_end.rs @@ -311,7 +311,7 @@ impl Opts { Http2(rama::http::core::client::conn::http2::SendRequest), } - let mut client = rt.block_on(async { + let client = rt.block_on(async { if self.http2 { let tcp = tokio::net::TcpStream::connect(&addr).await.unwrap(); let (tx, conn) = @@ -371,20 +371,15 @@ impl Opts { req }; - let mut send_request = |req| { - let fut = match client { - Client::Http1(ref mut tx) => { - futures_util::future::Either::Left(tx.send_request(req)) - } - Client::Http2(ref mut tx) => { - futures_util::future::Either::Right(tx.send_request(req)) - } + let client_ref = &client; + + let send_request = async |req| { + let res = match client_ref { + Client::Http1(tx) => tx.send_request(req).await.expect("client wait h1"), + Client::Http2(tx) => tx.send_request(req).await.expect("client wait h2"), }; - async { - let res = fut.await.expect("client wait"); - let mut body = res.into_body(); - while let Some(_chunk) = body.frame().await {} - } + let mut body = res.into_body(); + while let Some(_chunk) = body.frame().await {} }; let bytes_per_iter = (req_len + self.response_body.len() as u64) * self.parallel_cnt as u64; diff --git a/benches/http_core_pipeline.rs b/benches/http_core_pipeline.rs index 36eb7ced0..8ee2f991b 100644 --- a/benches/http_core_pipeline.rs +++ b/benches/http_core_pipeline.rs @@ -10,9 +10,9 @@ use bytes::Bytes; use tokio::net::TcpListener; use tokio::sync::oneshot; +use rama::http::Response; use rama::http::core::server::conn::http1; use rama::http::dep::http_body_util::Full; -use rama::http::Response; use rama::service::service_fn; #[global_allocator] diff --git a/benches/http_core_server.rs b/benches/http_core_server.rs index ee86dd491..18dd73de1 100644 --- a/benches/http_core_server.rs +++ b/benches/http_core_server.rs @@ -7,8 +7,8 @@ use std::time::Duration; use tokio::sync::oneshot; -use rama::http::core::server::conn::http1; use rama::http::Response; +use rama::http::core::server::conn::http1; use rama::service::service_fn; #[global_allocator] diff --git a/docs/book/src/crate.md b/docs/book/src/crate.md index 982385718..8ddddeb38 100644 --- a/docs/book/src/crate.md +++ b/docs/book/src/crate.md @@ -88,7 +88,7 @@ support as many as we reasonably can. ### Minimum supported Rust version -Rama's MSRV is `1.84`. +Rama's MSRV is `1.85`. [Using GitHub Actions we also test](https://github.com/plabayo/rama/blob/main/.github/workflows/CI.yml) if `rama` on that version still works on the stable and beta versions of _rust_ as well. diff --git a/examples/http_conn_state.rs b/examples/http_conn_state.rs index 450b38a59..411727acf 100644 --- a/examples/http_conn_state.rs +++ b/examples/http_conn_state.rs @@ -26,18 +26,18 @@ //! connection index and count of requests within that connection. use rama::{ - http::{response::Html, server::HttpServer, Request}, + Context, Layer, + http::{Request, response::Html, server::HttpServer}, layer::MapStateLayer, rt::Executor, service::service_fn, tcp::server::TcpListener, - Context, Layer, }; use std::{ convert::Infallible, sync::{ - atomic::{AtomicBool, AtomicUsize}, Arc, + atomic::{AtomicBool, AtomicUsize}, }, time::Duration, }; diff --git a/examples/http_connect_proxy.rs b/examples/http_connect_proxy.rs index 83e9414b7..04d4c7182 100644 --- a/examples/http_connect_proxy.rs +++ b/examples/http_connect_proxy.rs @@ -57,8 +57,10 @@ //! ``` use rama::{ + Context, Layer, Service, context::Extensions, http::{ + Body, IntoResponse, Request, Response, StatusCode, client::HttpClient, layer::{ proxy_auth::ProxyAuthLayer, @@ -70,7 +72,6 @@ use rama::{ response::Json, server::HttpServer, service::web::{extract::Path, match_service}, - Body, IntoResponse, Request, Response, StatusCode, }, layer::HijackLayer, net::http::RequestContext, @@ -82,13 +83,12 @@ use rama::{ username::{ UsernameLabelParser, UsernameLabelState, UsernameLabels, UsernameOpaqueLabelParser, }, - Context, Layer, Service, }; use serde::Deserialize; use serde_json::json; use std::{convert::Infallible, sync::Arc, time::Duration}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { diff --git a/examples/http_form.rs b/examples/http_form.rs index ad9841bed..bf149b3b2 100644 --- a/examples/http_form.rs +++ b/examples/http_form.rs @@ -35,17 +35,17 @@ //! and fill the form in the browser, you should see a response page after submitting the form, //! stating your name and age. +use rama::Layer; use rama::http::layer::trace::TraceLayer; use rama::http::matcher::HttpMatcher; use rama::http::response::Html; -use rama::http::service::web::{extract::Form, WebService}; +use rama::http::service::web::{WebService, extract::Form}; use rama::http::{IntoResponse, Response}; -use rama::Layer; use rama::{http::server::HttpServer, rt::Executor}; use serde::{Deserialize, Serialize}; use std::time::Duration; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[derive(Serialize, Deserialize, Debug)] struct Payload { diff --git a/examples/http_high_level_client.rs b/examples/http_high_level_client.rs index 0da4f800f..c6fb92463 100644 --- a/examples/http_high_level_client.rs +++ b/examples/http_high_level_client.rs @@ -13,9 +13,11 @@ // rama provides everything out of the box to build a complete web service. use rama::{ + Context, Layer, Service, http::{ + Body, BodyExtractExt, IntoResponse, Request, Response, StatusCode, client::HttpClient, - headers::{authorization::Basic, Accept, Authorization, HeaderMapExt}, + headers::{Accept, Authorization, HeaderMapExt, authorization::Basic}, layer::{ auth::{AddAuthorizationLayer, AsyncRequireAuthorizationLayer}, compression::CompressionLayer, @@ -27,11 +29,9 @@ use rama::{ server::HttpServer, service::client::HttpClientExt, service::web::WebService, - Body, BodyExtractExt, IntoResponse, Request, Response, StatusCode, }, rt::Executor, utils::{backoff::ExponentialBackoff, rng::HasherRng}, - Context, Layer, Service, }; // Everything else we need is provided by the standard library, community crates or tokio. @@ -41,7 +41,7 @@ use std::time::Duration; use tracing::level_filters::LevelFilter; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; const ADDRESS: &str = "127.0.0.1:62004"; diff --git a/examples/http_key_value_store.rs b/examples/http_key_value_store.rs index c67334622..aff0024ba 100644 --- a/examples/http_key_value_store.rs +++ b/examples/http_key_value_store.rs @@ -52,7 +52,9 @@ //! ``` use rama::{ + Context, Layer, http::{ + IntoResponse, Method, StatusCode, layer::{ compression::CompressionLayer, trace::TraceLayer, validate_request::ValidateRequestHeaderLayer, @@ -61,13 +63,11 @@ use rama::{ response::Json, server::HttpServer, service::web::{ - extract::{Bytes, Path}, IntoEndpointService, WebService, + extract::{Bytes, Path}, }, - IntoResponse, Method, StatusCode, }, rt::Executor, - Context, Layer, }; use serde::Deserialize; use serde_json::json; @@ -76,7 +76,7 @@ use tokio::sync::RwLock; use tracing::level_filters::LevelFilter; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; #[derive(Debug, Default)] struct AppState { diff --git a/examples/http_listener_hello.rs b/examples/http_listener_hello.rs index ee4b834b8..7f728ceb7 100644 --- a/examples/http_listener_hello.rs +++ b/examples/http_listener_hello.rs @@ -20,7 +20,7 @@ use std::net::{IpAddr, Ipv4Addr}; use rama::{ - http::{response::Json, server::HttpServer, Request}, + http::{Request, response::Json, server::HttpServer}, rt::Executor, service::service_fn, }; diff --git a/examples/http_mitm_proxy.rs b/examples/http_mitm_proxy.rs index 13c5856a9..0fc28c14e 100644 --- a/examples/http_mitm_proxy.rs +++ b/examples/http_mitm_proxy.rs @@ -39,8 +39,10 @@ //! ``` use rama::{ + Layer, Service, error::{BoxError, ErrorContext, OpaqueError}, http::{ + Body, IntoResponse, Request, Response, StatusCode, client::HttpClient, layer::{ map_response_body::MapResponseBodyLayer, @@ -53,26 +55,24 @@ use rama::{ }, matcher::MethodMatcher, server::HttpServer, - Body, IntoResponse, Request, Response, StatusCode, }, layer::ConsumeErrLayer, net::http::RequestContext, net::stream::layer::http::BodyLimitLayer, net::tls::{ + ApplicationProtocol, client::{ClientConfig, ClientHelloExtension, ServerVerifyMode}, server::{SelfSignedData, ServerAuth, ServerConfig}, - ApplicationProtocol, }, net::user::Basic, rt::Executor, service::service_fn, tcp::server::TcpListener, tls::std::server::{TlsAcceptorData, TlsAcceptorLayer}, - Layer, Service, }; use std::{convert::Infallible, time::Duration}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[derive(Debug, Clone)] struct State { diff --git a/examples/http_rate_limit.rs b/examples/http_rate_limit.rs index 93093f68f..2dd71b937 100644 --- a/examples/http_rate_limit.rs +++ b/examples/http_rate_limit.rs @@ -40,12 +40,12 @@ use rama::{ combinators::Either, error::BoxError, http::{ - matcher::HttpMatcher, response::Json, server::HttpServer, HeaderName, HeaderValue, - IntoResponse, Request, Response, StatusCode, + HeaderName, HeaderValue, IntoResponse, Request, Response, StatusCode, matcher::HttpMatcher, + response::Json, server::HttpServer, }, layer::{ - limit::policy::{ConcurrentPolicy, LimitReached}, Layer, LimitLayer, MapResultLayer, TraceErrLayer, + limit::policy::{ConcurrentPolicy, LimitReached}, }, net::stream::matcher::SocketMatcher, rt::Executor, diff --git a/examples/http_service_fs.rs b/examples/http_service_fs.rs index b7a60099c..dbc777d89 100644 --- a/examples/http_service_fs.rs +++ b/examples/http_service_fs.rs @@ -17,11 +17,11 @@ //! You should see a response with `HTTP/1.1 200 OK` and the content of the `index.html` file. use rama::{ + Layer, http::{server::HttpServer, service::fs::ServeDir}, layer::TraceErrLayer, rt::Executor, tcp::server::TcpListener, - Layer, }; #[tokio::main] diff --git a/examples/http_service_hello.rs b/examples/http_service_hello.rs index fb1523188..b596d2e75 100644 --- a/examples/http_service_hello.rs +++ b/examples/http_service_hello.rs @@ -21,8 +21,9 @@ use bytes::Bytes; use rama::{ + Context, Layer, http::{ - header, + IntoResponse, Request, header, layer::{ compression::CompressionLayer, sensitive_headers::{ @@ -32,22 +33,20 @@ use rama::{ }, response::Html, server::HttpServer, - IntoResponse, Request, }, layer::{MapResponseLayer, TimeoutLayer, TraceErrLayer}, net::stream::{ - layer::{BytesRWTrackerHandle, IncomingBytesTrackerLayer}, SocketInfo, + layer::{BytesRWTrackerHandle, IncomingBytesTrackerLayer}, }, rt::Executor, service::service_fn, tcp::server::TcpListener, utils::latency::LatencyUnit, - Context, Layer, }; use std::{sync::Arc, time::Duration}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { diff --git a/examples/http_service_match.rs b/examples/http_service_match.rs index 167343a51..eaa613d7c 100644 --- a/examples/http_service_match.rs +++ b/examples/http_service_match.rs @@ -21,16 +21,16 @@ // rama provides everything out of the box to build a complete web service. use rama::{ + Layer, http::{ + Request, layer::trace::TraceLayer, matcher::{HttpMatcher, PathMatcher}, response::{Html, Json, Redirect}, server::HttpServer, service::web::match_service, - Request, }, rt::Executor, - Layer, }; /// Everything else we need is provided by the standard library, community crates or tokio. @@ -39,7 +39,7 @@ use std::time::Duration; use tracing::level_filters::LevelFilter; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; #[tokio::main] async fn main() { diff --git a/examples/http_telemetry.rs b/examples/http_telemetry.rs index fedd8ef4a..84f0ac775 100644 --- a/examples/http_telemetry.rs +++ b/examples/http_telemetry.rs @@ -38,6 +38,7 @@ use opentelemetry_otlp::{ExportConfig, Protocol, WithExportConfig}; use rama::{ + Context, Layer, http::{ layer::{opentelemetry::RequestMetricsLayer, trace::TraceLayer}, response::Html, @@ -48,23 +49,21 @@ use rama::{ rt::Executor, tcp::server::TcpListener, telemetry::opentelemetry::{ - self, + self, InstrumentationScope, KeyValue, metrics::UpDownCounter, sdk::{ - metrics::{PeriodicReader, SdkMeterProvider}, Resource, + metrics::{PeriodicReader, SdkMeterProvider}, }, semantic_conventions::{ self, resource::{HOST_ARCH, OS_NAME}, }, - InstrumentationScope, KeyValue, }, - Context, Layer, }; use std::{sync::Arc, time::Duration}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[derive(Debug)] struct Metrics { diff --git a/examples/http_user_agent_classifier.rs b/examples/http_user_agent_classifier.rs index 032d2bd10..094d2ec0b 100644 --- a/examples/http_user_agent_classifier.rs +++ b/examples/http_user_agent_classifier.rs @@ -17,11 +17,11 @@ //! You should see a response with `HTTP/1.1 200 OK` and a JSON body with the user agent info exposed by Rama. use rama::{ + Context, Layer, http::layer::ua::{UserAgent, UserAgentClassifierLayer}, - http::{response::Json, server::HttpServer, HeaderName, IntoResponse, Request, Response}, + http::{HeaderName, IntoResponse, Request, Response, response::Json, server::HttpServer}, rt::Executor, service::service_fn, - Context, Layer, }; use serde_json::json; use std::convert::Infallible; diff --git a/examples/http_web_service_dir_and_api.rs b/examples/http_web_service_dir_and_api.rs index 14ece4ab1..f7b28b4fe 100644 --- a/examples/http_web_service_dir_and_api.rs +++ b/examples/http_web_service_dir_and_api.rs @@ -25,6 +25,7 @@ // rama provides everything out of the box to build a complete web service. use rama::{ + Context, Layer, http::{ layer::{compression::CompressionLayer, trace::TraceLayer}, matcher::HttpMatcher, @@ -32,19 +33,18 @@ use rama::{ server::HttpServer, service::web::WebService, }, - net::stream::{matcher::SocketMatcher, SocketInfo}, + net::stream::{SocketInfo, matcher::SocketMatcher}, rt::Executor, - Context, Layer, }; +use std::sync::Arc; /// Everything else we need is provided by the standard library, community crates or tokio. use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering; -use std::sync::Arc; use tracing::level_filters::LevelFilter; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; #[derive(Debug, Default)] struct AppState { diff --git a/examples/https_connect_proxy.rs b/examples/https_connect_proxy.rs index d22d71701..e32a8fee7 100644 --- a/examples/https_connect_proxy.rs +++ b/examples/https_connect_proxy.rs @@ -24,8 +24,10 @@ //! you'll need to first import and trust the generated certificate. use rama::{ + Context, Layer, Service, graceful::Shutdown, http::{ + Body, IntoResponse, Request, Response, StatusCode, client::HttpClient, layer::{ proxy_auth::ProxyAuthLayer, @@ -34,26 +36,24 @@ use rama::{ }, matcher::MethodMatcher, server::HttpServer, - Body, IntoResponse, Request, Response, StatusCode, }, net::http::RequestContext, net::stream::layer::http::BodyLimitLayer, net::tls::{ - server::{SelfSignedData, ServerAuth, ServerConfig}, ApplicationProtocol, SecureTransport, + server::{SelfSignedData, ServerAuth, ServerConfig}, }, net::user::Basic, rt::Executor, service::service_fn, tcp::{client::default_tcp_connect, server::TcpListener, utils::is_connection_error}, tls::std::server::TlsAcceptorLayer, - Context, Layer, Service, }; use std::convert::Infallible; use std::time::Duration; use tracing::metadata::LevelFilter; -use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; #[tokio::main] async fn main() { diff --git a/examples/mtls_tunnel_and_service.rs b/examples/mtls_tunnel_and_service.rs index d51de3080..137c816d1 100644 --- a/examples/mtls_tunnel_and_service.rs +++ b/examples/mtls_tunnel_and_service.rs @@ -27,6 +27,7 @@ // rama provides everything out of the box to build mtls web services and proxies use rama::{ + Layer, graceful::Shutdown, http::{ layer::trace::TraceLayer, @@ -46,14 +47,13 @@ use rama::{ tcp::server::TcpListener, tls::rustls::client::{TlsConnectorData, TlsConnectorLayer}, tls::rustls::server::{TlsAcceptorData, TlsAcceptorLayer}, - Layer, }; // everything else is provided by the standard library, community crates or tokio use std::net::{IpAddr, Ipv4Addr}; use std::time::Duration; use tracing::metadata::LevelFilter; -use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; const LOCALHOST: Host = Host::Address(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))); const SERVER_AUTHORITY: Authority = Authority::new(LOCALHOST, 63014); diff --git a/examples/tcp_listener_layers.rs b/examples/tcp_listener_layers.rs index a65c96136..2e6e103d7 100644 --- a/examples/tcp_listener_layers.rs +++ b/examples/tcp_listener_layers.rs @@ -19,16 +19,16 @@ //! This is because of the `TimeoutLayer` that was added to the server. use rama::{ + Layer, layer::{HijackLayer, TimeoutLayer, TraceErrLayer}, net::stream::{matcher::SocketMatcher, service::EchoService}, service::service_fn, tcp::server::TcpListener, - Layer, }; use std::{convert::Infallible, time::Duration}; use tokio::net::TcpStream; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() { diff --git a/examples/tls_boring_dynamic_certs.rs b/examples/tls_boring_dynamic_certs.rs index b91ec24cc..c3730bc14 100644 --- a/examples/tls_boring_dynamic_certs.rs +++ b/examples/tls_boring_dynamic_certs.rs @@ -57,6 +57,7 @@ // rama provides everything out of the box to build a TLS termination proxy use rama::{ + Context, Layer, error::OpaqueError, graceful::Shutdown, http::server::HttpServer, @@ -66,16 +67,15 @@ use rama::{ address::{Domain, Host}, tls::server::{ServerAuth, ServerConfig}, tls::{ + DataEncoding, client::ClientHello, server::{DynamicCertIssuer, ServerAuthData, ServerCertIssuerData}, - DataEncoding, }, }, rt::Executor, service::service_fn, tcp::server::TcpListener, tls::boring::server::{TlsAcceptorData, TlsAcceptorLayer}, - Context, Layer, }; use rama_http::IntoResponse; use rama_net::tls::server::CacheKind; @@ -83,7 +83,7 @@ use rama_net::tls::server::CacheKind; // everything else is provided by the standard library, community crates or tokio use std::{convert::Infallible, time::Duration}; use tracing::metadata::LevelFilter; -use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; #[tokio::main] async fn main() { diff --git a/examples/tls_boring_termination.rs b/examples/tls_boring_termination.rs index 78206e847..e82c93e8f 100644 --- a/examples/tls_boring_termination.rs +++ b/examples/tls_boring_termination.rs @@ -34,8 +34,9 @@ // rama provides everything out of the box to build a TLS termination proxy use rama::{ + Context, Layer, graceful::Shutdown, - http::{server::HttpServer, Request, Response}, + http::{Request, Response, server::HttpServer}, layer::{ConsumeErrLayer, GetExtensionLayer}, net::{ forwarded::Forwarded, @@ -55,13 +56,12 @@ use rama::{ boring::server::{TlsAcceptorData, TlsAcceptorLayer}, types::SecureTransport, }, - Context, Layer, }; // everything else is provided by the standard library, community crates or tokio use std::{convert::Infallible, time::Duration}; use tracing::metadata::LevelFilter; -use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; #[tokio::main] async fn main() { diff --git a/examples/tls_termination.rs b/examples/tls_termination.rs index 4ed2addb0..7fe9d25c9 100644 --- a/examples/tls_termination.rs +++ b/examples/tls_termination.rs @@ -43,6 +43,7 @@ // rama provides everything out of the box to build a TLS termination proxy use rama::{ + Context, Layer, graceful::Shutdown, layer::ConsumeErrLayer, net::forwarded::Forwarded, @@ -56,7 +57,6 @@ use rama::{ server::TcpListener, }, tls::std::server::{TlsAcceptorData, TlsAcceptorLayer}, - Context, Layer, }; use rama_net::tls::server::{SelfSignedData, ServerAuth, ServerConfig}; @@ -64,7 +64,7 @@ use rama_net::tls::server::{SelfSignedData, ServerAuth, ServerConfig}; use std::{convert::Infallible, time::Duration}; use tokio::io::AsyncWriteExt; use tracing::metadata::LevelFilter; -use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, prelude::*}; #[tokio::main] async fn main() { diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 30b9fc8db..0d3cd0981 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -2,7 +2,7 @@ name = "rama-fuzz" version = "0.0.0" publish = false -edition = "2021" +edition = "2024" [lints] workspace = true diff --git a/fuzz/fuzz_targets/h2_e2e.rs b/fuzz/fuzz_targets/h2_e2e.rs index d6da76698..20bf1cf95 100644 --- a/fuzz/fuzz_targets/h2_e2e.rs +++ b/fuzz/fuzz_targets/h2_e2e.rs @@ -2,7 +2,7 @@ use rama::http::{Method, Request}; use futures::stream::FuturesUnordered; -use futures::{future, Stream}; +use futures::{Stream, future}; use libfuzzer_sys::fuzz_target; use std::future::Future; @@ -26,7 +26,7 @@ impl MockIo<'_> { } fn next_u32(&mut self) -> u32 { - (self.next_byte().unwrap_or(0) as u32) << 8 | self.next_byte().unwrap_or(0) as u32 + ((self.next_byte().unwrap_or(0) as u32) << 8) | self.next_byte().unwrap_or(0) as u32 } } diff --git a/rama-cli/README.md b/rama-cli/README.md index afa0b8308..57f76ae14 100644 --- a/rama-cli/README.md +++ b/rama-cli/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-cli/src/cmd/echo/mod.rs b/rama-cli/src/cmd/echo/mod.rs index a9b2d6c3a..ffbf93a12 100644 --- a/rama-cli/src/cmd/echo/mod.rs +++ b/rama-cli/src/cmd/echo/mod.rs @@ -2,25 +2,25 @@ use clap::Args; use rama::{ - cli::{service::echo::EchoServiceBuilder, ForwardKind}, + Service, + cli::{ForwardKind, service::echo::EchoServiceBuilder}, error::BoxError, - http::{matcher::HttpMatcher, IntoResponse, Request, Response}, + http::{IntoResponse, Request, Response, matcher::HttpMatcher}, layer::HijackLayer, net::tls::{ - server::{SelfSignedData, ServerAuth, ServerAuthData, ServerConfig}, ApplicationProtocol, DataEncoding, + server::{SelfSignedData, ServerAuth, ServerAuthData, ServerConfig}, }, rt::Executor, tcp::server::TcpListener, - Service, }; -use base64::engine::general_purpose::STANDARD as ENGINE; use base64::Engine; +use base64::engine::general_purpose::STANDARD as ENGINE; use std::{convert::Infallible, time::Duration}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[derive(Debug, Args)] /// rama echo service (echos the http request and tls client config) @@ -85,7 +85,7 @@ pub async fn run(cfg: CliCommandEcho) -> Result<(), BoxError> { ApplicationProtocol::HTTP_11, ]), ..ServerConfig::new(ServerAuth::SelfSigned(SelfSignedData::default())) - } + }; } }; let tls_key_pem_raw = std::str::from_utf8( diff --git a/rama-cli/src/cmd/fp/data.rs b/rama-cli/src/cmd/fp/data.rs index e1030313c..3ae00dbaa 100644 --- a/rama-cli/src/cmd/fp/data.rs +++ b/rama-cli/src/cmd/fp/data.rs @@ -1,11 +1,12 @@ use super::State; use rama::{ + Context, error::{BoxError, ErrorContext}, http::{ - dep::http::{request::Parts, Extensions}, + HeaderMap, Request, + dep::http::{Extensions, request::Parts}, headers::Forwarded, proto::{h1::Http1HeaderMap, h2::PseudoHeaderOrder}, - HeaderMap, Request, }, net::{ fingerprint::{Ja3, Ja4, Ja4H}, @@ -13,11 +14,10 @@ use rama::{ stream::SocketInfo, }, tls::types::{ - client::{ClientHello, ClientHelloExtension}, SecureTransport, + client::{ClientHello, ClientHelloExtension}, }, ua::UserAgent, - Context, }; use serde::Serialize; use std::{str::FromStr, sync::Arc}; diff --git a/rama-cli/src/cmd/fp/endpoints.rs b/rama-cli/src/cmd/fp/endpoints.rs index 4047ee4f5..9b086c672 100644 --- a/rama-cli/src/cmd/fp/endpoints.rs +++ b/rama-cli/src/cmd/fp/endpoints.rs @@ -1,17 +1,17 @@ use super::{ + State, data::{ - get_http_info, get_ja4h_info, get_request_info, get_tls_display_info, get_user_agent_info, DataSource, FetchMode, Initiator, RequestInfo, ResourceType, TlsDisplayInfo, UserAgentInfo, + get_http_info, get_ja4h_info, get_request_info, get_tls_display_info, get_user_agent_info, }, - State, }; use crate::cmd::fp::data::TlsDisplayInfoExtensionData; use rama::{ + Context, http::{ - response::Json, service::web::extract::Path, Body, IntoResponse, Request, Response, - StatusCode, + Body, IntoResponse, Request, Response, StatusCode, response::Json, + service::web::extract::Path, }, - Context, }; use serde::{Deserialize, Serialize}; use serde_json::json; diff --git a/rama-cli/src/cmd/fp/mod.rs b/rama-cli/src/cmd/fp/mod.rs index 7499f7de4..4fd9cc516 100644 --- a/rama-cli/src/cmd/fp/mod.rs +++ b/rama-cli/src/cmd/fp/mod.rs @@ -1,13 +1,14 @@ //! Echo service that echos the http request and tls client config -use base64::engine::general_purpose::STANDARD as ENGINE; use base64::Engine; +use base64::engine::general_purpose::STANDARD as ENGINE; use clap::Args; use rama::{ cli::ForwardKind, combinators::Either7, error::{BoxError, OpaqueError}, http::{ + HeaderName, HeaderValue, IntoResponse, headers::{CFConnectingIp, ClientIp, TrueClientIp, XClientIp, XRealIp}, layer::{ catch_panic::CatchPanicLayer, compression::CompressionLayer, @@ -18,17 +19,16 @@ use rama::{ response::Redirect, server::HttpServer, service::web::match_service, - HeaderName, HeaderValue, IntoResponse, }, layer::{ - limit::policy::ConcurrentPolicy, ConsumeErrLayer, HijackLayer, Layer, LimitLayer, - TimeoutLayer, + ConsumeErrLayer, HijackLayer, Layer, LimitLayer, TimeoutLayer, + limit::policy::ConcurrentPolicy, }, net::{ stream::layer::http::BodyLimitLayer, tls::{ - server::{ServerAuth, ServerAuthData, ServerConfig}, ApplicationProtocol, DataEncoding, + server::{ServerAuth, ServerAuthData, ServerConfig}, }, }, proxy::haproxy::server::HaProxyLayer, @@ -40,7 +40,7 @@ use rama::{ }; use std::{convert::Infallible, str::FromStr, sync::Arc, time::Duration}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; mod data; mod endpoints; @@ -360,7 +360,7 @@ impl FromStr for HttpVersion { version => { return Err(OpaqueError::from_display(format!( "unsupported http version: {version}" - ))) + ))); } }) } diff --git a/rama-cli/src/cmd/http/mod.rs b/rama-cli/src/cmd/http/mod.rs index 0fa29a16b..e390594ac 100644 --- a/rama-cli/src/cmd/http/mod.rs +++ b/rama-cli/src/cmd/http/mod.rs @@ -2,42 +2,42 @@ use clap::Args; use rama::{ + Context, Layer, Service, cli::args::RequestArgsBuilder, - error::{error, BoxError, ErrorContext, OpaqueError}, + error::{BoxError, ErrorContext, OpaqueError, error}, graceful::{self, Shutdown, ShutdownGuard}, http::{ + IntoResponse, Request, Response, StatusCode, client::{ - proxy::layer::{HttpProxyAddressLayer, SetProxyAuthHttpHeaderLayer}, HttpClient, + proxy::layer::{HttpProxyAddressLayer, SetProxyAuthHttpHeaderLayer}, }, layer::{ auth::AddAuthorizationLayer, decompression::DecompressionLayer, - follow_redirect::{policy::Limited, FollowRedirectLayer}, + follow_redirect::{FollowRedirectLayer, policy::Limited}, required_header::AddRequiredRequestHeadersLayer, timeout::TimeoutLayer, traffic_writer::WriterMode, }, - IntoResponse, Request, Response, StatusCode, }, layer::{HijackLayer, MapResultLayer}, net::{ address::ProxyAddress, tls::{ - client::{ClientConfig, ClientHelloExtension, ServerVerifyMode}, ApplicationProtocol, + client::{ClientConfig, ClientHelloExtension, ServerVerifyMode}, }, user::ProxyCredential, }, rt::Executor, service::service_fn, - Context, Layer, Service, }; use std::{io::IsTerminal, time::Duration}; use terminal_prompt::Terminal; use tokio::sync::oneshot; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; use crate::error::ErrorWithExitCode; diff --git a/rama-cli/src/cmd/ip/mod.rs b/rama-cli/src/cmd/ip/mod.rs index 377dd3ef2..d4eca461b 100644 --- a/rama-cli/src/cmd/ip/mod.rs +++ b/rama-cli/src/cmd/ip/mod.rs @@ -2,7 +2,7 @@ use clap::Args; use rama::{ - cli::{service::ip::IpServiceBuilder, ForwardKind}, + cli::{ForwardKind, service::ip::IpServiceBuilder}, combinators::Either, error::BoxError, rt::Executor, @@ -10,7 +10,7 @@ use rama::{ }; use std::time::Duration; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[derive(Debug, Args)] /// rama ip service (returns the ip address of the client) diff --git a/rama-cli/src/cmd/proxy/mod.rs b/rama-cli/src/cmd/proxy/mod.rs index 9f49ac16b..b0ea2f6e2 100644 --- a/rama-cli/src/cmd/proxy/mod.rs +++ b/rama-cli/src/cmd/proxy/mod.rs @@ -2,8 +2,10 @@ use clap::Args; use rama::{ + Context, Layer, Service, error::BoxError, http::{ + Body, IntoResponse, Request, Response, StatusCode, client::HttpClient, layer::{ remove_header::{RemoveRequestHeaderLayer, RemoveResponseHeaderLayer}, @@ -12,19 +14,17 @@ use rama::{ }, matcher::MethodMatcher, server::HttpServer, - Body, IntoResponse, Request, Response, StatusCode, }, - layer::{limit::policy::ConcurrentPolicy, LimitLayer, TimeoutLayer}, + layer::{LimitLayer, TimeoutLayer, limit::policy::ConcurrentPolicy}, net::http::RequestContext, net::stream::layer::http::BodyLimitLayer, rt::Executor, service::service_fn, tcp::{client::default_tcp_connect, server::TcpListener, utils::is_connection_error}, - Context, Layer, Service, }; use std::{convert::Infallible, time::Duration}; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[derive(Debug, Args)] /// rama proxy server diff --git a/rama-core/README.md b/rama-core/README.md index 195275031..c1eeee563 100644 --- a/rama-core/README.md +++ b/rama-core/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-core/src/combinators/mod.rs b/rama-core/src/combinators/mod.rs index 7f9527004..bf29ac7ed 100644 --- a/rama-core/src/combinators/mod.rs +++ b/rama-core/src/combinators/mod.rs @@ -5,5 +5,5 @@ mod either; #[doc(inline)] pub use either::{ - impl_either, Either, Either3, Either4, Either5, Either6, Either7, Either8, Either9, + Either, Either3, Either4, Either5, Either6, Either7, Either8, Either9, impl_either, }; diff --git a/rama-core/src/graceful.rs b/rama-core/src/graceful.rs index 03db96210..4e057f980 100644 --- a/rama-core/src/graceful.rs +++ b/rama-core/src/graceful.rs @@ -2,5 +2,5 @@ #[doc(inline)] pub use ::tokio_graceful::{ - default_signal, Shutdown, ShutdownBuilder, ShutdownGuard, WeakShutdownGuard, + Shutdown, ShutdownBuilder, ShutdownGuard, WeakShutdownGuard, default_signal, }; diff --git a/rama-core/src/layer/add_extension.rs b/rama-core/src/layer/add_extension.rs index 1d4857edb..3848df048 100644 --- a/rama-core/src/layer/add_extension.rs +++ b/rama-core/src/layer/add_extension.rs @@ -164,7 +164,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{service::service_fn, Context}; + use crate::{Context, service::service_fn}; use std::{convert::Infallible, sync::Arc}; struct State(i32); diff --git a/rama-core/src/layer/consume_err.rs b/rama-core/src/layer/consume_err.rs index f34600a29..cb4868da1 100644 --- a/rama-core/src/layer/consume_err.rs +++ b/rama-core/src/layer/consume_err.rs @@ -1,4 +1,4 @@ -use crate::{error::BoxError, Context, Layer, Service}; +use crate::{Context, Layer, Service, error::BoxError}; use rama_utils::macros::define_inner_service_accessors; use std::{convert::Infallible, fmt}; diff --git a/rama-core/src/layer/get_extension.rs b/rama-core/src/layer/get_extension.rs index 536debf56..9b083749b 100644 --- a/rama-core/src/layer/get_extension.rs +++ b/rama-core/src/layer/get_extension.rs @@ -148,7 +148,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{service::service_fn, Context}; + use crate::{Context, service::service_fn}; use std::{convert::Infallible, sync::Arc}; #[derive(Debug, Clone)] diff --git a/rama-core/src/layer/hijack.rs b/rama-core/src/layer/hijack.rs index 44e24c729..f63cdf33f 100644 --- a/rama-core/src/layer/hijack.rs +++ b/rama-core/src/layer/hijack.rs @@ -7,7 +7,7 @@ //! [`Service`]: crate //! [`Matcher`]: crate::matcher::Matcher -use crate::{context::Extensions, matcher::Matcher, Context, Layer, Service}; +use crate::{Context, Layer, Service, context::Extensions, matcher::Matcher}; use rama_utils::macros::define_inner_service_accessors; /// Middleware to hijack request to a [`Service`] which match using a [`Matcher`]. diff --git a/rama-core/src/layer/layer_fn.rs b/rama-core/src/layer/layer_fn.rs index c2c1eace2..f2bc0cb8a 100644 --- a/rama-core/src/layer/layer_fn.rs +++ b/rama-core/src/layer/layer_fn.rs @@ -63,7 +63,7 @@ mod tests { /// for users that want to declare a Layer without implementing the Layer trait explicitly themselves. #[tokio::test] async fn test_layer_fn() { - use crate::{service::service_fn, Context, Service}; + use crate::{Context, Service, service::service_fn}; use std::convert::Infallible; struct ToUpper(S); diff --git a/rama-core/src/layer/limit/layer.rs b/rama-core/src/layer/limit/layer.rs index 56fd91b7b..52fe06b39 100644 --- a/rama-core/src/layer/limit/layer.rs +++ b/rama-core/src/layer/limit/layer.rs @@ -1,6 +1,6 @@ use std::fmt; -use super::{into_response::ErrorIntoResponseFn, policy::UnlimitedPolicy, Limit}; +use super::{Limit, into_response::ErrorIntoResponseFn, policy::UnlimitedPolicy}; use crate::Layer; /// Limit requests based on a [`Policy`]. diff --git a/rama-core/src/layer/limit/mod.rs b/rama-core/src/layer/limit/mod.rs index 295739659..3a9432d24 100644 --- a/rama-core/src/layer/limit/mod.rs +++ b/rama-core/src/layer/limit/mod.rs @@ -155,7 +155,7 @@ where return match self.error_into_response.error_into_response(err) { Ok(ok) => Ok(ok.into()), Err(err) => Err(err.into()), - } + }; } policy::PolicyOutput::Retry => (), } @@ -168,7 +168,7 @@ mod tests { use super::policy::ConcurrentPolicy; use super::*; - use crate::{service::service_fn, Context, Layer, Service}; + use crate::{Context, Layer, Service, service::service_fn}; use std::convert::Infallible; use futures_lite::future::zip; diff --git a/rama-core/src/layer/limit/policy/concurrent.rs b/rama-core/src/layer/limit/policy/concurrent.rs index 3a1fdc6fa..f1d789a1e 100644 --- a/rama-core/src/layer/limit/policy/concurrent.rs +++ b/rama-core/src/layer/limit/policy/concurrent.rs @@ -122,7 +122,7 @@ where ctx, request, output: PolicyOutput::Ready(guard), - } + }; } Err(err) => err, }; diff --git a/rama-core/src/layer/limit/policy/matcher.rs b/rama-core/src/layer/limit/policy/matcher.rs index 4ab51b173..311c28339 100644 --- a/rama-core/src/layer/limit/policy/matcher.rs +++ b/rama-core/src/layer/limit/policy/matcher.rs @@ -1,4 +1,4 @@ -use crate::{context::Extensions, matcher::Matcher, Context}; +use crate::{Context, context::Extensions, matcher::Matcher}; use super::{Policy, PolicyOutput, PolicyResult}; diff --git a/rama-core/src/layer/limit/policy/mod.rs b/rama-core/src/layer/limit/policy/mod.rs index 3ff5fe15f..7350e26ea 100644 --- a/rama-core/src/layer/limit/policy/mod.rs +++ b/rama-core/src/layer/limit/policy/mod.rs @@ -27,8 +27,8 @@ //! [`Extensions`]: crate::context::Extensions //! [`http_listener_hello.rs`]: https://github.com/plabayo/rama/blob/main/examples/http_rate_limit.rs -use crate::error::BoxError; use crate::Context; +use crate::error::BoxError; use std::{convert::Infallible, fmt, sync::Arc}; mod concurrent; @@ -104,8 +104,8 @@ pub trait Policy: Send + Sync + 'static { ctx: Context, request: Request, ) -> impl std::future::Future> - + Send - + '_; + + Send + + '_; } impl Policy for Option

diff --git a/rama-core/src/layer/mod.rs b/rama-core/src/layer/mod.rs index f8847a8c5..9cf2b2efa 100644 --- a/rama-core/src/layer/mod.rs +++ b/rama-core/src/layer/mod.rs @@ -687,7 +687,7 @@ pub use map_state::{MapState, MapStateLayer}; mod layer_fn; #[doc(inline)] -pub use layer_fn::{layer_fn, LayerFn}; +pub use layer_fn::{LayerFn, layer_fn}; mod map_request; #[doc(inline)] diff --git a/rama-core/src/layer/timeout/layer.rs b/rama-core/src/layer/timeout/layer.rs index 3df1bfe55..dd5702504 100644 --- a/rama-core/src/layer/timeout/layer.rs +++ b/rama-core/src/layer/timeout/layer.rs @@ -1,11 +1,11 @@ use std::{fmt, time::Duration}; use crate::{ - layer::{LayerErrorFn, LayerErrorStatic, MakeLayerError}, Layer, + layer::{LayerErrorFn, LayerErrorStatic, MakeLayerError}, }; -use super::{error::Elapsed, Timeout}; +use super::{Timeout, error::Elapsed}; /// Applies a timeout to requests via the supplied inner service. pub struct TimeoutLayer { diff --git a/rama-core/src/matcher/ext.rs b/rama-core/src/matcher/ext.rs index c79c4fb88..d2f3e83ac 100644 --- a/rama-core/src/matcher/ext.rs +++ b/rama-core/src/matcher/ext.rs @@ -1,6 +1,6 @@ use crate::{ - matcher::{Extensions, Matcher}, Context, + matcher::{Extensions, Matcher}, }; use std::marker::PhantomData; diff --git a/rama-core/src/matcher/iter.rs b/rama-core/src/matcher/iter.rs index f2d947559..f50f755c9 100644 --- a/rama-core/src/matcher/iter.rs +++ b/rama-core/src/matcher/iter.rs @@ -1,4 +1,4 @@ -use crate::{context::Extensions, Context}; +use crate::{Context, context::Extensions}; use super::Matcher; diff --git a/rama-core/src/matcher/mfn.rs b/rama-core/src/matcher/mfn.rs index c36b8cbf9..83f7837b4 100644 --- a/rama-core/src/matcher/mfn.rs +++ b/rama-core/src/matcher/mfn.rs @@ -1,5 +1,5 @@ use crate::context::Extensions; -use crate::{matcher::Matcher, Context}; +use crate::{Context, matcher::Matcher}; use std::marker::PhantomData; /// Create a [`MatchFn`] from a function. diff --git a/rama-core/src/matcher/mod.rs b/rama-core/src/matcher/mod.rs index 6beeba85a..f4e71bed1 100644 --- a/rama-core/src/matcher/mod.rs +++ b/rama-core/src/matcher/mod.rs @@ -14,7 +14,7 @@ use std::sync::Arc; -use super::{context::Extensions, Context}; +use super::{Context, context::Extensions}; use crate::Service; use paste::paste; use rama_utils::macros::all_the_tuples_no_last_special_case; @@ -33,7 +33,7 @@ pub use op_not::Not; mod mfn; #[doc(inline)] -pub use mfn::{match_fn, MatchFn}; +pub use mfn::{MatchFn, match_fn}; mod iter; #[doc(inline)] diff --git a/rama-core/src/matcher/op_and.rs b/rama-core/src/matcher/op_and.rs index 2fb9126bb..3c0317f05 100644 --- a/rama-core/src/matcher/op_and.rs +++ b/rama-core/src/matcher/op_and.rs @@ -1,5 +1,5 @@ use super::Matcher; -use crate::{context::Extensions, Context}; +use crate::{Context, context::Extensions}; use rama_utils::macros::all_the_tuples_no_last_special_case; /// A matcher that matches if all of the inner matchers match. diff --git a/rama-core/src/matcher/op_not.rs b/rama-core/src/matcher/op_not.rs index e77a3dd3e..d198d5237 100644 --- a/rama-core/src/matcher/op_not.rs +++ b/rama-core/src/matcher/op_not.rs @@ -1,5 +1,5 @@ use super::Matcher; -use crate::{context::Extensions, Context}; +use crate::{Context, context::Extensions}; /// A matcher that matches if the inner matcher does not match. pub struct Not(T); diff --git a/rama-core/src/matcher/op_or.rs b/rama-core/src/matcher/op_or.rs index 9cca03a4b..c5419775e 100644 --- a/rama-core/src/matcher/op_or.rs +++ b/rama-core/src/matcher/op_or.rs @@ -1,5 +1,5 @@ use super::Matcher; -use crate::{context::Extensions, Context}; +use crate::{Context, context::Extensions}; use rama_utils::macros::all_the_tuples_no_last_special_case; /// A matcher that matches if any of the inner matchers match. diff --git a/rama-core/src/service/svc.rs b/rama-core/src/service/svc.rs index 2d97d4e50..904cab116 100644 --- a/rama-core/src/service/svc.rs +++ b/rama-core/src/service/svc.rs @@ -1,7 +1,7 @@ //! [`Service`] and [`BoxService`] traits. -use crate::error::BoxError; use crate::Context; +use crate::error::BoxError; use std::convert::Infallible; use std::future::Future; use std::pin::Pin; diff --git a/rama-core/src/username/mod.rs b/rama-core/src/username/mod.rs index 871f9e1ef..f35c1bcdb 100644 --- a/rama-core/src/username/mod.rs +++ b/rama-core/src/username/mod.rs @@ -31,14 +31,14 @@ pub const DEFAULT_USERNAME_LABEL_SEPARATOR: char = '-'; mod parse; #[doc(inline)] pub use parse::{ - parse_username, parse_username_with_separator, ExclusiveUsernameParsers, UsernameLabelParser, - UsernameLabelState, UsernameLabels, UsernameOpaqueLabelParser, + ExclusiveUsernameParsers, UsernameLabelParser, UsernameLabelState, UsernameLabels, + UsernameOpaqueLabelParser, parse_username, parse_username_with_separator, }; mod compose; #[doc(inline)] pub use compose::{ - compose_username, compose_username_with_separator, ComposeError, Composer, UsernameLabelWriter, + ComposeError, Composer, UsernameLabelWriter, compose_username, compose_username_with_separator, }; #[cfg(test)] diff --git a/rama-core/src/username/parse.rs b/rama-core/src/username/parse.rs index 21f169bc9..3949720fc 100644 --- a/rama-core/src/username/parse.rs +++ b/rama-core/src/username/parse.rs @@ -145,7 +145,7 @@ macro_rules! username_label_parser_tuple_impl { type Error = OpaqueError; fn parse_label(&mut self, label: &str) -> UsernameLabelState { - let ($(ref mut $T,)+) = self; + let ($($T,)+) = self; let mut state = UsernameLabelState::Ignored; $( match $T.parse_label(label) { diff --git a/rama-dns/README.md b/rama-dns/README.md index d669c9b8c..b65f378f3 100644 --- a/rama-dns/README.md +++ b/rama-dns/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-dns/src/chain.rs b/rama-dns/src/chain.rs index b709c7670..c16c3e6a4 100644 --- a/rama-dns/src/chain.rs +++ b/rama-dns/src/chain.rs @@ -61,27 +61,31 @@ mod tests { #[tokio::test] async fn test_empty_chain_vec() { let v = Vec::::new(); - assert!(v - .ipv4_lookup(Domain::from_static("plabayo.tech")) - .await - .is_err()); - assert!(v - .ipv6_lookup(Domain::from_static("plabayo.tech")) - .await - .is_err()); + assert!( + v.ipv4_lookup(Domain::from_static("plabayo.tech")) + .await + .is_err() + ); + assert!( + v.ipv6_lookup(Domain::from_static("plabayo.tech")) + .await + .is_err() + ); } #[tokio::test] async fn test_empty_chain_array() { let a: [InMemoryDns; 0] = []; - assert!(a - .ipv4_lookup(Domain::from_static("plabayo.tech")) - .await - .is_err()); - assert!(a - .ipv6_lookup(Domain::from_static("plabayo.tech")) - .await - .is_err()); + assert!( + a.ipv4_lookup(Domain::from_static("plabayo.tech")) + .await + .is_err() + ); + assert!( + a.ipv6_lookup(Domain::from_static("plabayo.tech")) + .await + .is_err() + ); } #[tokio::test] @@ -161,9 +165,10 @@ mod tests { #[tokio::test] async fn test_chain_err_err_ipv4() { let v = vec![DenyAllDns::new(), DenyAllDns::new()]; - assert!(v - .ipv4_lookup(Domain::from_static("example.com")) - .await - .is_err()); + assert!( + v.ipv4_lookup(Domain::from_static("example.com")) + .await + .is_err() + ); } } diff --git a/rama-dns/src/hickory.rs b/rama-dns/src/hickory.rs index 92f4ff223..3b0e12e58 100644 --- a/rama-dns/src/hickory.rs +++ b/rama-dns/src/hickory.rs @@ -2,8 +2,8 @@ use crate::DnsResolver; use hickory_resolver::{ - proto::rr::rdata::{A, AAAA}, Name, TokioAsyncResolver, + proto::rr::rdata::{A, AAAA}, }; use rama_core::error::{ErrorContext, OpaqueError}; use rama_net::address::Domain; diff --git a/rama-dns/src/in_memory.rs b/rama-dns/src/in_memory.rs index b6a7175b3..5c79efe4d 100644 --- a/rama-dns/src/in_memory.rs +++ b/rama-dns/src/in_memory.rs @@ -159,19 +159,23 @@ mod tests { .unwrap(), Ipv4Addr::new(127, 0, 0, 1) ); - assert!(dns_overwrite - .ipv6_lookup(Domain::from_static("example.com")) - .await - .is_err()); + assert!( + dns_overwrite + .ipv6_lookup(Domain::from_static("example.com")) + .await + .is_err() + ); } #[tokio::test] async fn test_dns_overwrite_deserialize_ipv6() { let dns_overwrite: DnsOverwrite = serde_html_form::from_str("example.com=::1").unwrap(); - assert!(dns_overwrite - .ipv4_lookup(Domain::from_static("example.com")) - .await - .is_err()); + assert!( + dns_overwrite + .ipv4_lookup(Domain::from_static("example.com")) + .await + .is_err() + ); assert_eq!( dns_overwrite .ipv6_lookup(Domain::from_static("example.com")) @@ -196,10 +200,12 @@ mod tests { assert_eq!(ipv4_it.next().unwrap(), Ipv4Addr::new(127, 0, 0, 1)); assert_eq!(ipv4_it.next().unwrap(), Ipv4Addr::new(127, 0, 0, 2)); assert!(ipv4_it.next().is_none()); - assert!(dns_overwrite - .ipv6_lookup(Domain::from_static("example.com")) - .await - .is_err()); + assert!( + dns_overwrite + .ipv6_lookup(Domain::from_static("example.com")) + .await + .is_err() + ); } #[tokio::test] @@ -232,26 +238,34 @@ mod tests { async fn test_dns_overwrite_deserialize_not_found() { let dns_overwrite: DnsOverwrite = serde_html_form::from_str("example.com=127.0.0.1").unwrap(); - assert!(dns_overwrite - .ipv4_lookup(Domain::from_static("plabayo.tech")) - .await - .is_err()); - assert!(dns_overwrite - .ipv6_lookup(Domain::from_static("plabayo.tech")) - .await - .is_err()); + assert!( + dns_overwrite + .ipv4_lookup(Domain::from_static("plabayo.tech")) + .await + .is_err() + ); + assert!( + dns_overwrite + .ipv6_lookup(Domain::from_static("plabayo.tech")) + .await + .is_err() + ); } #[tokio::test] async fn test_dns_overwrite_deserialize_empty() { let dns_overwrite: DnsOverwrite = serde_html_form::from_str("").unwrap(); - assert!(dns_overwrite - .ipv4_lookup(Domain::from_static("example.com")) - .await - .is_err()); - assert!(dns_overwrite - .ipv6_lookup(Domain::from_static("example.com")) - .await - .is_err()); + assert!( + dns_overwrite + .ipv4_lookup(Domain::from_static("example.com")) + .await + .is_err() + ); + assert!( + dns_overwrite + .ipv6_lookup(Domain::from_static("example.com")) + .await + .is_err() + ); } } diff --git a/rama-error/README.md b/rama-error/README.md index ab366cae9..072818cc3 100644 --- a/rama-error/README.md +++ b/rama-error/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-haproxy/README.md b/rama-haproxy/README.md index ba0ead555..dfbc2d0ab 100644 --- a/rama-haproxy/README.md +++ b/rama-haproxy/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-haproxy/src/client/layer.rs b/rama-haproxy/src/client/layer.rs index 5fafc872f..d0d444107 100644 --- a/rama-haproxy/src/client/layer.rs +++ b/rama-haproxy/src/client/layer.rs @@ -2,8 +2,8 @@ use std::{fmt, marker::PhantomData, net::IpAddr}; use crate::protocol::{v1, v2}; use rama_core::{ - error::{BoxError, ErrorContext, OpaqueError}, Context, Layer, Service, + error::{BoxError, ErrorContext, OpaqueError}, }; use rama_net::{ client::{ConnectorService, EstablishedClientConnection}, @@ -247,7 +247,7 @@ where return Err(OpaqueError::from_display( "PROXY client (v1): IP version mismatch between src and dest", ) - .into()) + .into()); } }; @@ -267,11 +267,11 @@ where impl Service for HaProxyService where S: Service< - State, - Request, - Response = EstablishedClientConnection, - Error: Into, - >, + State, + Request, + Response = EstablishedClientConnection, + Error: Into, + >, P: protocol::Protocol + Send + 'static, State: Clone + Send + Sync + 'static, Request: Send + 'static, @@ -315,7 +315,7 @@ where return Err(OpaqueError::from_display( "PROXY client (v2): IP version mismatch between src and dest", ) - .into()) + .into()); } }; @@ -400,7 +400,7 @@ pub mod protocol { #[cfg(test)] mod tests { use super::*; - use rama_core::{service::service_fn, Layer}; + use rama_core::{Layer, service::service_fn}; use rama_net::forwarded::{ForwardedElement, NodeId}; use std::convert::Infallible; use tokio_test::io::Builder; @@ -421,8 +421,15 @@ mod tests { "PROXY TCP4 127.0.1.2 192.168.1.101 80 443\r\n", { let mut ctx = Context::default(); - ctx.insert(SocketInfo::new(None, "[1234:5678:90ab:cdef:fedc:ba09:8765:4321]:443".parse().unwrap())); - ctx.insert(Forwarded::new(ForwardedElement::forwarded_for(NodeId::try_from("127.0.1.2:80").unwrap()))); + ctx.insert(SocketInfo::new( + None, + "[1234:5678:90ab:cdef:fedc:ba09:8765:4321]:443" + .parse() + .unwrap(), + )); + ctx.insert(Forwarded::new(ForwardedElement::forwarded_for( + NodeId::try_from("127.0.1.2:80").unwrap(), + ))); ctx }, "192.168.1.101:443", @@ -431,7 +438,12 @@ mod tests { "PROXY TCP6 1234:5678:90ab:cdef:fedc:ba09:8765:4321 4321:8765:ba09:fedc:cdef:90ab:5678:1234 443 65535\r\n", { let mut ctx = Context::default(); - ctx.insert(SocketInfo::new(None, "[1234:5678:90ab:cdef:fedc:ba09:8765:4321]:443".parse().unwrap())); + ctx.insert(SocketInfo::new( + None, + "[1234:5678:90ab:cdef:fedc:ba09:8765:4321]:443" + .parse() + .unwrap(), + )); ctx }, "[4321:8765:ba09:fedc:cdef:90ab:5678:1234]:65535", @@ -441,13 +453,16 @@ mod tests { { let mut ctx = Context::default(); ctx.insert(SocketInfo::new(None, "127.0.1.2:80".parse().unwrap())); - ctx.insert(Forwarded::new(ForwardedElement::forwarded_for(NodeId::try_from("[1234:5678:90ab:cdef:fedc:ba09:8765:4321]:443").unwrap()))); + ctx.insert(Forwarded::new(ForwardedElement::forwarded_for( + NodeId::try_from("[1234:5678:90ab:cdef:fedc:ba09:8765:4321]:443").unwrap(), + ))); ctx }, "[4321:8765:ba09:fedc:cdef:90ab:5678:1234]:65535", ), ] { - let svc = HaProxyLayer::tcp().v1() + let svc = HaProxyLayer::tcp() + .v1() .layer(service_fn(move |ctx, req| async move { Ok::<_, Infallible>(EstablishedClientConnection { ctx, diff --git a/rama-haproxy/src/client/mod.rs b/rama-haproxy/src/client/mod.rs index 4a1d196ee..78c9053c0 100644 --- a/rama-haproxy/src/client/mod.rs +++ b/rama-haproxy/src/client/mod.rs @@ -4,4 +4,4 @@ mod layer; #[doc(inline)] -pub use layer::{protocol, version, HaProxyLayer, HaProxyService}; +pub use layer::{HaProxyLayer, HaProxyService, protocol, version}; diff --git a/rama-haproxy/src/protocol/v1/error.rs b/rama-haproxy/src/protocol/v1/error.rs index dbe88bf18..95dc57b22 100644 --- a/rama-haproxy/src/protocol/v1/error.rs +++ b/rama-haproxy/src/protocol/v1/error.rs @@ -51,13 +51,32 @@ impl fmt::Display for ParseError { Self::MissingDestinationAddress => write!(f, "Header missing destination address."), Self::MissingSourcePort => write!(f, "Header missing source port."), Self::MissingDestinationPort => write!(f, "Header missing destination port."), - Self::HeaderTooLong => write!(f, "Header does not fit within the expected buffer size of 107 bytes (plus 1 byte for null-terminated strings)."), + Self::HeaderTooLong => write!( + f, + "Header does not fit within the expected buffer size of 107 bytes (plus 1 byte for null-terminated strings)." + ), Self::InvalidProtocol => write!(f, "Header has an invalid protocol."), Self::InvalidSuffix => write!(f, "Header must end in '\r\n'."), - Self::InvalidSourceAddress(source) => write!(f, "Header contains invalid IP address for the source: {}", source), - Self::InvalidDestinationAddress(destination) => write!(f, "Header contains invalid IP address for the destination: {}", destination), - Self::InvalidSourcePort(port) => write!(f, "Header contains invalid TCP port for the source: {}", port.as_ref().map(|e| e.to_string()).unwrap_or_default()), - Self::InvalidDestinationPort(port) => write!(f, "Header contains invalid TCP port for the destination: {}", port.as_ref().map(|e| e.to_string()).unwrap_or_default()), + Self::InvalidSourceAddress(source) => write!( + f, + "Header contains invalid IP address for the source: {}", + source + ), + Self::InvalidDestinationAddress(destination) => write!( + f, + "Header contains invalid IP address for the destination: {}", + destination + ), + Self::InvalidSourcePort(port) => write!( + f, + "Header contains invalid TCP port for the source: {}", + port.as_ref().map(|e| e.to_string()).unwrap_or_default() + ), + Self::InvalidDestinationPort(port) => write!( + f, + "Header contains invalid TCP port for the destination: {}", + port.as_ref().map(|e| e.to_string()).unwrap_or_default() + ), } } } diff --git a/rama-haproxy/src/protocol/v1/mod.rs b/rama-haproxy/src/protocol/v1/mod.rs index 294f40da5..c7efefdaf 100644 --- a/rama-haproxy/src/protocol/v1/mod.rs +++ b/rama-haproxy/src/protocol/v1/mod.rs @@ -11,7 +11,7 @@ pub use model::{Addresses, Header, SEPARATOR, TCP4, TCP6, UNKNOWN}; pub use model::{PROTOCOL_PREFIX, PROTOCOL_SUFFIX}; use std::borrow::Cow; use std::net::{AddrParseError, Ipv4Addr, Ipv6Addr}; -use std::str::{from_utf8, FromStr}; +use std::str::{FromStr, from_utf8}; const ZERO: &str = "0"; const NEWLINE: &str = "\n"; @@ -72,14 +72,14 @@ fn parse_header(header: &str) -> Result { Addresses::Unknown } Some(protocol) if protocol.is_empty() && iterator.peek().is_none() => { - return Err(ParseError::MissingProtocol) + return Err(ParseError::MissingProtocol); } Some(protocol) if !protocol.is_empty() && header.ends_with(protocol) && (TCP4.starts_with(protocol) || UNKNOWN.starts_with(protocol)) => { - return Err(ParseError::Partial) + return Err(ParseError::Partial); } Some(_) => return Err(ParseError::InvalidProtocol), None => return Err(ParseError::MissingProtocol), @@ -292,7 +292,10 @@ mod tests { let ip: Ipv6Addr = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff".parse().unwrap(); let port = 65535; let text = "PROXY TCP6 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535 65535\r\nHi!"; - let expected = Header::new("PROXY TCP6 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535 65535\r\n", Addresses::new_tcp6(ip, ip, port, port)); + let expected = Header::new( + "PROXY TCP6 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535 65535\r\n", + Addresses::new_tcp6(ip, ip, port, port), + ); assert_eq!(Header::try_from(text), Ok(expected.to_owned())); assert_eq!(Header::try_from(text.as_bytes()), Ok(expected)); diff --git a/rama-haproxy/src/protocol/v2/builder.rs b/rama-haproxy/src/protocol/v2/builder.rs index e93d301a2..c664f9a7f 100644 --- a/rama-haproxy/src/protocol/v2/builder.rs +++ b/rama-haproxy/src/protocol/v2/builder.rs @@ -1,8 +1,8 @@ //! Builder pattern to generate both valid and invalid PROXY protocol v2 headers. use crate::protocol::v2::{ - Addresses, Protocol, Type, TypeLengthValue, TypeLengthValues, LENGTH, MINIMUM_LENGTH, - MINIMUM_TLV_LENGTH, PROTOCOL_PREFIX, + Addresses, LENGTH, MINIMUM_LENGTH, MINIMUM_TLV_LENGTH, PROTOCOL_PREFIX, Protocol, Type, + TypeLengthValue, TypeLengthValues, }; use std::io::{self, Write}; diff --git a/rama-haproxy/src/protocol/v2/error.rs b/rama-haproxy/src/protocol/v2/error.rs index af38f6b02..8b4e64e98 100644 --- a/rama-haproxy/src/protocol/v2/error.rs +++ b/rama-haproxy/src/protocol/v2/error.rs @@ -30,16 +30,51 @@ pub enum ParseError { impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Incomplete(len) => write!(f, "Expected header to the protocol prefix plus 4 bytes after the prefix (length {}).", len), - Self::Prefix => write!(f, "Expected header to start with a prefix of '\\r\\n\\r\\n\\0\\r\\nQUIT\\n'."), + Self::Incomplete(len) => write!( + f, + "Expected header to the protocol prefix plus 4 bytes after the prefix (length {}).", + len + ), + Self::Prefix => write!( + f, + "Expected header to start with a prefix of '\\r\\n\\r\\n\\0\\r\\nQUIT\\n'." + ), Self::Version(version) => write!(f, "Expected version {:X} to be equal to 2.", version), - Self::Command(command) => write!(f, "Invalid command {:X}. Command must be one of: Local, Proxy.", command), - Self::AddressFamily(af) => write!(f, "Invalid Address Family {:X}. Address Family must be one of: Unspecified, IPv4, IPv6, Unix.", af), - Self::Protocol(protocol) => write!(f, "Invalid protocol {:X}. Protocol must be one of: Unspecified, Stream, or Datagram.", protocol), - Self::Partial(len, total) => write!(f, "Header does not contain the advertised length of the address information and TLVs (has {} out of {} bytes).", len, total), - Self::InvalidAddresses(len, total) => write!(f, "Header length of {} bytes cannot store the {} bytes required for the address family.", len, total), - Self::InvalidTLV(tlv, len) => write!(f, "Header is not long enough to contain TLV {} with length {}.", tlv, len), - Self::Leftovers(len) => write!(f, "Header contains leftover {} bytes not accounted for by the address family or TLVs.", len), + Self::Command(command) => write!( + f, + "Invalid command {:X}. Command must be one of: Local, Proxy.", + command + ), + Self::AddressFamily(af) => write!( + f, + "Invalid Address Family {:X}. Address Family must be one of: Unspecified, IPv4, IPv6, Unix.", + af + ), + Self::Protocol(protocol) => write!( + f, + "Invalid protocol {:X}. Protocol must be one of: Unspecified, Stream, or Datagram.", + protocol + ), + Self::Partial(len, total) => write!( + f, + "Header does not contain the advertised length of the address information and TLVs (has {} out of {} bytes).", + len, total + ), + Self::InvalidAddresses(len, total) => write!( + f, + "Header length of {} bytes cannot store the {} bytes required for the address family.", + len, total + ), + Self::InvalidTLV(tlv, len) => write!( + f, + "Header is not long enough to contain TLV {} with length {}.", + tlv, len + ), + Self::Leftovers(len) => write!( + f, + "Header contains leftover {} bytes not accounted for by the address family or TLVs.", + len + ), } } } diff --git a/rama-haproxy/src/protocol/v2/mod.rs b/rama-haproxy/src/protocol/v2/mod.rs index 13c965200..f80754f1a 100644 --- a/rama-haproxy/src/protocol/v2/mod.rs +++ b/rama-haproxy/src/protocol/v2/mod.rs @@ -10,8 +10,8 @@ pub use crate::protocol::ip::{IPv4, IPv6}; pub use builder::{Builder, WriteToHeader, Writer}; pub use error::ParseError; pub use model::{ - AddressFamily, Addresses, Command, Header, Protocol, Type, TypeLengthValue, TypeLengthValues, - Unix, Version, PROTOCOL_PREFIX, + AddressFamily, Addresses, Command, Header, PROTOCOL_PREFIX, Protocol, Type, TypeLengthValue, + TypeLengthValues, Unix, Version, }; use model::{MINIMUM_LENGTH, MINIMUM_TLV_LENGTH}; use std::borrow::Cow; diff --git a/rama-haproxy/src/server/layer.rs b/rama-haproxy/src/server/layer.rs index 341a21ec9..acde718f7 100644 --- a/rama-haproxy/src/server/layer.rs +++ b/rama-haproxy/src/server/layer.rs @@ -1,7 +1,7 @@ -use crate::protocol::{v1, v2, HeaderResult, PartialResult}; +use crate::protocol::{HeaderResult, PartialResult, v1, v2}; use rama_core::{ - error::{BoxError, ErrorExt}, Context, Layer, Service, + error::{BoxError, ErrorExt}, }; use rama_net::{ forwarded::{Forwarded, ForwardedElement}, @@ -65,10 +65,13 @@ impl Service for HaProxyService where State: Clone + Send + Sync + 'static, S: Service< - State, - tokio::io::Join>, tokio::io::WriteHalf>, - Error: Into, - >, + State, + tokio::io::Join< + ChainReader>, + tokio::io::WriteHalf, + >, + Error: Into, + >, IO: Stream + Unpin, { type Response = S::Response; diff --git a/rama-http-backend/README.md b/rama-http-backend/README.md index 49d3e5afd..241b4c4af 100644 --- a/rama-http-backend/README.md +++ b/rama-http-backend/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-http-backend/src/client/conn.rs b/rama-http-backend/src/client/conn.rs index c94a36bd0..4fbb81025 100644 --- a/rama-http-backend/src/client/conn.rs +++ b/rama-http-backend/src/client/conn.rs @@ -1,9 +1,9 @@ -use super::{svc::SendRequest, HttpClientService}; +use super::{HttpClientService, svc::SendRequest}; use rama_core::{ - error::{BoxError, OpaqueError}, Context, Layer, Service, + error::{BoxError, OpaqueError}, }; -use rama_http_types::{dep::http_body, Request, Version}; +use rama_http_types::{Request, Version, dep::http_body}; use rama_net::{ client::{ConnectorService, EstablishedClientConnection}, stream::Stream, @@ -14,7 +14,7 @@ use std::fmt; use tracing::trace; #[cfg(any(feature = "rustls", feature = "boring"))] -use rama_net::tls::{client::NegotiatedTlsParameters, ApplicationProtocol}; +use rama_net::tls::{ApplicationProtocol, client::NegotiatedTlsParameters}; /// A [`Service`] which establishes an HTTP Connection. pub struct HttpConnector { diff --git a/rama-http-backend/src/client/mod.rs b/rama-http-backend/src/client/mod.rs index bd6aebfa7..c26a77cb8 100644 --- a/rama-http-backend/src/client/mod.rs +++ b/rama-http-backend/src/client/mod.rs @@ -3,10 +3,10 @@ use proxy::layer::HttpProxyConnector; use rama_core::{ - error::{BoxError, ErrorExt, OpaqueError}, Context, Service, + error::{BoxError, ErrorExt, OpaqueError}, }; -use rama_http_types::{dep::http_body, Request, Response}; +use rama_http_types::{Request, Response, dep::http_body}; use rama_net::client::{ConnectorService, EstablishedClientConnection}; use rama_tcp::client::service::TcpConnector; diff --git a/rama-http-backend/src/client/proxy/layer/proxy_address.rs b/rama-http-backend/src/client/proxy/layer/proxy_address.rs index a8dc1a7b2..7d61339c8 100644 --- a/rama-http-backend/src/client/proxy/layer/proxy_address.rs +++ b/rama-http-backend/src/client/proxy/layer/proxy_address.rs @@ -1,6 +1,6 @@ use rama_core::{ - error::{ErrorContext, OpaqueError}, Context, Layer, Service, + error::{ErrorContext, OpaqueError}, }; use rama_net::address::ProxyAddress; use std::{fmt, future::Future}; @@ -48,11 +48,7 @@ impl HttpProxyAddressLayer { let env_result = std::env::var(key.as_ref()).ok(); let env_result_mapped = env_result.as_ref().and_then(|v| { let v = v.trim(); - if v.is_empty() { - None - } else { - Some(v) - } + if v.is_empty() { None } else { Some(v) } }); let proxy_address = match env_result_mapped { @@ -146,11 +142,7 @@ impl HttpProxyAddressService { let env_result = std::env::var(key.as_ref()).ok(); let env_result_mapped = env_result.as_ref().and_then(|v| { let v = v.trim(); - if v.is_empty() { - None - } else { - Some(v) - } + if v.is_empty() { None } else { Some(v) } }); let proxy_address = match env_result_mapped { diff --git a/rama-http-backend/src/client/proxy/layer/proxy_auth_header.rs b/rama-http-backend/src/client/proxy/layer/proxy_auth_header.rs index 2a6fcfd74..c9b9202bf 100644 --- a/rama-http-backend/src/client/proxy/layer/proxy_auth_header.rs +++ b/rama-http-backend/src/client/proxy/layer/proxy_auth_header.rs @@ -1,7 +1,7 @@ use rama_core::{Context, Layer, Service}; use rama_http_types::{ - headers::{HeaderMapExt, ProxyAuthorization}, Request, + headers::{HeaderMapExt, ProxyAuthorization}, }; use rama_net::{address::ProxyAddress, http::RequestContext, user::ProxyCredential}; use std::{fmt, future::Future}; diff --git a/rama-http-backend/src/client/proxy/layer/proxy_connector/connector.rs b/rama-http-backend/src/client/proxy/layer/proxy_connector/connector.rs index d3e53c5b0..62c2d3f1a 100644 --- a/rama-http-backend/src/client/proxy/layer/proxy_connector/connector.rs +++ b/rama-http-backend/src/client/proxy/layer/proxy_connector/connector.rs @@ -5,9 +5,9 @@ use rama_core::error::{ErrorContext, OpaqueError}; use rama_http_core::{client::conn::http1, upgrade}; use rama_http_types::{ + Body, HeaderName, HeaderValue, Method, Request, StatusCode, Version, header::{HOST, USER_AGENT}, headers::{Header, HeaderMapExt}, - Body, HeaderName, HeaderValue, Method, Request, StatusCode, Version, }; use rama_net::{address::Authority, stream::Stream}; diff --git a/rama-http-backend/src/client/proxy/layer/proxy_connector/service.rs b/rama-http-backend/src/client/proxy/layer/proxy_connector/service.rs index 8174fbb0f..5319824b0 100644 --- a/rama-http-backend/src/client/proxy/layer/proxy_connector/service.rs +++ b/rama-http-backend/src/client/proxy/layer/proxy_connector/service.rs @@ -2,9 +2,9 @@ use crate::client::proxy::layer::HttpProxyError; use super::InnerHttpProxyConnector; use rama_core::{ + Context, Service, combinators::Either, error::{BoxError, ErrorExt, OpaqueError}, - Context, Service, }; use rama_http_core::upgrade; use rama_http_types::headers::ProxyAuthorization; @@ -144,7 +144,9 @@ where return if self.required { Err("http proxy required but none is defined".into()) } else { - tracing::trace!("http proxy connector: no proxy required or set: proceed with direct connection"); + tracing::trace!( + "http proxy connector: no proxy required or set: proceed with direct connection" + ); let EstablishedClientConnection { ctx, req, diff --git a/rama-http-backend/src/client/svc.rs b/rama-http-backend/src/client/svc.rs index c3af5730c..9e25cdac8 100644 --- a/rama-http-backend/src/client/svc.rs +++ b/rama-http-backend/src/client/svc.rs @@ -1,12 +1,12 @@ use rama_core::{ - error::{BoxError, ErrorContext, OpaqueError}, Context, Service, + error::{BoxError, ErrorContext, OpaqueError}, }; use rama_http_types::{ + Method, Request, Response, Version, dep::{http::uri::PathAndQuery, http_body}, header::{CONNECTION, HOST, KEEP_ALIVE, PROXY_CONNECTION, TRANSFER_ENCODING, UPGRADE}, headers::HeaderMapExt, - Method, Request, Response, Version, }; use rama_net::{address::ProxyAddress, http::RequestContext}; diff --git a/rama-http-backend/src/server/hyper_conn.rs b/rama-http-backend/src/server/hyper_conn.rs index ea8e39c20..210d897cd 100644 --- a/rama-http-backend/src/server/hyper_conn.rs +++ b/rama-http-backend/src/server/hyper_conn.rs @@ -66,8 +66,8 @@ fn map_http_core_err_to_result(err: rama_http_core::Error) -> HttpServeResult { } mod private { - use crate::server::hyper_conn::{map_boxed_http_core_result, map_http_core_result}; use crate::server::HttpServeResult; + use crate::server::hyper_conn::{map_boxed_http_core_result, map_http_core_result}; use rama_core::{Context, Service}; use rama_http_core::service::RamaHttpService; use rama_http_types::{IntoResponse, Request}; diff --git a/rama-http-backend/src/server/layer/upgrade/layer.rs b/rama-http-backend/src/server/layer/upgrade/layer.rs index 33aa090eb..3098d139e 100644 --- a/rama-http-backend/src/server/layer/upgrade/layer.rs +++ b/rama-http-backend/src/server/layer/upgrade/layer.rs @@ -1,5 +1,5 @@ -use super::{service::UpgradeHandler, UpgradeService, Upgraded}; -use rama_core::{matcher::Matcher, Context, Layer, Service}; +use super::{UpgradeService, Upgraded, service::UpgradeHandler}; +use rama_core::{Context, Layer, Service, matcher::Matcher}; use rama_http_types::Request; use std::{convert::Infallible, fmt, sync::Arc}; diff --git a/rama-http-backend/src/server/layer/upgrade/service.rs b/rama-http-backend/src/server/layer/upgrade/service.rs index d3f75d704..1314b8dc4 100644 --- a/rama-http-backend/src/server/layer/upgrade/service.rs +++ b/rama-http-backend/src/server/layer/upgrade/service.rs @@ -3,7 +3,7 @@ //! See [`UpgradeService`] for more details. use super::Upgraded; -use rama_core::{context::Extensions, matcher::Matcher, service::BoxService, Context, Service}; +use rama_core::{Context, Service, context::Extensions, matcher::Matcher, service::BoxService}; use rama_http_types::Request; use rama_utils::macros::define_inner_service_accessors; use std::{convert::Infallible, fmt, sync::Arc}; diff --git a/rama-http-backend/src/server/service.rs b/rama-http-backend/src/server/service.rs index 4ecf5674b..a3509e205 100644 --- a/rama-http-backend/src/server/service.rs +++ b/rama-http-backend/src/server/service.rs @@ -1,7 +1,7 @@ //! Rama HTTP server module. -use super::hyper_conn::HttpCoreConnServer; use super::HttpServeResult; +use super::hyper_conn::HttpCoreConnServer; use rama_core::error::BoxError; use rama_core::graceful::ShutdownGuard; use rama_core::rt::Executor; diff --git a/rama-http-core/README.md b/rama-http-core/README.md index dda18dca2..6c9f6f8a6 100644 --- a/rama-http-core/README.md +++ b/rama-http-core/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-http-core/examples/h2_client.rs b/rama-http-core/examples/h2_client.rs index e611a17f6..eaeef082e 100644 --- a/rama-http-core/examples/h2_client.rs +++ b/rama-http-core/examples/h2_client.rs @@ -28,7 +28,7 @@ use rama_error::BoxError; use rama_http_core::h2::client; use rama_http_types::{ - proto::h1::headers::original::OriginalHttp1Headers, HeaderMap, HeaderName, Request, + HeaderMap, HeaderName, Request, proto::h1::headers::original::OriginalHttp1Headers, }; use tokio::net::TcpStream; diff --git a/rama-http-core/examples/h2_example.rs b/rama-http-core/examples/h2_example.rs index 66e88928a..756443110 100644 --- a/rama-http-core/examples/h2_example.rs +++ b/rama-http-core/examples/h2_example.rs @@ -23,8 +23,8 @@ use rama_http_core::h2::client; use rama_http_types::{Method, Request}; use tokio::net::TcpStream; -use tokio_rustls::rustls::{pki_types::ServerName, RootCertStore}; use tokio_rustls::TlsConnector; +use tokio_rustls::rustls::{RootCertStore, pki_types::ServerName}; use std::net::ToSocketAddrs; diff --git a/rama-http-core/examples/h2_server.rs b/rama-http-core/examples/h2_server.rs index c7f352c3a..05dfab73c 100644 --- a/rama-http-core/examples/h2_server.rs +++ b/rama-http-core/examples/h2_server.rs @@ -29,8 +29,8 @@ //! ``` use rama_error::BoxError; -use rama_http_core::h2::server::{self, SendResponse}; use rama_http_core::h2::RecvStream; +use rama_http_core::h2::server::{self, SendResponse}; use rama_http_types::Request; use bytes::Bytes; diff --git a/rama-http-core/src/body/incoming.rs b/rama-http-core/src/body/incoming.rs index d5eb1afe1..657714e0f 100644 --- a/rama-http-core/src/body/incoming.rs +++ b/rama-http-core/src/body/incoming.rs @@ -5,9 +5,9 @@ use std::task::{Context, Poll}; use bytes::Bytes; use futures_channel::{mpsc, oneshot}; -use futures_util::{stream::FusedStream, Stream}; // for mpsc::Receiver -use rama_http_types::dep::http_body::{Body, Frame, SizeHint}; +use futures_util::{Stream, stream::FusedStream}; // for mpsc::Receiver use rama_http_types::HeaderMap; +use rama_http_types::dep::http_body::{Body, Frame, SizeHint}; use std::task::ready; use super::DecodedLength; diff --git a/rama-http-core/src/client/conn/http1.rs b/rama-http-core/src/client/conn/http1.rs index 0424f4c9d..7630cdd54 100644 --- a/rama-http-core/src/client/conn/http1.rs +++ b/rama-http-core/src/client/conn/http1.rs @@ -3,7 +3,7 @@ use std::fmt; use std::future::Future; use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::{Context, Poll, ready}; use bytes::Bytes; use httparse::ParserConfig; @@ -185,7 +185,7 @@ where pub fn send_request( &self, req: Request, - ) -> impl Future>> { + ) -> impl Future>> + use { let sent = self.dispatch.send(req); async move { diff --git a/rama-http-core/src/client/dispatch.rs b/rama-http-core/src/client/dispatch.rs index 7b8335a2e..05ff952f7 100644 --- a/rama-http-core/src/client/dispatch.rs +++ b/rama-http-core/src/client/dispatch.rs @@ -349,7 +349,7 @@ mod tests { use std::pin::Pin; use std::task::{Context, Poll}; - use super::{channel, Callback, Receiver}; + use super::{Callback, Receiver, channel}; #[derive(Debug)] struct Custom(#[allow(dead_code)] i32); diff --git a/rama-http-core/src/common/watch.rs b/rama-http-core/src/common/watch.rs index fccf82f75..5b283b4ca 100644 --- a/rama-http-core/src/common/watch.rs +++ b/rama-http-core/src/common/watch.rs @@ -5,8 +5,8 @@ //! - The value `0` is reserved for closed. use std::sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }; use std::task; diff --git a/rama-http-core/src/ext/mod.rs b/rama-http-core/src/ext/mod.rs index f475f90d1..899e52b0b 100644 --- a/rama-http-core/src/ext/mod.rs +++ b/rama-http-core/src/ext/mod.rs @@ -6,8 +6,8 @@ mod h1_reason_phrase; pub use h1_reason_phrase::ReasonPhrase; mod informational; -pub use informational::on_informational; pub(crate) use informational::OnInformational; +pub use informational::on_informational; // pub(crate) use informational::{on_informational_raw, OnInformationalCallback}; // ffi feature in hyperium/hyper /// Represents the `:protocol` pseudo-header used by diff --git a/rama-http-core/src/h2/client.rs b/rama-http-core/src/h2/client.rs index f44845a49..7f04139ea 100644 --- a/rama-http-core/src/h2/client.rs +++ b/rama-http-core/src/h2/client.rs @@ -1222,7 +1222,7 @@ impl Builder { pub fn handshake( &self, io: T, - ) -> impl Future, Connection), crate::h2::Error>> + ) -> impl Future, Connection), crate::h2::Error>> + use where T: AsyncRead + AsyncWrite + Unpin, B: Buf, diff --git a/rama-http-core/src/h2/error.rs b/rama-http-core/src/h2/error.rs index 61e613a60..aa295ca1b 100644 --- a/rama-http-core/src/h2/error.rs +++ b/rama-http-core/src/h2/error.rs @@ -163,13 +163,13 @@ impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let debug_data = match self.kind { Kind::Reset(_, reason, Initiator::User) => { - return write!(fmt, "stream error sent by user: {}", reason) + return write!(fmt, "stream error sent by user: {}", reason); } Kind::Reset(_, reason, Initiator::Library) => { - return write!(fmt, "stream error detected: {}", reason) + return write!(fmt, "stream error detected: {}", reason); } Kind::Reset(_, reason, Initiator::Remote) => { - return write!(fmt, "stream error received: {}", reason) + return write!(fmt, "stream error received: {}", reason); } Kind::GoAway(ref debug_data, reason, Initiator::User) => { write!(fmt, "connection error sent by user: {}", reason)?; diff --git a/rama-http-core/src/h2/frame/data.rs b/rama-http-core/src/h2/frame/data.rs index c27ec0be7..4b21a4934 100644 --- a/rama-http-core/src/h2/frame/data.rs +++ b/rama-http-core/src/h2/frame/data.rs @@ -1,4 +1,4 @@ -use crate::h2::frame::{util, Error, Frame, Head, Kind, StreamId}; +use crate::h2::frame::{Error, Frame, Head, Kind, StreamId, util}; use bytes::{Buf, BufMut, Bytes}; use std::fmt; diff --git a/rama-http-core/src/h2/frame/headers.rs b/rama-http-core/src/h2/frame/headers.rs index 54adcd45f..adfd0af8d 100644 --- a/rama-http-core/src/h2/frame/headers.rs +++ b/rama-http-core/src/h2/frame/headers.rs @@ -1,14 +1,14 @@ -use super::{util, StreamDependency, StreamId}; +use super::{StreamDependency, StreamId, util}; use crate::h2::ext::Protocol; use crate::h2::frame::{Error, Frame, Head, Kind}; use crate::h2::hpack::{self, BytesStr}; use rama_http_types::dep::http::uri; -use rama_http_types::proto::h1::headers::original::OriginalHttp1Headers; -use rama_http_types::proto::h1::headers::Http1HeaderMapIntoIter; use rama_http_types::proto::h1::Http1HeaderMap; +use rama_http_types::proto::h1::headers::Http1HeaderMapIntoIter; +use rama_http_types::proto::h1::headers::original::OriginalHttp1Headers; use rama_http_types::proto::h2::{PseudoHeader, PseudoHeaderOrder, PseudoHeaderOrderIter}; -use rama_http_types::{header, HeaderMap, HeaderName, Method, Request, StatusCode, Uri}; +use rama_http_types::{HeaderMap, HeaderName, Method, Request, StatusCode, Uri, header}; use bytes::{Buf, BufMut, Bytes, BytesMut}; diff --git a/rama-http-core/src/h2/frame/mod.rs b/rama-http-core/src/h2/frame/mod.rs index a9e04d9a9..b53ef9024 100644 --- a/rama-http-core/src/h2/frame/mod.rs +++ b/rama-http-core/src/h2/frame/mod.rs @@ -52,7 +52,7 @@ pub use self::data::Data; pub use self::go_away::GoAway; pub use self::head::{Head, Kind}; pub use self::headers::{ - parse_u64, Continuation, Headers, Pseudo, PushPromise, PushPromiseHeaderError, + Continuation, Headers, Pseudo, PushPromise, PushPromiseHeaderError, parse_u64, }; pub use self::ping::Ping; pub use self::priority::{Priority, StreamDependency}; diff --git a/rama-http-core/src/h2/frame/settings.rs b/rama-http-core/src/h2/frame/settings.rs index 7240bc59a..126516fe9 100644 --- a/rama-http-core/src/h2/frame/settings.rs +++ b/rama-http-core/src/h2/frame/settings.rs @@ -1,6 +1,6 @@ use std::fmt; -use crate::h2::frame::{util, Error, Frame, FrameSize, Head, Kind, StreamId}; +use crate::h2::frame::{Error, Frame, FrameSize, Head, Kind, StreamId, util}; use bytes::{BufMut, BytesMut}; #[derive(Clone, Default, Eq, PartialEq)] diff --git a/rama-http-core/src/h2/hpack/decoder.rs b/rama-http-core/src/h2/hpack/decoder.rs index ff90e5833..bb7a1fd37 100644 --- a/rama-http-core/src/h2/hpack/decoder.rs +++ b/rama-http-core/src/h2/hpack/decoder.rs @@ -1,4 +1,4 @@ -use super::{header::BytesStr, huffman, Header}; +use super::{Header, header::BytesStr, huffman}; use crate::h2::frame; use bytes::{Buf, Bytes, BytesMut}; diff --git a/rama-http-core/src/h2/hpack/encoder.rs b/rama-http-core/src/h2/hpack/encoder.rs index 981b5669a..81fe6867d 100644 --- a/rama-http-core/src/h2/hpack/encoder.rs +++ b/rama-http-core/src/h2/hpack/encoder.rs @@ -1,5 +1,5 @@ use super::table::{Index, Table}; -use super::{huffman, Header}; +use super::{Header, huffman}; use bytes::{BufMut, BytesMut}; use rama_http_types::dep::http::header::{HeaderName, HeaderValue}; @@ -330,7 +330,7 @@ mod test { let res = encode(&mut encoder, vec![method("PATCH")]); - assert_eq!(1 << 7 | 62, res[0]); + assert_eq!((1 << 7) | 62, res[0]); assert_eq!(1, res.len()); } diff --git a/rama-http-core/src/h2/hpack/test/fuzz.rs b/rama-http-core/src/h2/hpack/test/fuzz.rs index 789d087ab..993d8bddb 100644 --- a/rama-http-core/src/h2/hpack/test/fuzz.rs +++ b/rama-http-core/src/h2/hpack/test/fuzz.rs @@ -6,7 +6,7 @@ use bytes::BytesMut; use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult}; use rand::distr::slice::Choose; use rand::rngs::StdRng; -use rand::{rng, Rng, SeedableRng}; +use rand::{Rng, SeedableRng, rng}; use std::io::Cursor; diff --git a/rama-http-core/src/h2/proto/connection.rs b/rama-http-core/src/h2/proto/connection.rs index 73d2c2e2c..6c34f0b35 100644 --- a/rama-http-core/src/h2/proto/connection.rs +++ b/rama-http-core/src/h2/proto/connection.rs @@ -190,10 +190,11 @@ where // The order of these calls don't really matter too much ready!(self.inner.ping_pong.send_pending_pong(cx, &mut self.codec))?; ready!(self.inner.ping_pong.send_pending_ping(cx, &mut self.codec))?; - ready!(self - .inner - .settings - .poll_send(cx, &mut self.codec, &mut self.inner.streams))?; + ready!( + self.inner + .settings + .poll_send(cx, &mut self.codec, &mut self.inner.streams) + )?; ready!(self.inner.streams.send_pending_refusal(cx, &mut self.codec))?; Poll::Ready(Ok(())) diff --git a/rama-http-core/src/h2/proto/ping_pong.rs b/rama-http-core/src/h2/proto/ping_pong.rs index 635b15392..af6319213 100644 --- a/rama-http-core/src/h2/proto/ping_pong.rs +++ b/rama-http-core/src/h2/proto/ping_pong.rs @@ -5,8 +5,8 @@ use crate::h2::proto::{self, PingPayload}; use atomic_waker::AtomicWaker; use bytes::Buf; use std::io; -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::task::{Context, Poll}; use tokio::io::AsyncWrite; diff --git a/rama-http-core/src/h2/proto/streams/flow_control.rs b/rama-http-core/src/h2/proto/streams/flow_control.rs index 6bc4be613..6e9be6359 100644 --- a/rama-http-core/src/h2/proto/streams/flow_control.rs +++ b/rama-http-core/src/h2/proto/streams/flow_control.rs @@ -1,5 +1,5 @@ use crate::h2::frame::Reason; -use crate::h2::proto::{WindowSize, MAX_WINDOW_SIZE}; +use crate::h2::proto::{MAX_WINDOW_SIZE, WindowSize}; use std::fmt; @@ -206,11 +206,7 @@ pub struct Window(i32); impl Window { pub fn as_size(&self) -> WindowSize { - if self.0 < 0 { - 0 - } else { - self.0 as WindowSize - } + if self.0 < 0 { 0 } else { self.0 as WindowSize } } pub fn checked_size(&self) -> WindowSize { diff --git a/rama-http-core/src/h2/proto/streams/recv.rs b/rama-http-core/src/h2/proto/streams/recv.rs index b1c7c4447..1144343d0 100644 --- a/rama-http-core/src/h2/proto/streams/recv.rs +++ b/rama-http-core/src/h2/proto/streams/recv.rs @@ -1,6 +1,6 @@ use super::*; use crate::h2::codec::UserError; -use crate::h2::frame::{PushPromiseHeaderError, Reason, DEFAULT_INITIAL_WINDOW_SIZE}; +use crate::h2::frame::{DEFAULT_INITIAL_WINDOW_SIZE, PushPromiseHeaderError, Reason}; use crate::h2::proto; use rama_http_types::proto::h1::headers::original::OriginalHttp1Headers; @@ -193,7 +193,7 @@ impl Recv { && frame .pseudo() .status - .map_or(true, |status| status != 204 && status != 304) + .is_none_or(|status| status != 204 && status != 304) { proto_err!(stream: "recv_headers with END_STREAM: content-length is not zero; stream={:?};", stream.id); return Err(Error::library_reset(stream.id, Reason::PROTOCOL_ERROR).into()); diff --git a/rama-http-core/src/h2/proto/streams/send.rs b/rama-http-core/src/h2/proto/streams/send.rs index 0bce63997..40cb1e76b 100644 --- a/rama-http-core/src/h2/proto/streams/send.rs +++ b/rama-http-core/src/h2/proto/streams/send.rs @@ -1,6 +1,6 @@ use super::{ - store, Buffer, Codec, Config, Counts, Frame, Prioritize, Prioritized, Store, Stream, StreamId, - StreamIdOverflow, WindowSize, + Buffer, Codec, Config, Counts, Frame, Prioritize, Prioritized, Store, Stream, StreamId, + StreamIdOverflow, WindowSize, store, }; use crate::h2::codec::UserError; use crate::h2::frame::{self, Reason}; diff --git a/rama-http-core/src/h2/proto/streams/streams.rs b/rama-http-core/src/h2/proto/streams/streams.rs index 3bad648f0..8bb33aa9f 100644 --- a/rama-http-core/src/h2/proto/streams/streams.rs +++ b/rama-http-core/src/h2/proto/streams/streams.rs @@ -4,7 +4,7 @@ use super::{Buffer, Config, Counts, Prioritized, Recv, Send, Stream, StreamId}; use crate::h2::codec::{Codec, SendError, UserError}; use crate::h2::ext::Protocol; use crate::h2::frame::{self, Frame, Reason}; -use crate::h2::proto::{peer, Error, Initiator, Open, Peer, WindowSize}; +use crate::h2::proto::{Error, Initiator, Open, Peer, WindowSize, peer}; use crate::h2::{client, proto, server}; use bytes::{Buf, Bytes}; @@ -905,10 +905,11 @@ impl Inner { // // TODO: It would probably be better to interleave updates w/ data // frames. - ready!(self - .actions - .recv - .poll_complete(cx, &mut self.store, &mut self.counts, dst))?; + ready!( + self.actions + .recv + .poll_complete(cx, &mut self.store, &mut self.counts, dst) + )?; // Send any other pending frames ready!(self.actions.send.poll_complete( diff --git a/rama-http-core/src/h2/server.rs b/rama-http-core/src/h2/server.rs index b8a3a6ed7..0d9246c4a 100644 --- a/rama-http-core/src/h2/server.rs +++ b/rama-http-core/src/h2/server.rs @@ -1534,7 +1534,7 @@ impl proto::Peer for Peer { field_order: OriginalHttp1Headers, stream_id: StreamId, ) -> Result { - use rama_http_types::{dep::http::uri, Version}; + use rama_http_types::{Version, dep::http::uri}; let mut b = Request::builder(); diff --git a/rama-http-core/src/h2/share.rs b/rama-http-core/src/h2/share.rs index 2930aa883..e099075e1 100644 --- a/rama-http-core/src/h2/share.rs +++ b/rama-http-core/src/h2/share.rs @@ -3,8 +3,8 @@ use crate::h2::frame::Reason; use crate::h2::proto::{self, WindowSize}; use bytes::{Buf, Bytes}; -use rama_http_types::proto::h1::headers::original::OriginalHttp1Headers; use rama_http_types::HeaderMap; +use rama_http_types::proto::h1::headers::original::OriginalHttp1Headers; use std::fmt; use std::pin::Pin; diff --git a/rama-http-core/src/headers.rs b/rama-http-core/src/headers.rs index 0808e2287..8a0520faf 100644 --- a/rama-http-core/src/headers.rs +++ b/rama-http-core/src/headers.rs @@ -1,7 +1,7 @@ use bytes::BytesMut; use rama_http_types::{ - header::{OccupiedEntry, ValueIter, CONTENT_LENGTH, TRANSFER_ENCODING}, HeaderMap, HeaderValue, Method, + header::{CONTENT_LENGTH, OccupiedEntry, TRANSFER_ENCODING, ValueIter}, }; pub(super) fn connection_keep_alive(value: &HeaderValue) -> bool { diff --git a/rama-http-core/src/proto/h1/conn.rs b/rama-http-core/src/proto/h1/conn.rs index ce72c1d9d..04746222d 100644 --- a/rama-http-core/src/proto/h1/conn.rs +++ b/rama-http-core/src/proto/h1/conn.rs @@ -3,7 +3,7 @@ use std::future::Future; use std::io; use std::marker::{PhantomData, Unpin}; use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::{Context, Poll, ready}; use std::time::Duration; use bytes::{Buf, Bytes}; @@ -476,7 +476,7 @@ where match self.state.reading { Reading::Continue(..) | Reading::Body(..) | Reading::KeepAlive | Reading::Closed => { - return + return; } Reading::Init => (), }; diff --git a/rama-http-core/src/proto/h1/decode.rs b/rama-http-core/src/proto/h1/decode.rs index 6671cc1ab..a9719ae54 100644 --- a/rama-http-core/src/proto/h1/decode.rs +++ b/rama-http-core/src/proto/h1/decode.rs @@ -10,9 +10,9 @@ use std::task::ready; use tracing::debug; use tracing::trace; +use super::DecodedLength; use super::io::MemRead; use super::role::DEFAULT_MAX_HEADERS; -use super::DecodedLength; use self::Kind::{Chunked, Eof, Length}; @@ -612,7 +612,7 @@ impl ChunkedState { buf.put_u8(byte); *trailers_buf = Some(buf); } - Some(ref mut trailers_buf) => { + Some(trailers_buf) => { put_u8!(trailers_buf, byte, h1_max_header_size); } } diff --git a/rama-http-core/src/proto/h1/dispatch.rs b/rama-http-core/src/proto/h1/dispatch.rs index 55b6cae27..7701acb81 100644 --- a/rama-http-core/src/proto/h1/dispatch.rs +++ b/rama-http-core/src/proto/h1/dispatch.rs @@ -37,7 +37,7 @@ pub(crate) trait Dispatch { cx: &mut Context<'_>, ) -> Poll>>; fn recv_msg(&mut self, msg: crate::Result<(Self::RecvItem, IncomingBody)>) - -> crate::Result<()>; + -> crate::Result<()>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll>; fn should_poll(&self) -> bool; } @@ -496,9 +496,9 @@ impl Drop for OptGuard<'_, T> { // ===== impl Server ===== impl< - S: HttpService, - B: Body + Send + 'static + Unpin>, - > Server + S: HttpService, + B: Body + Send + 'static + Unpin>, +> Server { pub(crate) fn new(service: S) -> Server { Server { @@ -515,9 +515,9 @@ impl< // Service is never pinned impl< - S: HttpService, - B: Body + Send + 'static + Unpin>, - > Unpin for Server + S: HttpService, + B: Body + Send + 'static + Unpin>, +> Unpin for Server { } diff --git a/rama-http-core/src/proto/h1/encode.rs b/rama-http-core/src/proto/h1/encode.rs index 46ca8e981..afa099dd2 100644 --- a/rama-http-core/src/proto/h1/encode.rs +++ b/rama-http-core/src/proto/h1/encode.rs @@ -5,11 +5,11 @@ use std::io::IoSlice; use bytes::buf::{Chain, Take}; use bytes::{Buf, Bytes}; use rama_http_types::{ + HeaderMap, HeaderName, HeaderValue, header::{ AUTHORIZATION, CACHE_CONTROL, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_RANGE, CONTENT_TYPE, HOST, MAX_FORWARDS, SET_COOKIE, TE, TRAILER, TRANSFER_ENCODING, }, - HeaderMap, HeaderName, HeaderValue, }; use tracing::{debug, trace}; @@ -438,11 +438,11 @@ impl std::error::Error for NotEof {} mod tests { use bytes::BufMut; use rama_http_types::{ + HeaderMap, HeaderName, HeaderValue, header::{ AUTHORIZATION, CACHE_CONTROL, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_RANGE, CONTENT_TYPE, HOST, MAX_FORWARDS, SET_COOKIE, TE, TRAILER, TRANSFER_ENCODING, }, - HeaderMap, HeaderName, HeaderValue, }; use super::super::io::Cursor; @@ -582,9 +582,11 @@ mod tests { HeaderValue::from_static("header data"), )]); - assert!(encoder - .encode_trailers::<&[u8]>(headers.clone(), false) - .is_none()); + assert!( + encoder + .encode_trailers::<&[u8]>(headers.clone(), false) + .is_none() + ); let trailers = vec![]; let encoder = encoder.into_chunked_with_trailing_fields(trailers); diff --git a/rama-http-core/src/proto/h1/io.rs b/rama-http-core/src/proto/h1/io.rs index bbbfca4eb..549394ce8 100644 --- a/rama-http-core/src/proto/h1/io.rs +++ b/rama-http-core/src/proto/h1/io.rs @@ -693,9 +693,11 @@ mod tests { h09_responses: false, on_informational: &mut None, }; - assert!(buffered - .parse::(cx, parse_ctx) - .is_pending()); + assert!( + buffered + .parse::(cx, parse_ctx) + .is_pending() + ); Poll::Ready(()) }) .await; diff --git a/rama-http-core/src/proto/h1/role.rs b/rama-http-core/src/proto/h1/role.rs index 8be450719..dd323549f 100644 --- a/rama-http-core/src/proto/h1/role.rs +++ b/rama-http-core/src/proto/h1/role.rs @@ -9,7 +9,7 @@ use rama_http_types::header::Entry; use rama_http_types::header::{self, HeaderMap, HeaderValue}; use rama_http_types::proto::h1::{Http1HeaderMap, Http1HeaderName}; use rama_http_types::{Method, StatusCode, Version}; -use smallvec::{smallvec, smallvec_inline, SmallVec}; +use smallvec::{SmallVec, smallvec, smallvec_inline}; use tracing::{debug, error, trace, trace_span, warn}; use crate::body::DecodedLength; @@ -28,11 +28,7 @@ const AVERAGE_HEADER_SIZE: usize = 30; // totally scientific const MAX_URI_LEN: usize = (u16::MAX - 1) as usize; macro_rules! header_value { - ($bytes:expr) => {{ - { - unsafe { HeaderValue::from_maybe_shared_unchecked($bytes) } - } - }}; + ($bytes:expr) => {{ { unsafe { HeaderValue::from_maybe_shared_unchecked($bytes) } } }}; } pub(super) fn parse_headers( @@ -301,9 +297,7 @@ impl Http1Transaction for Server { fn encode(mut msg: Encode<'_, Self::Outgoing>, dst: &mut Vec) -> crate::Result { trace!( "Server::encode status={:?}, body={:?}, req_method={:?}", - msg.head.subject, - msg.body, - msg.req_method + msg.head.subject, msg.body, msg.req_method ); let mut wrote_len = false; @@ -567,11 +561,11 @@ impl Server { if let Some(len) = headers::content_length_parse(&value) { if msg.req_method != &Some(Method::HEAD) || known_len != 0 { assert!( - len == known_len, - "payload claims content-length of {}, custom content-length header claims {}", - known_len, - len, - ); + len == known_len, + "payload claims content-length of {}, custom content-length header claims {}", + known_len, + len, + ); } } } @@ -774,8 +768,7 @@ impl Server { if !Server::can_have_body(msg.req_method, msg.head.subject) { trace!( "server body forced to 0; method={:?}, status={:?}", - msg.req_method, - msg.head.subject + msg.req_method, msg.head.subject ); encoder = Encoder::length(0); } @@ -973,8 +966,7 @@ impl Http1Transaction for Client { fn encode(mut msg: Encode<'_, Self::Outgoing>, dst: &mut Vec) -> crate::Result { trace!( "Client::encode method={:?}, body={:?}", - msg.head.subject.0, - msg.body + msg.head.subject.0, msg.body ); *msg.req_method = Some(msg.head.subject.0.clone()); @@ -1820,18 +1812,20 @@ mod tests { fn parse_ignores(s: &str) { let mut bytes = BytesMut::from(s); - assert!(Client::parse( - &mut bytes, - ParseContext { - req_method: &mut Some(Method::GET), - h1_parser_config: Default::default(), - h1_max_headers: None, - h09_responses: false, - on_informational: &mut None, - } + assert!( + Client::parse( + &mut bytes, + ParseContext { + req_method: &mut Some(Method::GET), + h1_parser_config: Default::default(), + h1_max_headers: None, + h09_responses: false, + on_informational: &mut None, + } + ) + .expect("parse ok") + .is_none() ) - .expect("parse ok") - .is_none()) } fn parse_with_method(s: &str, m: Method) -> ParsedMessage { diff --git a/rama-http-core/src/proto/h2/client.rs b/rama-http-core/src/proto/h2/client.rs index a8be58617..9644fabdd 100644 --- a/rama-http-core/src/proto/h2/client.rs +++ b/rama-http-core/src/proto/h2/client.rs @@ -16,21 +16,21 @@ use futures_util::stream::{StreamExt as _, StreamFuture}; use pin_project_lite::pin_project; use rama_core::error::BoxError; use rama_core::rt::Executor; -use rama_http_types::{dep::http_body, Method, Request, Response, StatusCode}; +use rama_http_types::{Method, Request, Response, StatusCode, dep::http_body}; use tokio::io::{AsyncRead, AsyncWrite}; use tracing::{debug, trace, warn}; use super::ping::{Ponger, Recorder}; -use super::{ping, H2Upgraded, PipeToSendStream, SendBuf}; +use super::{H2Upgraded, PipeToSendStream, SendBuf, ping}; use crate::body::{Body, Incoming as IncomingBody}; use crate::client::dispatch::{Callback, SendWhen, TrySendError}; use crate::ext::Protocol; +use crate::h2::SendStream; use crate::h2::client::ResponseFuture; use crate::h2::client::{Builder, Connection, SendRequest}; -use crate::h2::SendStream; use crate::headers; -use crate::proto::h2::UpgradedSendStream; use crate::proto::Dispatched; +use crate::proto::h2::UpgradedSendStream; use crate::upgrade::Upgraded; type ClientRx = crate::client::dispatch::Receiver, Response>; diff --git a/rama-http-core/src/proto/h2/mod.rs b/rama-http-core/src/proto/h2/mod.rs index dd5ca2d90..e1b390aaf 100644 --- a/rama-http-core/src/proto/h2/mod.rs +++ b/rama-http-core/src/proto/h2/mod.rs @@ -286,7 +286,7 @@ where match ready!(self.recv_stream.poll_data(cx)) { None => return Poll::Ready(Ok(())), Some(Ok(buf)) if buf.is_empty() && !self.recv_stream.is_end_stream() => { - continue + continue; } Some(Ok(buf)) => { self.ping.record_data(buf.len()); @@ -299,7 +299,7 @@ where Err(std::io::Error::new(std::io::ErrorKind::BrokenPipe, e)) } _ => Err(h2_to_io_error(e)), - }) + }); } } }; @@ -345,7 +345,7 @@ where Poll::Ready(Err(h2_to_io_error( match ready!(self.send_stream.poll_reset(cx)) { Ok(Reason::NO_ERROR | Reason::CANCEL | Reason::STREAM_CLOSED) => { - return Poll::Ready(Err(std::io::ErrorKind::BrokenPipe.into())) + return Poll::Ready(Err(std::io::ErrorKind::BrokenPipe.into())); } Ok(reason) => reason.into(), Err(e) => e, @@ -369,7 +369,7 @@ where match ready!(self.send_stream.poll_reset(cx)) { Ok(Reason::NO_ERROR) => return Poll::Ready(Ok(())), Ok(Reason::CANCEL | Reason::STREAM_CLOSED) => { - return Poll::Ready(Err(std::io::ErrorKind::BrokenPipe.into())) + return Poll::Ready(Err(std::io::ErrorKind::BrokenPipe.into())); } Ok(reason) => reason.into(), Err(e) => e, @@ -395,7 +395,7 @@ where unsafe fn new(inner: SendStream>) -> Self { assert_eq!(mem::size_of::(), mem::size_of::>()); #[allow(clippy::missing_transmute_annotations)] - Self(mem::transmute(inner)) + Self(unsafe { mem::transmute(inner) }) } fn reserve_capacity(&mut self, cnt: usize) { @@ -426,7 +426,7 @@ where } unsafe fn as_inner_unchecked(&mut self) -> &mut SendStream> { - &mut *(&mut self.0 as *mut _ as *mut _) + unsafe { &mut *(&mut self.0 as *mut _ as *mut _) } } } diff --git a/rama-http-core/src/proto/h2/server.rs b/rama-http-core/src/proto/h2/server.rs index 6e3f72200..efc98ddbf 100644 --- a/rama-http-core/src/proto/h2/server.rs +++ b/rama-http-core/src/proto/h2/server.rs @@ -1,6 +1,6 @@ use std::future::Future; use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::{Context, Poll, ready}; use std::time::Duration; use crate::h2::server::{Connection, Handshake, SendResponse}; @@ -9,18 +9,18 @@ use bytes::Bytes; use pin_project_lite::pin_project; use rama_core::error::BoxError; use rama_core::rt::Executor; -use rama_http_types::{header, Method, Request, Response}; +use rama_http_types::{Method, Request, Response, header}; use tokio::io::{AsyncRead, AsyncWrite}; use tracing::{debug, trace, warn}; -use super::{ping, PipeToSendStream, SendBuf}; +use super::{PipeToSendStream, SendBuf, ping}; use crate::body::{Body, Incoming as IncomingBody}; use crate::common::date; use crate::ext::Protocol; use crate::headers; +use crate::proto::Dispatched; use crate::proto::h2::ping::Recorder; use crate::proto::h2::{H2Upgraded, UpgradedSendStream}; -use crate::proto::Dispatched; use crate::service::HttpService; use crate::upgrade::{OnUpgrade, Pending, Upgraded}; @@ -461,12 +461,16 @@ where if headers::content_length_parse_all(res.headers()) .is_some_and(|len| len != 0) { - warn!("h2 successful response to CONNECT request with body not supported"); + warn!( + "h2 successful response to CONNECT request with body not supported" + ); me.reply.send_reset(crate::h2::Reason::INTERNAL_ERROR); return Poll::Ready(Err(crate::Error::new_user_header())); } if res.headers_mut().remove(header::CONTENT_LENGTH).is_some() { - warn!("successful response to CONNECT request disallows content-length header"); + warn!( + "successful response to CONNECT request disallows content-length header" + ); } let send_stream = reply!(me, res, false); connect_parts.pending.fulfill(Upgraded::new( diff --git a/rama-http-core/src/proto/mod.rs b/rama-http-core/src/proto/mod.rs index 273b1a7b8..f5c1e043a 100644 --- a/rama-http-core/src/proto/mod.rs +++ b/rama-http-core/src/proto/mod.rs @@ -1,14 +1,14 @@ //! Pieces pertaining to the HTTP message protocol. -use rama_http_types::dep::http; use rama_http_types::HeaderMap; use rama_http_types::Version; +use rama_http_types::dep::http; pub(crate) mod h1; -pub(crate) use self::h1::dispatch; pub(crate) use self::h1::Conn; pub(crate) use self::h1::ServerTransaction; +pub(crate) use self::h1::dispatch; pub(crate) mod h2; diff --git a/rama-http-core/src/server/conn/auto.rs b/rama-http-core/src/server/conn/auto.rs index d2400a2d3..902cc3409 100644 --- a/rama-http-core/src/server/conn/auto.rs +++ b/rama-http-core/src/server/conn/auto.rs @@ -226,7 +226,7 @@ impl std::ops::Deref for Cow<'_, T> { fn deref(&self) -> &T { match self { Cow::Borrowed(t) => t, - Cow::Owned(ref t) => t, + Cow::Owned(t) => t, } } } @@ -763,10 +763,10 @@ mod tests { use crate::server::conn::auto; use crate::service::RamaHttpService; use crate::{body::Bytes, client}; + use rama_core::Context; use rama_core::error::BoxError; use rama_core::rt::Executor; use rama_core::service::service_fn; - use rama_core::Context; use rama_http_types::dep::http_body::Body; use rama_http_types::dep::http_body_util::{BodyExt, Empty}; use rama_http_types::{Request, Response}; @@ -887,7 +887,7 @@ mod tests { #[cfg(not(miri))] #[tokio::test] async fn graceful_shutdown() { - use rama_core::{service::service_fn, Context}; + use rama_core::{Context, service::service_fn}; use crate::service::RamaHttpService; diff --git a/rama-http-core/src/service.rs b/rama-http-core/src/service.rs index b6764e6ba..1e1850d56 100644 --- a/rama-http-core/src/service.rs +++ b/rama-http-core/src/service.rs @@ -1,5 +1,5 @@ use bytes::Bytes; -use rama_core::{error::BoxError, Context, Service}; +use rama_core::{Context, Service, error::BoxError}; use rama_http_types::{Request, Response}; use std::{convert::Infallible, fmt, future::Future}; diff --git a/rama-http-core/tests/h2-fuzz/Cargo.toml b/rama-http-core/tests/h2-fuzz/Cargo.toml index 31a95111c..5f1237345 100644 --- a/rama-http-core/tests/h2-fuzz/Cargo.toml +++ b/rama-http-core/tests/h2-fuzz/Cargo.toml @@ -3,7 +3,7 @@ name = "h2-fuzz" version = "0.0.0" publish = false license = "MIT" -edition = "2021" +edition = "2024" [dependencies] futures = { workspace = true } diff --git a/rama-http-core/tests/h2-fuzz/src/main.rs b/rama-http-core/tests/h2-fuzz/src/main.rs index 0cc178945..4354326d6 100644 --- a/rama-http-core/tests/h2-fuzz/src/main.rs +++ b/rama-http-core/tests/h2-fuzz/src/main.rs @@ -1,6 +1,6 @@ +use futures::Stream; use futures::future; use futures::stream::FuturesUnordered; -use futures::Stream; use rama_http_types::{Method, Request}; use std::future::Future; use std::io; @@ -10,7 +10,7 @@ use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tracing::level_filters::LevelFilter; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{fmt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt}; struct MockIo<'a> { input: &'a [u8], @@ -27,7 +27,7 @@ impl MockIo<'_> { } fn next_u32(&mut self) -> u32 { - (self.next_byte().unwrap_or(0) as u32) << 8 | self.next_byte().unwrap_or(0) as u32 + ((self.next_byte().unwrap_or(0) as u32) << 8) | self.next_byte().unwrap_or(0) as u32 } } diff --git a/rama-http-core/tests/h2-support/Cargo.toml b/rama-http-core/tests/h2-support/Cargo.toml index 7991f444f..cac239c1a 100644 --- a/rama-http-core/tests/h2-support/Cargo.toml +++ b/rama-http-core/tests/h2-support/Cargo.toml @@ -3,7 +3,7 @@ name = "h2-support" version = "0.1.0" authors = ["Carl Lerche "] publish = false -edition = "2021" +edition = "2024" license = "MIT OR Apache-2.0" [dependencies] diff --git a/rama-http-core/tests/h2-support/src/frames.rs b/rama-http-core/tests/h2-support/src/frames.rs index 7fc5b923a..d340cc615 100644 --- a/rama-http-core/tests/h2-support/src/frames.rs +++ b/rama-http-core/tests/h2-support/src/frames.rs @@ -2,7 +2,7 @@ use std::convert::TryInto; use std::fmt; use bytes::Bytes; -use rama_http_types::{proto::h1::headers::original::OriginalHttp1Headers, HeaderMap, StatusCode}; +use rama_http_types::{HeaderMap, StatusCode, proto::h1::headers::original::OriginalHttp1Headers}; use rama_http_core::h2::frame::{self, Frame, StreamId}; diff --git a/rama-http-core/tests/h2-support/src/future_ext.rs b/rama-http-core/tests/h2-support/src/future_ext.rs index e299e1bc7..d6fb0c37a 100644 --- a/rama-http-core/tests/h2-support/src/future_ext.rs +++ b/rama-http-core/tests/h2-support/src/future_ext.rs @@ -1,8 +1,8 @@ use futures::{FutureExt, TryFuture}; use std::future::Future; use std::pin::Pin; -use std::sync::atomic::AtomicBool; use std::sync::Arc; +use std::sync::atomic::AtomicBool; use std::task::{Context, Poll, Wake, Waker}; /// Future extension helpers that are useful for tests diff --git a/rama-http-core/tests/h2-support/src/mock.rs b/rama-http-core/tests/h2-support/src/mock.rs index 23fc159f1..4311421c4 100644 --- a/rama-http-core/tests/h2-support/src/mock.rs +++ b/rama-http-core/tests/h2-support/src/mock.rs @@ -1,11 +1,11 @@ use crate::SendFrame; +use rama_http_core::h2::SendError; use rama_http_core::h2::frame::{self, Frame}; use rama_http_core::h2::proto::Error; -use rama_http_core::h2::SendError; use futures::future::poll_fn; -use futures::{ready, Stream, StreamExt}; +use futures::{Stream, StreamExt, ready}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}; diff --git a/rama-http-core/tests/h2-support/src/prelude.rs b/rama-http-core/tests/h2-support/src/prelude.rs index 7235594eb..bb7090994 100644 --- a/rama-http-core/tests/h2-support/src/prelude.rs +++ b/rama-http-core/tests/h2-support/src/prelude.rs @@ -35,7 +35,7 @@ pub use {bytes, futures, http, tokio::io as tokio_io, tracing, tracing_subscribe pub use futures::{Future, Sink, Stream}; // And our Future extensions -pub use super::future_ext::{join, join3, join4, join_all, select, try_join, TestFuture}; +pub use super::future_ext::{TestFuture, join, join_all, join3, join4, select, try_join}; // Our client_ext helpers pub use super::client_ext::SendRequestExt; @@ -43,7 +43,7 @@ pub use super::client_ext::SendRequestExt; // Re-export HTTP types pub use bytes::{Buf, BufMut, Bytes, BytesMut}; pub use rama_http_types::{ - dep::http::uri, HeaderMap, Method, Request, Response, StatusCode, Version, + HeaderMap, Method, Request, Response, StatusCode, Version, dep::http::uri, }; pub use tokio::io::{AsyncRead, AsyncWrite}; @@ -57,8 +57,8 @@ pub static MAGIC_PREFACE: &[u8] = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; // TODO: work on deleting this code use futures::future; -pub use futures::future::poll_fn; use futures::future::Either::*; +pub use futures::future::poll_fn; use std::pin::Pin; pub trait MockH2 { diff --git a/rama-http-core/util/genfixture/Cargo.toml b/rama-http-core/util/genfixture/Cargo.toml index 58aea7d51..673ff69c3 100644 --- a/rama-http-core/util/genfixture/Cargo.toml +++ b/rama-http-core/util/genfixture/Cargo.toml @@ -3,7 +3,7 @@ name = "genfixture" version = "0.1.0" authors = ["Carl Lerche "] publish = false -edition = "2021" +edition = "2024" [dependencies] walkdir = "2.3.2" diff --git a/rama-http-core/util/genhuff/Cargo.toml b/rama-http-core/util/genhuff/Cargo.toml index 804f08218..30b808236 100644 --- a/rama-http-core/util/genhuff/Cargo.toml +++ b/rama-http-core/util/genhuff/Cargo.toml @@ -3,6 +3,6 @@ name = "genhuff" version = "0.1.0" authors = ["Carl Lerche "] publish = false -edition = "2021" +edition = "2024" [dependencies] diff --git a/rama-http-types/README.md b/rama-http-types/README.md index b4dcad5e8..7276bd645 100644 --- a/rama-http-types/README.md +++ b/rama-http-types/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-http-types/src/proto/h1/headers/map.rs b/rama-http-types/src/proto/h1/headers/map.rs index 409641eaf..84e051c6c 100644 --- a/rama-http-types/src/proto/h1/headers/map.rs +++ b/rama-http-types/src/proto/h1/headers/map.rs @@ -1,15 +1,15 @@ use std::collections::{self, HashMap}; use super::{ + Http1HeaderName, name::{IntoHttp1HeaderName, IntoSealed as _, TryIntoHttp1HeaderName}, original::{self, OriginalHttp1Headers}, - Http1HeaderName, }; use crate::{ + HeaderMap, HeaderName, HeaderValue, Request, dep::http::Extensions, header::{self, InvalidHeaderName}, - HeaderMap, HeaderName, HeaderValue, Request, }; #[derive(Debug, Clone, Default)] diff --git a/rama-http-types/src/proto/h1/headers/name.rs b/rama-http-types/src/proto/h1/headers/name.rs index fc5a7e65b..338b7ab15 100644 --- a/rama-http-types/src/proto/h1/headers/name.rs +++ b/rama-http-types/src/proto/h1/headers/name.rs @@ -1,8 +1,8 @@ use bytes::Bytes; -use serde::{de::Error, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::Error}; use std::{fmt, str::FromStr}; -use crate::{header::InvalidHeaderName, HeaderName}; +use crate::{HeaderName, header::InvalidHeaderName}; #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct Http1HeaderName { diff --git a/rama-http-types/src/proto/h2/pseudo_header.rs b/rama-http-types/src/proto/h2/pseudo_header.rs index a26a6689d..619f02ef7 100644 --- a/rama-http-types/src/proto/h2/pseudo_header.rs +++ b/rama-http-types/src/proto/h2/pseudo_header.rs @@ -1,4 +1,4 @@ -use serde::{de::Error, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::Error}; use smallvec::SmallVec; use std::{fmt, str::FromStr}; diff --git a/rama-http-types/src/response/csv.rs b/rama-http-types/src/response/csv.rs index 9d887b957..94e4894ce 100644 --- a/rama-http-types/src/response/csv.rs +++ b/rama-http-types/src/response/csv.rs @@ -1,10 +1,10 @@ use crate::response::{IntoResponse, Response}; -use crate::{dep::http::StatusCode, Body}; +use crate::{Body, dep::http::StatusCode}; use bytes::{BufMut, BytesMut}; use csv; use headers::ContentType; -use http::header::CONTENT_TYPE; use http::HeaderValue; +use http::header::CONTENT_TYPE; use rama_error::OpaqueError; use rama_utils::macros::impl_deref; use serde::Serialize; diff --git a/rama-http-types/src/response/form.rs b/rama-http-types/src/response/form.rs index 90c737195..80f5d9c54 100644 --- a/rama-http-types/src/response/form.rs +++ b/rama-http-types/src/response/form.rs @@ -1,8 +1,8 @@ use std::fmt; +use crate::Body; use crate::dep::http::StatusCode; use crate::response::{IntoResponse, Response}; -use crate::Body; use headers::ContentType; use rama_error::OpaqueError; use rama_utils::macros::impl_deref; diff --git a/rama-http-types/src/response/into_response.rs b/rama-http-types/src/response/into_response.rs index 16b9ca735..5c5cd9e02 100644 --- a/rama-http-types/src/response/into_response.rs +++ b/rama-http-types/src/response/into_response.rs @@ -1,13 +1,13 @@ use super::{IntoResponseParts, Response, ResponseParts}; +use crate::Body; use crate::dep::http_body::{Frame, SizeHint}; use crate::dep::mime; -use crate::Body; use crate::{ + StatusCode, dep::http::Extensions, header::{self, HeaderMap, HeaderName, HeaderValue}, - StatusCode, }; -use bytes::{buf::Chain, Buf, Bytes, BytesMut}; +use bytes::{Buf, Bytes, BytesMut, buf::Chain}; use rama_error::BoxError; use rama_utils::macros::all_the_tuples_no_last_special_case; use std::{ diff --git a/rama-http-types/src/response/into_response_parts.rs b/rama-http-types/src/response/into_response_parts.rs index 675aa69a8..806f66a38 100644 --- a/rama-http-types/src/response/into_response_parts.rs +++ b/rama-http-types/src/response/into_response_parts.rs @@ -1,8 +1,8 @@ use crate::{ + StatusCode, dep::http::Extensions, header::{HeaderMap, HeaderName, HeaderValue}, response::{IntoResponse, Response}, - StatusCode, }; use rama_utils::macros::all_the_tuples_no_last_special_case; use std::{convert::Infallible, fmt}; diff --git a/rama-http-types/src/response/json.rs b/rama-http-types/src/response/json.rs index 21db8a7b7..561c03c66 100644 --- a/rama-http-types/src/response/json.rs +++ b/rama-http-types/src/response/json.rs @@ -1,5 +1,5 @@ use crate::response::{IntoResponse, Response}; -use crate::{dep::http::StatusCode, Body}; +use crate::{Body, dep::http::StatusCode}; use bytes::{BufMut, BytesMut}; use headers::ContentType; use rama_error::OpaqueError; diff --git a/rama-http-types/src/response/redirect.rs b/rama-http-types/src/response/redirect.rs index e709cf36e..493b75a26 100644 --- a/rama-http-types/src/response/redirect.rs +++ b/rama-http-types/src/response/redirect.rs @@ -1,5 +1,5 @@ use super::IntoResponse; -use crate::{header, HeaderValue, Response, StatusCode}; +use crate::{HeaderValue, Response, StatusCode, header}; #[derive(Debug, Clone)] /// Utility struct to easily create a redirect response. diff --git a/rama-http/README.md b/rama-http/README.md index a8fcc6509..c01f26a9a 100644 --- a/rama-http/README.md +++ b/rama-http/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-http/src/headers/forwarded/via.rs b/rama-http/src/headers/forwarded/via.rs index 2b6d477f7..25a251083 100644 --- a/rama-http/src/headers/forwarded/via.rs +++ b/rama-http/src/headers/forwarded/via.rs @@ -107,11 +107,7 @@ impl super::ForwardHeader for Via { }) }) .collect(); - if vec.is_empty() { - None - } else { - Some(Via(vec)) - } + if vec.is_empty() { None } else { Some(Via(vec)) } } } diff --git a/rama-http/src/headers/forwarded/x_forwarded_for.rs b/rama-http/src/headers/forwarded/x_forwarded_for.rs index dcbda9a1c..8efff66be 100644 --- a/rama-http/src/headers/forwarded/x_forwarded_for.rs +++ b/rama-http/src/headers/forwarded/x_forwarded_for.rs @@ -140,9 +140,9 @@ mod tests { test_header!( test1, vec!["2001:db8:85a3:8d3:1319:8a2e:370:7348"], - Some(XForwardedFor(vec!["2001:db8:85a3:8d3:1319:8a2e:370:7348" - .parse() - .unwrap(),])) + Some(XForwardedFor(vec![ + "2001:db8:85a3:8d3:1319:8a2e:370:7348".parse().unwrap(), + ])) ); test_header!( test2, diff --git a/rama-http/src/headers/util/csv.rs b/rama-http/src/headers/util/csv.rs index b91f35674..c9f65c59b 100644 --- a/rama-http/src/headers/util/csv.rs +++ b/rama-http/src/headers/util/csv.rs @@ -4,8 +4,8 @@ use std::fmt; -use crate::headers::Error; use crate::HeaderValue; +use crate::headers::Error; /// Reads a comma-delimited raw header into a Vec. pub(crate) fn from_comma_delimited<'i, I, T, E>(values: &mut I) -> Result diff --git a/rama-http/src/io/request.rs b/rama-http/src/io/request.rs index c57dfb564..d890f0e5a 100644 --- a/rama-http/src/io/request.rs +++ b/rama-http/src/io/request.rs @@ -1,6 +1,6 @@ use crate::{ - dep::{http_body, http_body_util::BodyExt}, Body, Request, + dep::{http_body, http_body_util::BodyExt}, }; use bytes::Bytes; use rama_core::error::BoxError; diff --git a/rama-http/src/io/response.rs b/rama-http/src/io/response.rs index 516a43e9c..260924fdf 100644 --- a/rama-http/src/io/response.rs +++ b/rama-http/src/io/response.rs @@ -1,6 +1,6 @@ use crate::{ - dep::{http_body, http_body_util::BodyExt}, Body, Response, + dep::{http_body, http_body_util::BodyExt}, }; use bytes::Bytes; use rama_core::error::BoxError; diff --git a/rama-http/src/layer/auth/async_require_authorization.rs b/rama-http/src/layer/auth/async_require_authorization.rs index cdb1077ea..1b72abba1 100644 --- a/rama-http/src/layer/auth/async_require_authorization.rs +++ b/rama-http/src/layer/auth/async_require_authorization.rs @@ -217,7 +217,7 @@ pub trait AsyncAuthorizeRequest { ) -> impl std::future::Future< Output = Result<(Context, Request), Response>, > + Send - + '_; + + '_; } impl AsyncAuthorizeRequest for F @@ -247,7 +247,7 @@ mod tests { #[allow(unused_imports)] use super::*; - use crate::{header, Body, StatusCode}; + use crate::{Body, StatusCode, header}; use rama_core::error::BoxError; use rama_core::service::service_fn; diff --git a/rama-http/src/layer/auth/require_authorization.rs b/rama-http/src/layer/auth/require_authorization.rs index e82fd7c8f..4600e709b 100644 --- a/rama-http/src/layer/auth/require_authorization.rs +++ b/rama-http/src/layer/auth/require_authorization.rs @@ -59,8 +59,8 @@ use crate::layer::validate_request::{ ValidateRequest, ValidateRequestHeader, ValidateRequestHeaderLayer, }; use crate::{ - header::{self, HeaderValue}, Request, Response, StatusCode, + header::{self, HeaderValue}, }; use rama_core::Context; @@ -336,7 +336,7 @@ mod tests { use super::*; use crate::layer::validate_request::ValidateRequestHeaderLayer; - use crate::{header, Body}; + use crate::{Body, header}; use rama_core::error::BoxError; use rama_core::service::service_fn; use rama_core::{Context, Layer, Service}; diff --git a/rama-http/src/layer/body_limit.rs b/rama-http/src/layer/body_limit.rs index 0376b2115..574805c50 100644 --- a/rama-http/src/layer/body_limit.rs +++ b/rama-http/src/layer/body_limit.rs @@ -29,10 +29,10 @@ //! # } //! ``` -use crate::dep::http_body_util::Limited; use crate::Request; +use crate::dep::http_body_util::Limited; use bytes::Bytes; -use rama_core::{error::BoxError, Context, Layer, Service}; +use rama_core::{Context, Layer, Service, error::BoxError}; use rama_http_types::Body; use rama_utils::macros::define_inner_service_accessors; use std::fmt; diff --git a/rama-http/src/layer/classify/mod.rs b/rama-http/src/layer/classify/mod.rs index e22cc7814..6025fc247 100644 --- a/rama-http/src/layer/classify/mod.rs +++ b/rama-http/src/layer/classify/mod.rs @@ -26,10 +26,7 @@ pub use self::{ /// [`Error` type]: https://docs.rs/tower/latest/tower/trait.Service.html#associatedtype.Error pub trait MakeClassifier: Send + Sync + 'static { /// The response classifier produced. - type Classifier: ClassifyResponse< - FailureClass = Self::FailureClass, - ClassifyEos = Self::ClassifyEos, - >; + type Classifier: ClassifyResponse; /// The type of failure classifications. /// diff --git a/rama-http/src/layer/classify/status_in_range_is_error.rs b/rama-http/src/layer/classify/status_in_range_is_error.rs index 20fa27af5..b23569da5 100644 --- a/rama-http/src/layer/classify/status_in_range_is_error.rs +++ b/rama-http/src/layer/classify/status_in_range_is_error.rs @@ -100,16 +100,20 @@ mod tests { let classifier = StatusInRangeAsFailures::new(400..=599); assert!(matches!( - dbg!(classifier - .clone() - .classify_response(&response_with_status(200))), + dbg!( + classifier + .clone() + .classify_response(&response_with_status(200)) + ), ClassifiedResponse::Ready(Ok(())), )); assert!(matches!( - dbg!(classifier - .clone() - .classify_response(&response_with_status(400))), + dbg!( + classifier + .clone() + .classify_response(&response_with_status(400)) + ), ClassifiedResponse::Ready(Err(StatusInRangeFailureClass::StatusCode( StatusCode::BAD_REQUEST ))), diff --git a/rama-http/src/layer/collect_body.rs b/rama-http/src/layer/collect_body.rs index 69a057f79..b6555a965 100644 --- a/rama-http/src/layer/collect_body.rs +++ b/rama-http/src/layer/collect_body.rs @@ -1,10 +1,10 @@ //! Collect the http `Body` use crate::dep::http_body_util::BodyExt; -use crate::{dep::http_body::Body, Request, Response}; +use crate::{Request, Response, dep::http_body::Body}; use rama_core::{ - error::{BoxError, ErrorContext, OpaqueError}, Context, Layer, Service, + error::{BoxError, ErrorContext, OpaqueError}, }; use rama_utils::macros::define_inner_service_accessors; use std::fmt; diff --git a/rama-http/src/layer/compression/body.rs b/rama-http/src/layer/compression/body.rs index 44616023e..3e6161842 100644 --- a/rama-http/src/layer/compression/body.rs +++ b/rama-http/src/layer/compression/body.rs @@ -1,10 +1,10 @@ #![allow(unused_imports)] +use crate::HeaderMap; use crate::dep::http_body::{Body, Frame}; use crate::layer::util::compression::{ AsyncReadBody, BodyIntoStream, CompressionLevel, DecorateAsyncRead, WrapBody, }; -use crate::HeaderMap; use rama_core::error::BoxError; use async_compression::tokio::bufread::{BrotliEncoder, GzipEncoder, ZlibEncoder, ZstdEncoder}; diff --git a/rama-http/src/layer/compression/layer.rs b/rama-http/src/layer/compression/layer.rs index 9270af0a0..59ec6fee4 100644 --- a/rama-http/src/layer/compression/layer.rs +++ b/rama-http/src/layer/compression/layer.rs @@ -118,7 +118,7 @@ mod tests { use super::*; use crate::dep::http_body_util::BodyExt; - use crate::{header::ACCEPT_ENCODING, Body, Request, Response}; + use crate::{Body, Request, Response, header::ACCEPT_ENCODING}; use rama_core::service::service_fn; use rama_core::{Context, Service}; use std::convert::Infallible; diff --git a/rama-http/src/layer/compression/predicate.rs b/rama-http/src/layer/compression/predicate.rs index e51986f29..967fc5087 100644 --- a/rama-http/src/layer/compression/predicate.rs +++ b/rama-http/src/layer/compression/predicate.rs @@ -7,7 +7,7 @@ //! [`CompressionLayer::compress_when`]: super::CompressionLayer::compress_when use crate::dep::http_body::Body; -use rama_http_types::{dep::http::Extensions, header, HeaderMap, StatusCode, Version}; +use rama_http_types::{HeaderMap, StatusCode, Version, dep::http::Extensions, header}; use std::{fmt, sync::Arc}; /// Predicate used to determine if a response should be compressed or not. diff --git a/rama-http/src/layer/compression/service.rs b/rama-http/src/layer/compression/service.rs index 3d2d681e4..8d48fa36a 100644 --- a/rama-http/src/layer/compression/service.rs +++ b/rama-http/src/layer/compression/service.rs @@ -1,11 +1,11 @@ -use super::body::BodyInner; -use super::predicate::{DefaultPredicate, Predicate}; use super::CompressionBody; use super::CompressionLevel; +use super::body::BodyInner; +use super::predicate::{DefaultPredicate, Predicate}; use crate::dep::http_body::Body; use crate::layer::util::compression::WrapBody; use crate::layer::util::{compression::AcceptEncoding, content_encoding::Encoding}; -use crate::{header, Request, Response}; +use crate::{Request, Response, header}; use rama_core::{Context, Service}; use rama_utils::macros::define_inner_service_accessors; @@ -216,7 +216,7 @@ where return Ok(Response::from_parts( parts, CompressionBody::new(BodyInner::identity(body)), - )) + )); } (_, Encoding::Gzip) => { diff --git a/rama-http/src/layer/cors/allow_headers.rs b/rama-http/src/layer/cors/allow_headers.rs index 3e9d69597..ee5ee1b12 100644 --- a/rama-http/src/layer/cors/allow_headers.rs +++ b/rama-http/src/layer/cors/allow_headers.rs @@ -5,7 +5,7 @@ use crate::dep::http::{ request::Parts as RequestParts, }; -use super::{separated_by_commas, Any, WILDCARD}; +use super::{Any, WILDCARD, separated_by_commas}; /// Holds configuration for how to set the [`Access-Control-Allow-Headers`][mdn] header. /// diff --git a/rama-http/src/layer/cors/allow_methods.rs b/rama-http/src/layer/cors/allow_methods.rs index b9e255109..ba1cb923d 100644 --- a/rama-http/src/layer/cors/allow_methods.rs +++ b/rama-http/src/layer/cors/allow_methods.rs @@ -1,12 +1,12 @@ use std::{array, fmt}; use crate::dep::http::{ + Method, header::{self, HeaderName, HeaderValue}, request::Parts as RequestParts, - Method, }; -use super::{separated_by_commas, Any, WILDCARD}; +use super::{Any, WILDCARD, separated_by_commas}; /// Holds configuration for how to set the [`Access-Control-Allow-Methods`][mdn] header. /// diff --git a/rama-http/src/layer/cors/allow_private_network.rs b/rama-http/src/layer/cors/allow_private_network.rs index e6dab26d7..f43b6635f 100644 --- a/rama-http/src/layer/cors/allow_private_network.rs +++ b/rama-http/src/layer/cors/allow_private_network.rs @@ -113,11 +113,11 @@ impl Default for AllowPrivateNetworkInner { mod tests { use super::AllowPrivateNetwork; + use crate::Body; use crate::dep::http::{ - header::ORIGIN, request::Parts, HeaderName, HeaderValue, Request, Response, + HeaderName, HeaderValue, Request, Response, header::ORIGIN, request::Parts, }; use crate::layer::cors::CorsLayer; - use crate::Body; use rama_core::error::BoxError; use rama_core::service::service_fn; use rama_core::{Context, Layer, Service}; diff --git a/rama-http/src/layer/cors/expose_headers.rs b/rama-http/src/layer/cors/expose_headers.rs index 7b26c63b3..130882478 100644 --- a/rama-http/src/layer/cors/expose_headers.rs +++ b/rama-http/src/layer/cors/expose_headers.rs @@ -5,7 +5,7 @@ use crate::dep::http::{ request::Parts as RequestParts, }; -use super::{separated_by_commas, Any, WILDCARD}; +use super::{Any, WILDCARD, separated_by_commas}; /// Holds configuration for how to set the [`Access-Control-Expose-Headers`][mdn] header. /// diff --git a/rama-http/src/layer/cors/mod.rs b/rama-http/src/layer/cors/mod.rs index 4653a733b..a4a98a0f5 100644 --- a/rama-http/src/layer/cors/mod.rs +++ b/rama-http/src/layer/cors/mod.rs @@ -47,8 +47,8 @@ #![allow(clippy::enum_variant_names)] use crate::dep::http::{ - header::{self, HeaderName}, HeaderMap, HeaderValue, Method, Request, Response, + header::{self, HeaderName}, }; use bytes::{BufMut, BytesMut}; use rama_core::{Context, Layer, Service}; diff --git a/rama-http/src/layer/cors/tests.rs b/rama-http/src/layer/cors/tests.rs index f8c1a9f75..312fd2563 100644 --- a/rama-http/src/layer/cors/tests.rs +++ b/rama-http/src/layer/cors/tests.rs @@ -1,5 +1,5 @@ use crate::layer::cors::{AllowOrigin, CorsLayer}; -use crate::{header, Body, HeaderValue, Request, Response}; +use crate::{Body, HeaderValue, Request, Response, header}; use rama_core::service::service_fn; use rama_core::{Context, Layer, Service}; use std::convert::Infallible; diff --git a/rama-http/src/layer/cors/vary.rs b/rama-http/src/layer/cors/vary.rs index 2fadfe60e..85b25179b 100644 --- a/rama-http/src/layer/cors/vary.rs +++ b/rama-http/src/layer/cors/vary.rs @@ -1,8 +1,8 @@ use std::array; use crate::{ - header::{self, HeaderName}, HeaderValue, + header::{self, HeaderName}, }; use super::preflight_request_headers; diff --git a/rama-http/src/layer/decompression/body.rs b/rama-http/src/layer/decompression/body.rs index b923c8eda..d7f7d2543 100644 --- a/rama-http/src/layer/decompression/body.rs +++ b/rama-http/src/layer/decompression/body.rs @@ -1,10 +1,10 @@ #![allow(unused_imports)] +use crate::HeaderMap; use crate::dep::http_body::{Body, Frame, SizeHint}; use crate::layer::util::compression::{ AsyncReadBody, BodyIntoStream, CompressionLevel, DecorateAsyncRead, WrapBody, }; -use crate::HeaderMap; use rama_core::error::BoxError; use async_compression::tokio::bufread::BrotliDecoder; diff --git a/rama-http/src/layer/decompression/request/mod.rs b/rama-http/src/layer/decompression/request/mod.rs index cd90a5022..a140e5f69 100644 --- a/rama-http/src/layer/decompression/request/mod.rs +++ b/rama-http/src/layer/decompression/request/mod.rs @@ -7,11 +7,11 @@ mod tests { use crate::dep::http_body_util::BodyExt; use crate::layer::decompression::DecompressionBody; - use crate::{header, Body, Request, Response, StatusCode}; + use crate::{Body, Request, Response, StatusCode, header}; use rama_core::service::service_fn; use rama_core::{Context, Service}; - use flate2::{write::GzEncoder, Compression}; + use flate2::{Compression, write::GzEncoder}; use std::{convert::Infallible, io::Write}; #[tokio::test] diff --git a/rama-http/src/layer/decompression/request/service.rs b/rama-http/src/layer/decompression/request/service.rs index d6f47d03a..be2aa2fef 100644 --- a/rama-http/src/layer/decompression/request/service.rs +++ b/rama-http/src/layer/decompression/request/service.rs @@ -1,14 +1,14 @@ use std::fmt; use crate::dep::http_body::Body; -use crate::dep::http_body_util::{combinators::UnsyncBoxBody, BodyExt, Empty}; +use crate::dep::http_body_util::{BodyExt, Empty, combinators::UnsyncBoxBody}; use crate::layer::{ - decompression::body::BodyInner, decompression::DecompressionBody, + decompression::body::BodyInner, util::compression::{AcceptEncoding, CompressionLevel, WrapBody}, util::content_encoding::SupportedEncodings, }; -use crate::{header, HeaderValue, Request, Response, StatusCode}; +use crate::{HeaderValue, Request, Response, StatusCode, header}; use bytes::Buf; use rama_core::error::BoxError; use rama_core::{Context, Service}; @@ -54,11 +54,11 @@ impl Clone for RequestDecompression { impl Service> for RequestDecompression where S: Service< - State, - Request>, - Response = Response, - Error: Into, - >, + State, + Request>, + Response = Response, + Error: Into, + >, State: Clone + Send + Sync + 'static, ReqBody: Body + Send + 'static, ResBody: Body> + Send + 'static, diff --git a/rama-http/src/layer/decompression/service.rs b/rama-http/src/layer/decompression/service.rs index 25e06b287..cd4031590 100644 --- a/rama-http/src/layer/decompression/service.rs +++ b/rama-http/src/layer/decompression/service.rs @@ -1,14 +1,14 @@ use std::fmt; -use super::{body::BodyInner, DecompressionBody}; +use super::{DecompressionBody, body::BodyInner}; use crate::dep::http_body::Body; use crate::layer::util::{ compression::{AcceptEncoding, CompressionLevel, WrapBody}, content_encoding::SupportedEncodings, }; use crate::{ - header::{self, ACCEPT_ENCODING}, Request, Response, + header::{self, ACCEPT_ENCODING}, }; use rama_core::{Context, Service}; use rama_utils::macros::define_inner_service_accessors; @@ -150,7 +150,7 @@ where return Ok(Response::from_parts( parts, DecompressionBody::new(BodyInner::identity(body)), - )) + )); } }; diff --git a/rama-http/src/layer/dns/dns_resolve/layer.rs b/rama-http/src/layer/dns/dns_resolve/layer.rs index 6669acef8..1d716655d 100644 --- a/rama-http/src/layer/dns/dns_resolve/layer.rs +++ b/rama-http/src/layer/dns/dns_resolve/layer.rs @@ -28,8 +28,8 @@ impl Layer for DnsResolveModeLayer { #[cfg(test)] mod tests { use super::*; - use crate::{layer::dns::DnsResolveMode, Request}; - use rama_core::{service::service_fn, Context, Service}; + use crate::{Request, layer::dns::DnsResolveMode}; + use rama_core::{Context, Service, service::service_fn}; use std::convert::Infallible; #[tokio::test] diff --git a/rama-http/src/layer/dns/dns_resolve/service.rs b/rama-http/src/layer/dns/dns_resolve/service.rs index 2d26c7918..bc643ff5e 100644 --- a/rama-http/src/layer/dns/dns_resolve/service.rs +++ b/rama-http/src/layer/dns/dns_resolve/service.rs @@ -1,6 +1,6 @@ use super::DnsResolveMode; use crate::{HeaderName, Request}; -use rama_core::{error::OpaqueError, Context, Service}; +use rama_core::{Context, Service, error::OpaqueError}; use rama_utils::macros::define_inner_service_accessors; use std::fmt; @@ -49,10 +49,10 @@ where State: Clone + Send + Sync + 'static, Body: Send + Sync + 'static, S: Service< - State, - Request, - Error: Into + Send + Sync + 'static, - >, + State, + Request, + Error: Into + Send + Sync + 'static, + >, { type Response = S::Response; type Error = OpaqueError; diff --git a/rama-http/src/layer/dns/dns_resolve/username_parser.rs b/rama-http/src/layer/dns/dns_resolve/username_parser.rs index fb5b6dc1f..567643689 100644 --- a/rama-http/src/layer/dns/dns_resolve/username_parser.rs +++ b/rama-http/src/layer/dns/dns_resolve/username_parser.rs @@ -2,7 +2,7 @@ use super::DnsResolveMode; use rama_core::username::{UsernameLabelParser, UsernameLabelState}; use rama_core::{ context::Extensions, - error::{error, ErrorContext, OpaqueError}, + error::{ErrorContext, OpaqueError, error}, }; use rama_utils::macros::str::eq_ignore_ascii_case; diff --git a/rama-http/src/layer/follow_redirect/mod.rs b/rama-http/src/layer/follow_redirect/mod.rs index 8b85ecdf2..8d9a7971f 100644 --- a/rama-http/src/layer/follow_redirect/mod.rs +++ b/rama-http/src/layer/follow_redirect/mod.rs @@ -101,7 +101,7 @@ pub mod policy; -use crate::{dep::http_body::Body, header::LOCATION, Method, Request, Response, StatusCode, Uri}; +use crate::{Method, Request, Response, StatusCode, Uri, dep::http_body::Body, header::LOCATION}; use iri_string::types::{UriAbsoluteString, UriReferenceStr}; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; @@ -287,7 +287,7 @@ where location: &location, previous: &uri, }; - match policy.redirect(&ctx, &attempt).map_err(Into::into)? { + match policy.redirect(&ctx, &attempt)? { Action::Follow => { uri = location; body.try_clone_from(&ctx, &mut policy, &taken_body); @@ -375,9 +375,9 @@ fn resolve_uri(relative: &str, base: &Uri) -> Option { #[cfg(test)] mod tests { use super::{policy::*, *}; - use crate::{header::LOCATION, Body}; - use rama_core::service::service_fn; + use crate::{Body, header::LOCATION}; use rama_core::Layer; + use rama_core::service::service_fn; use std::convert::Infallible; #[tokio::test] diff --git a/rama-http/src/layer/follow_redirect/policy/and.rs b/rama-http/src/layer/follow_redirect/policy/and.rs index fc5091f37..25ea0bc98 100644 --- a/rama-http/src/layer/follow_redirect/policy/and.rs +++ b/rama-http/src/layer/follow_redirect/policy/and.rs @@ -114,36 +114,44 @@ mod tests { let a = Taint::new(Action::Follow); let b = Taint::new(Action::Follow); let mut policy = And::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_follow() + ); assert!(policy.a.used); assert!(policy.b.used); let a = Taint::new(Action::Stop); let b = Taint::new(Action::Follow); let mut policy = And::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_stop()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_stop() + ); assert!(policy.a.used); assert!(!policy.b.used); // short-circuiting let a = Taint::new(Action::Follow); let b = Taint::new(Action::Stop); let mut policy = And::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_stop()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_stop() + ); assert!(policy.a.used); assert!(policy.b.used); let a = Taint::new(Action::Stop); let b = Taint::new(Action::Stop); let mut policy = And::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_stop()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_stop() + ); assert!(policy.a.used); assert!(!policy.b.used); } diff --git a/rama-http/src/layer/follow_redirect/policy/filter_credentials.rs b/rama-http/src/layer/follow_redirect/policy/filter_credentials.rs index e60f1524f..dabf820df 100644 --- a/rama-http/src/layer/follow_redirect/policy/filter_credentials.rs +++ b/rama-http/src/layer/follow_redirect/policy/filter_credentials.rs @@ -1,7 +1,7 @@ -use super::{eq_origin, Action, Attempt, Policy}; +use super::{Action, Attempt, Policy, eq_origin}; use crate::{ - header::{self, HeaderName}, Request, + header::{self, HeaderName}, }; use rama_core::Context; @@ -162,9 +162,11 @@ mod tests { location: &same_origin, previous: request.uri(), }; - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_follow() + ); let mut request = Request::builder() .uri(same_origin) @@ -179,9 +181,11 @@ mod tests { location: &cross_origin, previous: request.uri(), }; - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_follow() + ); let mut request = Request::builder() .uri(cross_origin) diff --git a/rama-http/src/layer/follow_redirect/policy/limited.rs b/rama-http/src/layer/follow_redirect/policy/limited.rs index 3b21ae841..36ed5626a 100644 --- a/rama-http/src/layer/follow_redirect/policy/limited.rs +++ b/rama-http/src/layer/follow_redirect/policy/limited.rs @@ -87,9 +87,11 @@ mod tests { location: &uri, previous: &uri, }; - assert!(Policy::<(), (), ()>::redirect(policy, ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(policy, ctx, &attempt) + .unwrap() + .is_follow() + ); } let mut request = Request::builder().uri(uri.clone()).body(()).unwrap(); @@ -100,8 +102,10 @@ mod tests { location: &uri, previous: &uri, }; - assert!(Policy::<(), (), ()>::redirect(policy, ctx, &attempt) - .unwrap() - .is_stop()); + assert!( + Policy::<(), (), ()>::redirect(policy, ctx, &attempt) + .unwrap() + .is_stop() + ); } } diff --git a/rama-http/src/layer/follow_redirect/policy/mod.rs b/rama-http/src/layer/follow_redirect/policy/mod.rs index 917c56b7a..f312d4b6a 100644 --- a/rama-http/src/layer/follow_redirect/policy/mod.rs +++ b/rama-http/src/layer/follow_redirect/policy/mod.rs @@ -10,11 +10,11 @@ mod same_origin; pub use self::{ and::And, - clone_body_fn::{clone_body_fn, CloneBodyFn}, + clone_body_fn::{CloneBodyFn, clone_body_fn}, filter_credentials::FilterCredentials, limited::Limited, or::Or, - redirect_fn::{redirect_fn, RedirectFn}, + redirect_fn::{RedirectFn, redirect_fn}, same_origin::SameOrigin, }; use crate::{Request, Scheme, StatusCode, Uri}; diff --git a/rama-http/src/layer/follow_redirect/policy/or.rs b/rama-http/src/layer/follow_redirect/policy/or.rs index 4be6860b7..2ed0683db 100644 --- a/rama-http/src/layer/follow_redirect/policy/or.rs +++ b/rama-http/src/layer/follow_redirect/policy/or.rs @@ -114,36 +114,44 @@ mod tests { let a = Taint::new(Action::Follow); let b = Taint::new(Action::Follow); let mut policy = Or::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_follow() + ); assert!(policy.a.used); assert!(!policy.b.used); // short-circuiting let a = Taint::new(Action::Stop); let b = Taint::new(Action::Follow); let mut policy = Or::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_follow() + ); assert!(policy.a.used); assert!(policy.b.used); let a = Taint::new(Action::Follow); let b = Taint::new(Action::Stop); let mut policy = Or::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_follow() + ); assert!(policy.a.used); assert!(!policy.b.used); let a = Taint::new(Action::Stop); let b = Taint::new(Action::Stop); let mut policy = Or::new::<(), (), ()>(a, b); - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_stop()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_stop() + ); assert!(policy.a.used); assert!(policy.b.used); } diff --git a/rama-http/src/layer/follow_redirect/policy/same_origin.rs b/rama-http/src/layer/follow_redirect/policy/same_origin.rs index 6d1aa3b78..4cb389869 100644 --- a/rama-http/src/layer/follow_redirect/policy/same_origin.rs +++ b/rama-http/src/layer/follow_redirect/policy/same_origin.rs @@ -1,4 +1,4 @@ -use super::{eq_origin, Action, Attempt, Policy}; +use super::{Action, Attempt, Policy, eq_origin}; use rama_core::Context; use std::fmt; @@ -54,9 +54,11 @@ mod tests { location: &same_origin, previous: request.uri(), }; - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_follow()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_follow() + ); let mut request = Request::builder().uri(same_origin).body(()).unwrap(); Policy::<(), (), ()>::on_request(&mut policy, &mut ctx, &mut request); @@ -66,8 +68,10 @@ mod tests { location: &cross_origin, previous: request.uri(), }; - assert!(Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) - .unwrap() - .is_stop()); + assert!( + Policy::<(), (), ()>::redirect(&mut policy, &ctx, &attempt) + .unwrap() + .is_stop() + ); } } diff --git a/rama-http/src/layer/forwarded/get_forwarded.rs b/rama-http/src/layer/forwarded/get_forwarded.rs index ac2bce23b..690b75094 100644 --- a/rama-http/src/layer/forwarded/get_forwarded.rs +++ b/rama-http/src/layer/forwarded/get_forwarded.rs @@ -1,7 +1,7 @@ +use crate::Request; use crate::headers::{ ForwardHeader, HeaderMapExt, Via, XForwardedFor, XForwardedHost, XForwardedProto, }; -use crate::Request; use rama_core::{Context, Layer, Service}; use rama_net::forwarded::Forwarded; use rama_net::forwarded::ForwardedElement; @@ -349,10 +349,10 @@ all_the_tuples_no_last_special_case!(get_forwarded_service_for_tuple); mod tests { use super::*; use crate::{ - headers::{ClientIp, TrueClientIp, XClientIp, XRealIp}, IntoResponse, Response, StatusCode, + headers::{ClientIp, TrueClientIp, XClientIp, XRealIp}, }; - use rama_core::{error::OpaqueError, service::service_fn, Layer}; + use rama_core::{Layer, error::OpaqueError, service::service_fn}; use rama_net::forwarded::{ForwardedProtocol, ForwardedVersion}; use std::{convert::Infallible, net::IpAddr}; diff --git a/rama-http/src/layer/forwarded/set_forwarded.rs b/rama-http/src/layer/forwarded/set_forwarded.rs index bfd5c3182..e5f23cc41 100644 --- a/rama-http/src/layer/forwarded/set_forwarded.rs +++ b/rama-http/src/layer/forwarded/set_forwarded.rs @@ -1,7 +1,7 @@ +use crate::Request; use crate::headers::{ ForwardHeader, HeaderMapExt, Via, XForwardedFor, XForwardedHost, XForwardedProto, }; -use crate::Request; use rama_core::error::BoxError; use rama_core::{Context, Layer, Service}; use rama_net::address::Domain; @@ -408,10 +408,10 @@ all_the_tuples_no_last_special_case!(set_forwarded_service_for_tuple); mod tests { use super::*; use crate::{ - headers::{TrueClientIp, XClientIp, XRealIp}, IntoResponse, Response, StatusCode, + headers::{TrueClientIp, XClientIp, XRealIp}, }; - use rama_core::{error::OpaqueError, service::service_fn, Layer}; + use rama_core::{Layer, error::OpaqueError, service::service_fn}; use std::{convert::Infallible, net::IpAddr}; fn assert_is_service>>(_: T) {} diff --git a/rama-http/src/layer/header_config.rs b/rama-http/src/layer/header_config.rs index 53dd7a3f0..6a0a616a6 100644 --- a/rama-http/src/layer/header_config.rs +++ b/rama-http/src/layer/header_config.rs @@ -43,12 +43,12 @@ //! } //! ``` -use crate::{header::AsHeaderName, HeaderName}; +use crate::{HeaderName, header::AsHeaderName}; use crate::{ - utils::{HeaderValueErr, HeaderValueGetter}, Request, + utils::{HeaderValueErr, HeaderValueGetter}, }; -use rama_core::{error::BoxError, Context, Layer, Service}; +use rama_core::{Context, Layer, Service, error::BoxError}; use rama_utils::macros::define_inner_service_accessors; use serde::de::DeserializeOwned; use std::{fmt, marker::PhantomData}; diff --git a/rama-http/src/layer/header_option_value.rs b/rama-http/src/layer/header_option_value.rs index e40175f90..5a57ac5f4 100644 --- a/rama-http/src/layer/header_option_value.rs +++ b/rama-http/src/layer/header_option_value.rs @@ -3,10 +3,10 @@ //! the header with the given [`HeaderName`] is present //! and has a bool-like value. -use crate::{utils::HeaderValueGetter, HeaderName, Request}; +use crate::{HeaderName, Request, utils::HeaderValueGetter}; use rama_core::{ - error::{BoxError, ErrorExt, OpaqueError}, Context, Layer, Service, + error::{BoxError, ErrorExt, OpaqueError}, }; use rama_utils::macros::define_inner_service_accessors; use std::{fmt, marker::PhantomData}; diff --git a/rama-http/src/layer/normalize_path.rs b/rama-http/src/layer/normalize_path.rs index 01f2b5ed1..23dde0c8b 100644 --- a/rama-http/src/layer/normalize_path.rs +++ b/rama-http/src/layer/normalize_path.rs @@ -170,8 +170,8 @@ fn normalize_trailing_slash(uri: &mut Uri) { #[cfg(test)] mod tests { use super::*; - use rama_core::service::service_fn; use rama_core::Layer; + use rama_core::service::service_fn; use std::convert::Infallible; #[tokio::test] diff --git a/rama-http/src/layer/opentelemetry.rs b/rama-http/src/layer/opentelemetry.rs index c010293c9..289ff56f0 100644 --- a/rama-http/src/layer/opentelemetry.rs +++ b/rama-http/src/layer/opentelemetry.rs @@ -3,17 +3,16 @@ //! [`Layer`]: rama_core::Layer use crate::{ - headers::{HeaderMapExt, UserAgent}, IntoResponse, Request, Response, + headers::{HeaderMapExt, UserAgent}, }; use rama_core::telemetry::opentelemetry::{ - global, + AttributesFactory, InstrumentationScope, KeyValue, MeterOptions, ServiceInfo, global, metrics::{Counter, Histogram, Meter}, semantic_conventions::{ self, resource::{SERVICE_NAME, SERVICE_VERSION}, }, - AttributesFactory, InstrumentationScope, KeyValue, MeterOptions, ServiceInfo, }; use rama_core::{Context, Layer, Service}; use rama_net::http::RequestContext; @@ -350,15 +349,21 @@ mod tests { .unwrap(); let attributes = svc.compute_attributes(&mut ctx, &req); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST)); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST) + ); } #[test] @@ -379,15 +384,21 @@ mod tests { .unwrap(); let attributes = svc.compute_attributes(&mut ctx, &req); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST)); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST) + ); } #[test] @@ -409,18 +420,26 @@ mod tests { .unwrap(); let attributes = svc.compute_attributes(&mut ctx, &req); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn")); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn") + ); } #[test] @@ -446,17 +465,25 @@ mod tests { .unwrap(); let attributes = svc.compute_attributes(&mut ctx, &req); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn")); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == HTTP_REQUEST_HOST) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn") + ); } } diff --git a/rama-http/src/layer/propagate_headers.rs b/rama-http/src/layer/propagate_headers.rs index f804308df..0c8478a7e 100644 --- a/rama-http/src/layer/propagate_headers.rs +++ b/rama-http/src/layer/propagate_headers.rs @@ -35,7 +35,7 @@ //! # } //! ``` -use crate::{header::HeaderName, Request, Response}; +use crate::{Request, Response, header::HeaderName}; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; diff --git a/rama-http/src/layer/proxy_auth.rs b/rama-http/src/layer/proxy_auth.rs index bb45ab874..6341e4ea4 100644 --- a/rama-http/src/layer/proxy_auth.rs +++ b/rama-http/src/layer/proxy_auth.rs @@ -3,10 +3,10 @@ //! If the request is not authorized a `407 Proxy Authentication Required` response will be sent. use crate::header::PROXY_AUTHENTICATE; -use crate::headers::{authorization::Credentials, HeaderMapExt, ProxyAuthorization}; +use crate::headers::{HeaderMapExt, ProxyAuthorization, authorization::Credentials}; use crate::{Request, Response, StatusCode}; use rama_core::{Context, Layer, Service}; -use rama_net::user::{auth::Authority, UserId}; +use rama_net::user::{UserId, auth::Authority}; use rama_utils::macros::define_inner_service_accessors; use std::fmt; use std::marker::PhantomData; diff --git a/rama-http/src/layer/remove_header/mod.rs b/rama-http/src/layer/remove_header/mod.rs index 2020c0773..bf050e492 100644 --- a/rama-http/src/layer/remove_header/mod.rs +++ b/rama-http/src/layer/remove_header/mod.rs @@ -2,7 +2,7 @@ //! //! See [request] and [response] for more details. -use crate::{header, HeaderMap, HeaderName}; +use crate::{HeaderMap, HeaderName, header}; pub mod request; pub mod response; diff --git a/rama-http/src/layer/remove_header/request.rs b/rama-http/src/layer/remove_header/request.rs index 1609640a1..0c31b6d8d 100644 --- a/rama-http/src/layer/remove_header/request.rs +++ b/rama-http/src/layer/remove_header/request.rs @@ -173,7 +173,7 @@ where mod test { use super::*; use crate::{Body, Response}; - use rama_core::{service::service_fn, Layer, Service}; + use rama_core::{Layer, Service, service::service_fn}; use std::convert::Infallible; #[tokio::test] diff --git a/rama-http/src/layer/remove_header/response.rs b/rama-http/src/layer/remove_header/response.rs index d36be8291..47c456697 100644 --- a/rama-http/src/layer/remove_header/response.rs +++ b/rama-http/src/layer/remove_header/response.rs @@ -174,7 +174,7 @@ where mod test { use super::*; use crate::{Body, Response}; - use rama_core::{service::service_fn, Layer, Service}; + use rama_core::{Layer, Service, service::service_fn}; use std::convert::Infallible; #[tokio::test] diff --git a/rama-http/src/layer/request_id.rs b/rama-http/src/layer/request_id.rs index bb62d51fc..bda5c6250 100644 --- a/rama-http/src/layer/request_id.rs +++ b/rama-http/src/layer/request_id.rs @@ -60,8 +60,8 @@ use std::fmt; use crate::{ - header::{HeaderName, HeaderValue}, Request, Response, + header::{HeaderName, HeaderValue}, }; use nanoid::nanoid; use rama_core::{Context, Layer, Service}; @@ -401,13 +401,13 @@ impl MakeRequestId for MakeRequestNanoid { mod tests { use crate::layer::set_header; use crate::{Body, Response}; - use rama_core::service::service_fn; use rama_core::Layer; + use rama_core::service::service_fn; use std::{ convert::Infallible, sync::{ - atomic::{AtomicU64, Ordering}, Arc, + atomic::{AtomicU64, Ordering}, }, }; diff --git a/rama-http/src/layer/required_header/request.rs b/rama-http/src/layer/required_header/request.rs index 058158c82..748b0de3e 100644 --- a/rama-http/src/layer/required_header/request.rs +++ b/rama-http/src/layer/required_header/request.rs @@ -4,13 +4,13 @@ //! as well as always a User-Agent for all versions. use crate::{ + HeaderValue, Request, Response, header::{self, HOST, RAMA_ID_HEADER_VALUE, USER_AGENT}, headers::HeaderMapExt, - HeaderValue, Request, Response, }; use rama_core::{ - error::{BoxError, ErrorContext}, Context, Layer, Service, + error::{BoxError, ErrorContext}, }; use rama_net::http::RequestContext; use rama_utils::macros::define_inner_service_accessors; diff --git a/rama-http/src/layer/required_header/response.rs b/rama-http/src/layer/required_header/response.rs index 04b1ddce0..90a124cef 100644 --- a/rama-http/src/layer/required_header/response.rs +++ b/rama-http/src/layer/required_header/response.rs @@ -3,9 +3,9 @@ //! For now this only sets `Server` and `Date` heades. use crate::{ + HeaderValue, Request, Response, header::{self, DATE, RAMA_ID_HEADER_VALUE, SERVER}, headers::{Date, HeaderMapExt}, - HeaderValue, Request, Response, }; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; @@ -206,7 +206,7 @@ where mod tests { use super::*; use crate::Body; - use rama_core::{service::service_fn, Layer}; + use rama_core::{Layer, service::service_fn}; use std::convert::Infallible; #[tokio::test] diff --git a/rama-http/src/layer/retry/mod.rs b/rama-http/src/layer/retry/mod.rs index 7bd58c20d..3b3f1ab1e 100644 --- a/rama-http/src/layer/retry/mod.rs +++ b/rama-http/src/layer/retry/mod.rs @@ -1,8 +1,8 @@ //! Middleware for retrying "failed" requests. +use crate::Request; use crate::dep::http_body::Body as HttpBody; use crate::dep::http_body_util::BodyExt; -use crate::Request; use rama_core::error::BoxError; use rama_core::{Context, Service}; use rama_utils::macros::define_inner_service_accessors; @@ -146,7 +146,7 @@ where return result.map_err(|e| RetryError { kind: RetryErrorKind::Service, inner: Some(e.into()), - }) + }); } PolicyResult::Retry { ctx, req } => (ctx, req), }; @@ -160,7 +160,7 @@ where return resp.map_err(|e| RetryError { kind: RetryErrorKind::Service, inner: Some(e.into()), - }) + }); } } } @@ -171,12 +171,12 @@ where mod test { use super::*; use crate::{ - layer::retry::managed::DoNotRetry, BodyExtractExt, IntoResponse, Response, StatusCode, + BodyExtractExt, IntoResponse, Response, StatusCode, layer::retry::managed::DoNotRetry, }; - use rama_core::{service::service_fn, Context, Layer}; + use rama_core::{Context, Layer, service::service_fn}; use rama_utils::{backoff::ExponentialBackoff, rng::HasherRng}; use std::{ - sync::{atomic::AtomicUsize, Arc}, + sync::{Arc, atomic::AtomicUsize}, time::Duration, }; diff --git a/rama-http/src/layer/retry/tests.rs b/rama-http/src/layer/retry/tests.rs index f1cddb63d..cda9eec8f 100644 --- a/rama-http/src/layer/retry/tests.rs +++ b/rama-http/src/layer/retry/tests.rs @@ -1,12 +1,12 @@ use super::*; -use crate::{response::IntoResponse, BodyExtractExt}; +use crate::{BodyExtractExt, response::IntoResponse}; use crate::{Request, Response}; use parking_lot::Mutex; -use rama_core::error::{error, OpaqueError}; +use rama_core::error::{OpaqueError, error}; use rama_core::{Layer, Service}; use std::sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, Arc, + atomic::{AtomicBool, AtomicUsize, Ordering}, }; #[tokio::test] diff --git a/rama-http/src/layer/sensitive_headers.rs b/rama-http/src/layer/sensitive_headers.rs index cb14dab6e..8aa9e1247 100644 --- a/rama-http/src/layer/sensitive_headers.rs +++ b/rama-http/src/layer/sensitive_headers.rs @@ -38,7 +38,7 @@ //! # } //! ``` -use crate::{header, HeaderName, Request, Response}; +use crate::{HeaderName, Request, Response, header}; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; use std::sync::Arc; @@ -286,7 +286,7 @@ where #[cfg(test)] mod tests { use super::*; - use crate::{header, HeaderValue, Request, Response}; + use crate::{HeaderValue, Request, Response, header}; use rama_core::service::service_fn; #[tokio::test] @@ -326,11 +326,13 @@ mod tests { let resp = service.serve(Context::default(), req).await.unwrap(); - assert!(!resp - .headers() - .get(header::CONTENT_TYPE) - .unwrap() - .is_sensitive()); + assert!( + !resp + .headers() + .get(header::CONTENT_TYPE) + .unwrap() + .is_sensitive() + ); let mut iter = resp.headers().get_all(header::SET_COOKIE).iter().peekable(); diff --git a/rama-http/src/layer/set_header/request/header.rs b/rama-http/src/layer/set_header/request/header.rs index 4bac7b4b8..f4e992c54 100644 --- a/rama-http/src/layer/set_header/request/header.rs +++ b/rama-http/src/layer/set_header/request/header.rs @@ -1,7 +1,7 @@ use crate::{HeaderName, HeaderValue, Request}; use rama_core::Context; use std::{ - future::{ready, Future}, + future::{Future, ready}, marker::PhantomData, }; diff --git a/rama-http/src/layer/set_header/request/mod.rs b/rama-http/src/layer/set_header/request/mod.rs index c6b3d3411..8bfe7b2ce 100644 --- a/rama-http/src/layer/set_header/request/mod.rs +++ b/rama-http/src/layer/set_header/request/mod.rs @@ -81,9 +81,9 @@ //! ``` use crate::{ + HeaderValue, Request, Response, header::HeaderName, headers::{Header, HeaderExt}, - HeaderValue, Request, Response, }; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; diff --git a/rama-http/src/layer/set_header/response/header.rs b/rama-http/src/layer/set_header/response/header.rs index 20b98e125..0bbb19cbf 100644 --- a/rama-http/src/layer/set_header/response/header.rs +++ b/rama-http/src/layer/set_header/response/header.rs @@ -1,7 +1,7 @@ use crate::{HeaderName, HeaderValue, Request, Response}; use rama_core::Context; use std::{ - future::{ready, Future}, + future::{Future, ready}, marker::PhantomData, }; diff --git a/rama-http/src/layer/set_header/response/mod.rs b/rama-http/src/layer/set_header/response/mod.rs index 32701ed0a..0928bb395 100644 --- a/rama-http/src/layer/set_header/response/mod.rs +++ b/rama-http/src/layer/set_header/response/mod.rs @@ -150,9 +150,9 @@ //! ``` use crate::{ + HeaderValue, Request, Response, header::HeaderName, headers::{Header, HeaderExt}, - HeaderValue, Request, Response, }; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; @@ -428,7 +428,7 @@ where mod tests { use super::*; - use crate::{header, Body, HeaderValue, Request, Response}; + use crate::{Body, HeaderValue, Request, Response, header}; use rama_core::service::service_fn; use std::convert::Infallible; diff --git a/rama-http/src/layer/trace/layer.rs b/rama-http/src/layer/trace/layer.rs index 36f826725..0e5a0ef53 100644 --- a/rama-http/src/layer/trace/layer.rs +++ b/rama-http/src/layer/trace/layer.rs @@ -34,14 +34,14 @@ pub struct TraceLayer< } impl< - M: fmt::Debug, - MakeSpan: fmt::Debug, - OnRequest: fmt::Debug, - OnResponse: fmt::Debug, - OnBodyChunk: fmt::Debug, - OnEos: fmt::Debug, - OnFailure: fmt::Debug, - > fmt::Debug for TraceLayer + M: fmt::Debug, + MakeSpan: fmt::Debug, + OnRequest: fmt::Debug, + OnResponse: fmt::Debug, + OnBodyChunk: fmt::Debug, + OnEos: fmt::Debug, + OnFailure: fmt::Debug, +> fmt::Debug for TraceLayer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("TraceLayer") @@ -57,14 +57,14 @@ impl< } impl< - M: Clone, - MakeSpan: Clone, - OnRequest: Clone, - OnResponse: Clone, - OnBodyChunk: Clone, - OnEos: Clone, - OnFailure: Clone, - > Clone for TraceLayer + M: Clone, + MakeSpan: Clone, + OnRequest: Clone, + OnResponse: Clone, + OnBodyChunk: Clone, + OnEos: Clone, + OnFailure: Clone, +> Clone for TraceLayer { fn clone(&self) -> Self { Self { diff --git a/rama-http/src/layer/trace/on_eos.rs b/rama-http/src/layer/trace/on_eos.rs index 6506c8a09..70aea819c 100644 --- a/rama-http/src/layer/trace/on_eos.rs +++ b/rama-http/src/layer/trace/on_eos.rs @@ -1,4 +1,4 @@ -use super::{Latency, DEFAULT_MESSAGE_LEVEL}; +use super::{DEFAULT_MESSAGE_LEVEL, Latency}; use crate::header::HeaderMap; use crate::layer::classify::grpc_errors_as_failures::ParsedGrpcStatus; use rama_utils::latency::LatencyUnit; diff --git a/rama-http/src/layer/trace/on_failure.rs b/rama-http/src/layer/trace/on_failure.rs index 02cdfaf21..4b8d20a2f 100644 --- a/rama-http/src/layer/trace/on_failure.rs +++ b/rama-http/src/layer/trace/on_failure.rs @@ -1,4 +1,4 @@ -use super::{Latency, DEFAULT_ERROR_LEVEL}; +use super::{DEFAULT_ERROR_LEVEL, Latency}; use rama_utils::latency::LatencyUnit; use std::{fmt, time::Duration}; use tracing::{Level, Span}; diff --git a/rama-http/src/layer/trace/on_response.rs b/rama-http/src/layer/trace/on_response.rs index 057f653f9..f8941e35e 100644 --- a/rama-http/src/layer/trace/on_response.rs +++ b/rama-http/src/layer/trace/on_response.rs @@ -1,4 +1,4 @@ -use super::{Latency, DEFAULT_MESSAGE_LEVEL}; +use super::{DEFAULT_MESSAGE_LEVEL, Latency}; use crate::Response; use rama_utils::latency::LatencyUnit; use std::time::Duration; diff --git a/rama-http/src/layer/trace/service.rs b/rama-http/src/layer/trace/service.rs index 6f0a13b2e..ef61087e2 100644 --- a/rama-http/src/layer/trace/service.rs +++ b/rama-http/src/layer/trace/service.rs @@ -40,15 +40,15 @@ pub struct Trace< } impl< - S: fmt::Debug, - M: fmt::Debug, - MakeSpan: fmt::Debug, - OnRequest: fmt::Debug, - OnResponse: fmt::Debug, - OnBodyChunk: fmt::Debug, - OnEos: fmt::Debug, - OnFailure: fmt::Debug, - > fmt::Debug for Trace + S: fmt::Debug, + M: fmt::Debug, + MakeSpan: fmt::Debug, + OnRequest: fmt::Debug, + OnResponse: fmt::Debug, + OnBodyChunk: fmt::Debug, + OnEos: fmt::Debug, + OnFailure: fmt::Debug, +> fmt::Debug for Trace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("TraceLayer") @@ -65,15 +65,15 @@ impl< } impl< - S: Clone, - M: Clone, - MakeSpan: Clone, - OnRequest: Clone, - OnResponse: Clone, - OnBodyChunk: Clone, - OnEos: Clone, - OnFailure: Clone, - > Clone for Trace + S: Clone, + M: Clone, + MakeSpan: Clone, + OnRequest: Clone, + OnResponse: Clone, + OnBodyChunk: Clone, + OnEos: Clone, + OnFailure: Clone, +> Clone for Trace { fn clone(&self) -> Self { Self { @@ -298,18 +298,18 @@ impl } impl< - S, - State, - ReqBody, - ResBody, - M, - OnRequestT, - OnResponseT, - OnFailureT, - OnBodyChunkT, - OnEosT, - MakeSpanT, - > Service> + S, + State, + ReqBody, + ResBody, + M, + OnRequestT, + OnResponseT, + OnFailureT, + OnBodyChunkT, + OnEosT, + MakeSpanT, +> Service> for Trace where S: Service, Response = Response, Error: fmt::Display>, diff --git a/rama-http/src/layer/traffic_writer/mod.rs b/rama-http/src/layer/traffic_writer/mod.rs index 178082311..5e745c9b8 100644 --- a/rama-http/src/layer/traffic_writer/mod.rs +++ b/rama-http/src/layer/traffic_writer/mod.rs @@ -3,13 +3,13 @@ //! Can be useful for cli / debug purposes. use crate::{ - io::{write_http_request, write_http_response}, Request, Response, + io::{write_http_request, write_http_response}, }; use rama_core::rt::Executor; use tokio::{ io::{AsyncWrite, AsyncWriteExt}, - sync::mpsc::{channel, unbounded_channel, Sender, UnboundedSender}, + sync::mpsc::{Sender, UnboundedSender, channel, unbounded_channel}, }; mod request; diff --git a/rama-http/src/layer/traffic_writer/request.rs b/rama-http/src/layer/traffic_writer/request.rs index 8bc1eec43..773c5213a 100644 --- a/rama-http/src/layer/traffic_writer/request.rs +++ b/rama-http/src/layer/traffic_writer/request.rs @@ -10,8 +10,8 @@ use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; use std::fmt::Debug; use std::future::Future; -use tokio::io::{stderr, stdout, AsyncWrite, AsyncWriteExt}; -use tokio::sync::mpsc::{channel, unbounded_channel, Sender, UnboundedSender}; +use tokio::io::{AsyncWrite, AsyncWriteExt, stderr, stdout}; +use tokio::sync::mpsc::{Sender, UnboundedSender, channel, unbounded_channel}; /// Layer that applies [`RequestWriterService`] which prints the http request in std format. pub struct RequestWriterLayer { diff --git a/rama-http/src/layer/traffic_writer/response.rs b/rama-http/src/layer/traffic_writer/response.rs index 0373ceaa6..76b3d0dd2 100644 --- a/rama-http/src/layer/traffic_writer/response.rs +++ b/rama-http/src/layer/traffic_writer/response.rs @@ -10,8 +10,8 @@ use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; use std::fmt::Debug; use std::future::Future; -use tokio::io::{stderr, stdout, AsyncWrite}; -use tokio::sync::mpsc::{channel, unbounded_channel, Sender, UnboundedSender}; +use tokio::io::{AsyncWrite, stderr, stdout}; +use tokio::sync::mpsc::{Sender, UnboundedSender, channel, unbounded_channel}; /// Layer that applies [`ResponseWriterService`] which prints the http response in std format. pub struct ResponseWriterLayer { diff --git a/rama-http/src/layer/ua.rs b/rama-http/src/layer/ua.rs index a34e6618c..9d3bfd620 100644 --- a/rama-http/src/layer/ua.rs +++ b/rama-http/src/layer/ua.rs @@ -36,8 +36,8 @@ //! ``` use crate::{ - headers::{self, HeaderMapExt}, HeaderName, Request, + headers::{self, HeaderMapExt}, }; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; @@ -203,9 +203,9 @@ mod tests { use super::*; use crate::layer::required_header::AddRequiredRequestHeadersLayer; use crate::service::client::HttpClientExt; - use crate::{headers, IntoResponse, Response, StatusCode}; - use rama_core::service::service_fn; + use crate::{IntoResponse, Response, StatusCode, headers}; use rama_core::Context; + use rama_core::service::service_fn; use std::convert::Infallible; #[tokio::test] diff --git a/rama-http/src/layer/util/compression.rs b/rama-http/src/layer/util/compression.rs index 74b1237f4..a46978885 100644 --- a/rama-http/src/layer/util/compression.rs +++ b/rama-http/src/layer/util/compression.rs @@ -1,11 +1,11 @@ //! Types used by compression and decompression middleware. use super::content_encoding::SupportedEncodings; -use crate::dep::http_body::{Body, Frame}; use crate::HeaderValue; +use crate::dep::http_body::{Body, Frame}; use bytes::{Buf, Bytes, BytesMut}; -use futures_lite::ready; use futures_lite::Stream; +use futures_lite::ready; use pin_project_lite::pin_project; use rama_core::error::BoxError; use std::{ diff --git a/rama-http/src/layer/validate_request/accept_header.rs b/rama-http/src/layer/validate_request/accept_header.rs index f5be3c829..fbf0ecaf7 100644 --- a/rama-http/src/layer/validate_request/accept_header.rs +++ b/rama-http/src/layer/validate_request/accept_header.rs @@ -1,7 +1,8 @@ use super::ValidateRequest; use crate::{ + Request, Response, StatusCode, dep::mime::{Mime, MimeIter}, - header, Request, Response, StatusCode, + header, }; use rama_core::Context; use std::{fmt, marker::PhantomData, sync::Arc}; diff --git a/rama-http/src/layer/validate_request/validate_request_header.rs b/rama-http/src/layer/validate_request/validate_request_header.rs index 2128f26ca..308f01124 100644 --- a/rama-http/src/layer/validate_request/validate_request_header.rs +++ b/rama-http/src/layer/validate_request/validate_request_header.rs @@ -185,8 +185,8 @@ mod tests { #[allow(unused_imports)] use super::*; - use crate::{header, Body, StatusCode}; - use rama_core::{error::BoxError, service::service_fn, Layer}; + use crate::{Body, StatusCode, header}; + use rama_core::{Layer, error::BoxError, service::service_fn}; #[tokio::test] async fn valid_accept_header() { diff --git a/rama-http/src/lib.rs b/rama-http/src/lib.rs index 5163b360f..d4402ea66 100644 --- a/rama-http/src/lib.rs +++ b/rama-http/src/lib.rs @@ -19,10 +19,9 @@ #[doc(inline)] pub use ::rama_http_types::{ - header, proto, - response::{self, IntoResponse, Response}, Body, BodyDataStream, BodyExtractExt, BodyLimit, HeaderMap, HeaderName, HeaderValue, Method, - Request, Scheme, StatusCode, Uri, Version, + Request, Scheme, StatusCode, Uri, Version, header, proto, + response::{self, IntoResponse, Response}, }; pub mod headers; diff --git a/rama-http/src/matcher/domain.rs b/rama-http/src/matcher/domain.rs index 8d15d838b..435f54ab3 100644 --- a/rama-http/src/matcher/domain.rs +++ b/rama-http/src/matcher/domain.rs @@ -1,5 +1,5 @@ use crate::Request; -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; use rama_net::address::{Domain, Host}; use rama_net::http::RequestContext; diff --git a/rama-http/src/matcher/header.rs b/rama-http/src/matcher/header.rs index 7695e691c..b641fefaa 100644 --- a/rama-http/src/matcher/header.rs +++ b/rama-http/src/matcher/header.rs @@ -1,5 +1,5 @@ use crate::{HeaderName, HeaderValue, Request}; -use rama_core::{context::Extensions, matcher::Matcher, Context}; +use rama_core::{Context, context::Extensions, matcher::Matcher}; #[derive(Debug, Clone)] /// Matcher based on the [`Request`]'s headers. diff --git a/rama-http/src/matcher/method.rs b/rama-http/src/matcher/method.rs index 273244749..8f181c98c 100644 --- a/rama-http/src/matcher/method.rs +++ b/rama-http/src/matcher/method.rs @@ -1,5 +1,5 @@ use crate::{Method, Request}; -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; use std::{ fmt, fmt::{Debug, Formatter}, diff --git a/rama-http/src/matcher/mod.rs b/rama-http/src/matcher/mod.rs index 942eb13c8..b9d191ef8 100644 --- a/rama-http/src/matcher/mod.rs +++ b/rama-http/src/matcher/mod.rs @@ -6,7 +6,7 @@ //! [`http::Request`]: crate::Request //! [`service::matcher` module]: rama_core use crate::Request; -use rama_core::{context::Extensions, matcher::IteratorMatcherExt, Context}; +use rama_core::{Context, context::Extensions, matcher::IteratorMatcherExt}; use rama_net::{address::Domain, stream::matcher::SocketMatcher}; use std::fmt; use std::sync::Arc; @@ -688,11 +688,7 @@ where req: &Request, ) -> bool { let matches = self.kind.matches(ext, ctx, req); - if self.negate { - !matches - } else { - matches - } + if self.negate { !matches } else { matches } } } diff --git a/rama-http/src/matcher/path/de.rs b/rama-http/src/matcher/path/de.rs index 440e86a2a..9f6a3620a 100644 --- a/rama-http/src/matcher/path/de.rs +++ b/rama-http/src/matcher/path/de.rs @@ -1,6 +1,7 @@ use serde::{ + Deserializer, de::{self, DeserializeSeed, EnumAccess, Error, MapAccess, SeqAccess, VariantAccess, Visitor}, - forward_to_deserialize_any, Deserializer, + forward_to_deserialize_any, }; use std::{any::type_name, fmt}; @@ -144,7 +145,10 @@ impl fmt::Display for ErrorKind { )?; if *expected == 1 { - write!(f, ". Note that multiple parameters must be extracted with a tuple `Path<(_, _)>` or a struct `Path`")?; + write!( + f, + ". Note that multiple parameters must be extracted with a tuple `Path<(_, _)>` or a struct `Path`" + )?; } Ok(()) diff --git a/rama-http/src/matcher/path/mod.rs b/rama-http/src/matcher/path/mod.rs index 678b1a4d0..c403b9d4c 100644 --- a/rama-http/src/matcher/path/mod.rs +++ b/rama-http/src/matcher/path/mod.rs @@ -1,5 +1,5 @@ use crate::{IntoResponse, Request, StatusCode}; -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; use std::collections::HashMap; mod de; diff --git a/rama-http/src/matcher/uri.rs b/rama-http/src/matcher/uri.rs index aebea13ed..f5b45effa 100644 --- a/rama-http/src/matcher/uri.rs +++ b/rama-http/src/matcher/uri.rs @@ -1,7 +1,7 @@ //! provides a [`UriMatcher`] matcher for matching requests based on their URI. use crate::{Request, Uri}; -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; pub mod dep { //! dependencies for the `uri` matcher module diff --git a/rama-http/src/matcher/version.rs b/rama-http/src/matcher/version.rs index 71edef4cf..2d2659f1d 100644 --- a/rama-http/src/matcher/version.rs +++ b/rama-http/src/matcher/version.rs @@ -1,5 +1,5 @@ use crate::{Request, Version}; -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; use std::fmt::{self, Debug, Formatter}; /// A matcher that matches one or more HTTP methods. diff --git a/rama-http/src/service/client/ext.rs b/rama-http/src/service/client/ext.rs index c2662098e..fcd6a4481 100644 --- a/rama-http/src/service/client/ext.rs +++ b/rama-http/src/service/client/ext.rs @@ -1,7 +1,7 @@ -use crate::{headers::HeaderExt, Method, Request, Response, Uri}; +use crate::{Method, Request, Response, Uri, headers::HeaderExt}; use rama_core::{ - error::{BoxError, ErrorExt, OpaqueError}, Context, Service, + error::{BoxError, ErrorExt, OpaqueError}, }; use std::future::Future; @@ -141,7 +141,7 @@ where http_client_service: self, state: RequestBuilderState::Error(err), _phantom: std::marker::PhantomData, - } + }; } }; @@ -652,16 +652,16 @@ mod test { use super::*; use crate::{ + IntoResponse, layer::{ required_header::AddRequiredRequestHeadersLayer, retry::{ManagedPolicy, RetryLayer}, trace::TraceLayer, }, - IntoResponse, }; use rama_core::{ layer::{Layer, MapResultLayer}, - service::{service_fn, BoxService}, + service::{BoxService, service_fn}, }; use rama_utils::backoff::ExponentialBackoff; use std::convert::Infallible; diff --git a/rama-http/src/service/fs/serve_dir/future.rs b/rama-http/src/service/fs/serve_dir/future.rs index f609cdf04..142bddda0 100644 --- a/rama-http/src/service/fs/serve_dir/future.rs +++ b/rama-http/src/service/fs/serve_dir/future.rs @@ -1,13 +1,13 @@ use super::open_file::{FileOpened, FileRequestExtent, OpenFileOutput}; use crate::{ + Body, HeaderValue, Request, Response, StatusCode, dep::http_body_util::BodyExt, header::{self, ALLOW}, layer::util::content_encoding::Encoding, service::fs::AsyncReadBody, - Body, HeaderValue, Request, Response, StatusCode, }; use bytes::Bytes; -use rama_core::{error::BoxError, Context, Service}; +use rama_core::{Context, Service, error::BoxError}; use std::{convert::Infallible, io}; pub(super) async fn consume_open_file_result( diff --git a/rama-http/src/service/fs/serve_dir/mod.rs b/rama-http/src/service/fs/serve_dir/mod.rs index 1342134c1..0db993aad 100644 --- a/rama-http/src/service/fs/serve_dir/mod.rs +++ b/rama-http/src/service/fs/serve_dir/mod.rs @@ -1,9 +1,9 @@ use crate::dep::http_body::Body as HttpBody; use crate::layer::{ set_status::SetStatus, - util::content_encoding::{encodings, SupportedEncodings}, + util::content_encoding::{SupportedEncodings, encodings}, }; -use crate::{header, Body, HeaderValue, Method, Request, Response, StatusCode}; +use crate::{Body, HeaderValue, Method, Request, Response, StatusCode, header}; use bytes::Bytes; use percent_encoding::percent_decode; use rama_core::error::BoxError; diff --git a/rama-http/src/service/fs/serve_dir/open_file.rs b/rama-http/src/service/fs/serve_dir/open_file.rs index 618b10675..198703bc3 100644 --- a/rama-http/src/service/fs/serve_dir/open_file.rs +++ b/rama-http/src/service/fs/serve_dir/open_file.rs @@ -1,9 +1,9 @@ use super::{ - headers::{IfModifiedSince, IfUnmodifiedSince, LastModified}, ServeVariant, + headers::{IfModifiedSince, IfUnmodifiedSince, LastModified}, }; use crate::layer::util::content_encoding::{Encoding, QValue}; -use crate::{header, HeaderValue, Method, Request, Uri}; +use crate::{HeaderValue, Method, Request, Uri, header}; use http_range_header::RangeUnsatisfiableError; use std::{ ffi::OsStr, diff --git a/rama-http/src/service/fs/serve_dir/tests.rs b/rama-http/src/service/fs/serve_dir/tests.rs index 1e037a265..9f313f319 100644 --- a/rama-http/src/service/fs/serve_dir/tests.rs +++ b/rama-http/src/service/fs/serve_dir/tests.rs @@ -1,9 +1,9 @@ +use crate::Body; use crate::dep::http_body::Body as HttpBody; use crate::dep::http_body_util::BodyExt; use crate::header::ALLOW; use crate::service::fs::{ServeDir, ServeFile}; -use crate::Body; -use crate::{header, Method, Response}; +use crate::{Method, Response, header}; use crate::{Request, StatusCode}; use brotli::BrotliDecompress; use bytes::Bytes; @@ -493,15 +493,17 @@ async fn read_partial_in_bounds() { res.headers()["content-length"], (bytes_end_incl - bytes_start_incl + 1).to_string() ); - assert!(res.headers()["content-range"] - .to_str() - .unwrap() - .starts_with(&format!( - "bytes {}-{}/{}", - bytes_start_incl, - bytes_end_incl, - file_contents.len() - ))); + assert!( + res.headers()["content-range"] + .to_str() + .unwrap() + .starts_with(&format!( + "bytes {}-{}/{}", + bytes_start_incl, + bytes_end_incl, + file_contents.len() + )) + ); assert_eq!(res.headers()["content-type"], "text/markdown"); let body = res.into_body().collect().await.unwrap().to_bytes(); diff --git a/rama-http/src/service/fs/serve_file.rs b/rama-http/src/service/fs/serve_file.rs index 81d590644..77220613a 100644 --- a/rama-http/src/service/fs/serve_file.rs +++ b/rama-http/src/service/fs/serve_file.rs @@ -171,12 +171,12 @@ mod compression_tests { #[cfg(test)] mod tests { + use crate::Body; + use crate::Method; use crate::dep::http_body_util::BodyExt; use crate::dep::mime::Mime; use crate::header; use crate::service::fs::ServeFile; - use crate::Body; - use crate::Method; use crate::{Request, StatusCode}; use brotli::BrotliDecompress; use flate2::bufread::DeflateDecoder; diff --git a/rama-http/src/service/redirect.rs b/rama-http/src/service/redirect.rs index b47978b91..87445a232 100644 --- a/rama-http/src/service/redirect.rs +++ b/rama-http/src/service/redirect.rs @@ -1,7 +1,7 @@ //! Service that redirects all requests. use crate::Request; -use crate::{header, HeaderValue, Response, StatusCode, Uri}; +use crate::{HeaderValue, Response, StatusCode, Uri, header}; use rama_core::{Context, Service}; use std::{ convert::{Infallible, TryFrom}, diff --git a/rama-http/src/service/web/endpoint/extract/authority.rs b/rama-http/src/service/web/endpoint/extract/authority.rs index 226d75908..86d69224d 100644 --- a/rama-http/src/service/web/endpoint/extract/authority.rs +++ b/rama-http/src/service/web/endpoint/extract/authority.rs @@ -44,11 +44,11 @@ where mod tests { use super::*; + use crate::StatusCode; use crate::dep::http_body_util::BodyExt as _; use crate::header::X_FORWARDED_HOST; use crate::layer::forwarded::GetForwardedHeadersService; use crate::service::web::WebService; - use crate::StatusCode; use crate::{Body, HeaderName, Request}; use rama_core::Service; diff --git a/rama-http/src/service/web/endpoint/extract/body/bytes.rs b/rama-http/src/service/web/endpoint/extract/body/bytes.rs index cc7273792..b8335aa7f 100644 --- a/rama-http/src/service/web/endpoint/extract/body/bytes.rs +++ b/rama-http/src/service/web/endpoint/extract/body/bytes.rs @@ -1,7 +1,7 @@ +use crate::Request; use crate::dep::http_body_util::BodyExt; use crate::service::web::extract::FromRequest; use crate::utils::macros::define_http_rejection; -use crate::Request; use rama_utils::macros::impl_deref; /// Extractor to get the response body, collected as [`Bytes`]. diff --git a/rama-http/src/service/web/endpoint/extract/body/csv.rs b/rama-http/src/service/web/endpoint/extract/body/csv.rs index 6521afcb0..f37836fe8 100644 --- a/rama-http/src/service/web/endpoint/extract/body/csv.rs +++ b/rama-http/src/service/web/endpoint/extract/body/csv.rs @@ -1,8 +1,8 @@ use super::BytesRejection; +use crate::Request; use crate::dep::http_body_util::BodyExt; use crate::service::web::extract::FromRequest; use crate::utils::macros::{composite_http_rejection, define_http_rejection}; -use crate::Request; use bytes::Buf; pub use crate::response::Csv; @@ -74,8 +74,8 @@ where #[cfg(test)] mod test { use super::*; - use crate::service::web::WebService; use crate::StatusCode; + use crate::service::web::WebService; use rama_core::{Context, Service}; #[tokio::test] diff --git a/rama-http/src/service/web/endpoint/extract/body/json.rs b/rama-http/src/service/web/endpoint/extract/body/json.rs index f83fa619c..c58628062 100644 --- a/rama-http/src/service/web/endpoint/extract/body/json.rs +++ b/rama-http/src/service/web/endpoint/extract/body/json.rs @@ -1,8 +1,8 @@ use super::BytesRejection; +use crate::Request; use crate::dep::http_body_util::BodyExt; use crate::service::web::extract::FromRequest; use crate::utils::macros::{composite_http_rejection, define_http_rejection}; -use crate::Request; pub use crate::response::Json; @@ -66,8 +66,8 @@ where #[cfg(test)] mod test { use super::*; - use crate::service::web::WebService; use crate::StatusCode; + use crate::service::web::WebService; use rama_core::{Context, Service}; #[tokio::test] diff --git a/rama-http/src/service/web/endpoint/extract/body/text.rs b/rama-http/src/service/web/endpoint/extract/body/text.rs index e796a5fee..c690e11c5 100644 --- a/rama-http/src/service/web/endpoint/extract/body/text.rs +++ b/rama-http/src/service/web/endpoint/extract/body/text.rs @@ -1,8 +1,8 @@ use super::BytesRejection; +use crate::Request; use crate::dep::http_body_util::BodyExt; use crate::service::web::extract::FromRequest; use crate::utils::macros::{composite_http_rejection, define_http_rejection}; -use crate::Request; use rama_utils::macros::impl_deref; /// Extractor to get the response body, collected as [`String`]. @@ -64,7 +64,7 @@ impl FromRequest for Text { mod test { use super::*; use crate::service::web::WebService; - use crate::{header, Method, Request, StatusCode}; + use crate::{Method, Request, StatusCode, header}; use rama_core::{Context, Service}; #[tokio::test] diff --git a/rama-http/src/service/web/endpoint/extract/host.rs b/rama-http/src/service/web/endpoint/extract/host.rs index 5305ab76f..f49c68ce7 100644 --- a/rama-http/src/service/web/endpoint/extract/host.rs +++ b/rama-http/src/service/web/endpoint/extract/host.rs @@ -45,11 +45,11 @@ where mod tests { use super::*; + use crate::StatusCode; use crate::dep::http_body_util::BodyExt as _; use crate::header::X_FORWARDED_HOST; use crate::layer::forwarded::GetForwardedHeadersService; use crate::service::web::WebService; - use crate::StatusCode; use crate::{Body, HeaderName, Request}; use rama_core::Service; diff --git a/rama-http/src/service/web/endpoint/extract/method.rs b/rama-http/src/service/web/endpoint/extract/method.rs index 75e2bd391..79a864a89 100644 --- a/rama-http/src/service/web/endpoint/extract/method.rs +++ b/rama-http/src/service/web/endpoint/extract/method.rs @@ -1,5 +1,5 @@ use super::FromRequestContextRefPair; -use crate::{dep::http::request::Parts, Method}; +use crate::{Method, dep::http::request::Parts}; use rama_core::Context; use std::convert::Infallible; diff --git a/rama-http/src/service/web/endpoint/extract/mod.rs b/rama-http/src/service/web/endpoint/extract/mod.rs index 858fffe95..3c75edbf0 100644 --- a/rama-http/src/service/web/endpoint/extract/mod.rs +++ b/rama-http/src/service/web/endpoint/extract/mod.rs @@ -1,6 +1,6 @@ //! Extract utilities to develop endpoint services efortless. -use crate::{dep::http::request::Parts, dep::mime, header, HeaderMap, IntoResponse}; +use crate::{HeaderMap, IntoResponse, dep::http::request::Parts, dep::mime, header}; use rama_core::Context; use std::future::Future; diff --git a/rama-http/src/service/web/endpoint/extract/option.rs b/rama-http/src/service/web/endpoint/extract/option.rs index da73e28fc..fbcb76cdc 100644 --- a/rama-http/src/service/web/endpoint/extract/option.rs +++ b/rama-http/src/service/web/endpoint/extract/option.rs @@ -3,7 +3,7 @@ use std::future::Future; use rama_core::Context; use crate::response::IntoResponse; -use crate::{dep::http::request::Parts, Request}; +use crate::{Request, dep::http::request::Parts}; use super::{FromRequest, FromRequestContextRefPair}; diff --git a/rama-http/src/service/web/endpoint/extract/typed_header.rs b/rama-http/src/service/web/endpoint/extract/typed_header.rs index 933f8c2b9..482d80808 100644 --- a/rama-http/src/service/web/endpoint/extract/typed_header.rs +++ b/rama-http/src/service/web/endpoint/extract/typed_header.rs @@ -157,9 +157,9 @@ impl std::error::Error for TypedHeaderRejection { #[cfg(test)] mod tests { use crate::{ + Body, Request, headers::ContentType, service::web::extract::{FromRequestContextRefPair, TypedHeader}, - Body, Request, }; use rama_core::Context; diff --git a/rama-http/src/service/web/endpoint/mod.rs b/rama-http/src/service/web/endpoint/mod.rs index 3b9078943..639fd8fbb 100644 --- a/rama-http/src/service/web/endpoint/mod.rs +++ b/rama-http/src/service/web/endpoint/mod.rs @@ -1,5 +1,5 @@ -use crate::{matcher::HttpMatcher, Body, IntoResponse, Request, Response}; -use rama_core::{layer::MapResponseLayer, service::BoxService, Context, Layer, Service}; +use crate::{Body, IntoResponse, Request, Response, matcher::HttpMatcher}; +use rama_core::{Context, Layer, Service, layer::MapResponseLayer, service::BoxService}; use std::future::Future; use std::{convert::Infallible, fmt}; @@ -178,7 +178,7 @@ mod private { #[cfg(test)] mod tests { use super::*; - use crate::{dep::http_body_util::BodyExt, Body, Method, Request, StatusCode}; + use crate::{Body, Method, Request, StatusCode, dep::http_body_util::BodyExt}; use extract::*; fn assert_into_endpoint_service(_: I) diff --git a/rama-http/src/service/web/endpoint/service.rs b/rama-http/src/service/web/endpoint/service.rs index ebada7f2c..6054d384e 100644 --- a/rama-http/src/service/web/endpoint/service.rs +++ b/rama-http/src/service/web/endpoint/service.rs @@ -124,7 +124,7 @@ mod private { /// It is expected to do so by extracting the desired data from the context and/or request, /// and then calling the function with the extracted data. fn call(&self, ctx: Context, req: Request) - -> impl Future + Send + '_; + -> impl Future + Send + '_; } impl Sealed for F diff --git a/rama-http/src/service/web/k8s.rs b/rama-http/src/service/web/k8s.rs index 2c84640c2..861d5cdc4 100644 --- a/rama-http/src/service/web/k8s.rs +++ b/rama-http/src/service/web/k8s.rs @@ -1,9 +1,9 @@ //! k8s web service -use crate::{matcher::HttpMatcher, IntoResponse, Request, Response, StatusCode}; +use crate::{IntoResponse, Request, Response, StatusCode, matcher::HttpMatcher}; use rama_core::{ - service::{service_fn, BoxService}, Context, Service, + service::{BoxService, service_fn}, }; use std::{convert::Infallible, fmt, marker::PhantomData, sync::Arc}; diff --git a/rama-http/src/service/web/mod.rs b/rama-http/src/service/web/mod.rs index 7c39386ba..b7b9b4fec 100644 --- a/rama-http/src/service/web/mod.rs +++ b/rama-http/src/service/web/mod.rs @@ -2,11 +2,11 @@ mod service; #[doc(inline)] -pub use service::{match_service, WebService}; +pub use service::{WebService, match_service}; mod endpoint; #[doc(inline)] -pub use endpoint::{extract, EndpointServiceFn, IntoEndpointService}; +pub use endpoint::{EndpointServiceFn, IntoEndpointService, extract}; pub mod k8s; #[doc(inline)] diff --git a/rama-http/src/service/web/service.rs b/rama-http/src/service/web/service.rs index 2bb98679f..efd8a7e8b 100644 --- a/rama-http/src/service/web/service.rs +++ b/rama-http/src/service/web/service.rs @@ -1,14 +1,14 @@ -use super::{endpoint::Endpoint, IntoEndpointService}; +use super::{IntoEndpointService, endpoint::Endpoint}; use crate::{ + Body, IntoResponse, Request, Response, StatusCode, Uri, matcher::{HttpMatcher, UriParams}, service::fs::ServeDir, - Body, IntoResponse, Request, Response, StatusCode, Uri, }; use rama_core::{ + Context, context::Extensions, matcher::Matcher, - service::{service_fn, BoxService, Service}, - Context, + service::{BoxService, Service, service_fn}, }; use std::{convert::Infallible, fmt, future::Future, marker::PhantomData, sync::Arc}; @@ -320,7 +320,7 @@ where /// As you can see it is pretty much the same, except that you need to explicitly ensure /// that each service is an actual Endpoint service. macro_rules! __match_service { - ($($M:expr => $S:expr),+, _ => $F:expr $(,)?) => {{ + ($($M:expr_2021 => $S:expr_2021),+, _ => $F:expr $(,)?) => {{ use $crate::service::web::IntoEndpointService; ($(($M, $S.into_endpoint_service())),+, $F.into_endpoint_service()) }}; @@ -331,9 +331,9 @@ pub use crate::__match_service as match_service; #[cfg(test)] mod test { + use crate::Body; use crate::dep::http_body_util::BodyExt; use crate::matcher::MethodMatcher; - use crate::Body; use super::*; diff --git a/rama-http/src/utils/header_value.rs b/rama-http/src/utils/header_value.rs index c50912ee5..e3c0a723d 100644 --- a/rama-http/src/utils/header_value.rs +++ b/rama-http/src/utils/header_value.rs @@ -1,4 +1,4 @@ -use crate::{header::AsHeaderName, HeaderMap, Request, Response}; +use crate::{HeaderMap, Request, Response, header::AsHeaderName}; /// Utility trait for getting header values from a request or response. pub trait HeaderValueGetter { diff --git a/rama-macros/README.md b/rama-macros/README.md index 36b412aca..66097642c 100644 --- a/rama-macros/README.md +++ b/rama-macros/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-net/README.md b/rama-net/README.md index d2934caed..5e3f844db 100644 --- a/rama-net/README.md +++ b/rama-net/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-net/src/address/authority.rs b/rama-net/src/address/authority.rs index 7d0e43839..af2945304 100644 --- a/rama-net/src/address/authority.rs +++ b/rama-net/src/address/authority.rs @@ -1,4 +1,4 @@ -use super::{parse_utils, Domain, DomainAddress, Host}; +use super::{Domain, DomainAddress, Host, parse_utils}; use rama_core::error::{ErrorContext, OpaqueError}; use std::net::{Ipv4Addr, Ipv6Addr}; use std::{ diff --git a/rama-net/src/address/domain_address.rs b/rama-net/src/address/domain_address.rs index 2b774afb7..e09f159e6 100644 --- a/rama-net/src/address/domain_address.rs +++ b/rama-net/src/address/domain_address.rs @@ -1,4 +1,4 @@ -use crate::address::{parse_utils, Domain}; +use crate::address::{Domain, parse_utils}; use rama_core::error::{ErrorContext, OpaqueError}; use std::fmt; use std::str::FromStr; diff --git a/rama-net/src/address/host.rs b/rama-net/src/address/host.rs index ed45f823c..aced21466 100644 --- a/rama-net/src/address/host.rs +++ b/rama-net/src/address/host.rs @@ -1,4 +1,4 @@ -use super::{parse_utils, Domain}; +use super::{Domain, parse_utils}; use rama_core::error::{ErrorContext, OpaqueError}; use std::{ fmt, diff --git a/rama-net/src/address/proxy.rs b/rama-net/src/address/proxy.rs index dbf3675c2..d7ee8d33b 100644 --- a/rama-net/src/address/proxy.rs +++ b/rama-net/src/address/proxy.rs @@ -1,5 +1,5 @@ use super::{Authority, Host}; -use crate::{proto::try_to_extract_protocol_from_uri_scheme, user::ProxyCredential, Protocol}; +use crate::{Protocol, proto::try_to_extract_protocol_from_uri_scheme, user::ProxyCredential}; use rama_core::error::{ErrorContext, OpaqueError}; use std::{fmt::Display, str::FromStr}; diff --git a/rama-net/src/client/conn.rs b/rama-net/src/client/conn.rs index 1627f3a58..ea83597af 100644 --- a/rama-net/src/client/conn.rs +++ b/rama-net/src/client/conn.rs @@ -1,4 +1,4 @@ -use rama_core::{error::BoxError, Context, Service}; +use rama_core::{Context, Service, error::BoxError}; use std::{fmt, future::Future, net::SocketAddr}; /// The established connection to a server returned for the http client to be used. @@ -59,17 +59,17 @@ pub trait ConnectorService: Send + Sync + 'static { ) -> impl Future< Output = Result, Self::Error>, > + Send - + '_; + + '_; } impl ConnectorService for S where S: Service< - State, - Request, - Response = EstablishedClientConnection, - Error: Into, - >, + State, + Request, + Response = EstablishedClientConnection, + Error: Into, + >, { type Connection = Connection; type Error = S::Error; @@ -81,7 +81,7 @@ where ) -> impl Future< Output = Result, Self::Error>, > + Send - + '_ { + + '_ { self.serve(ctx, req) } } diff --git a/rama-net/src/fingerprint/ja3.rs b/rama-net/src/fingerprint/ja3.rs index ada128533..32a4a0159 100644 --- a/rama-net/src/fingerprint/ja3.rs +++ b/rama-net/src/fingerprint/ja3.rs @@ -224,17 +224,92 @@ mod tests { #[test] fn test_ja3_compute() { // src: - let test_cases = [TestCase { - client_hello: vec![0x3, 0x3, 0x86, 0xad, 0xa4, 0xcc, 0x19, 0xe7, 0x14, 0x54, 0x54, 0xfd, 0xe7, 0x37, 0x33, 0xdf, 0x66, 0xcb, 0xf6, 0xef, 0x3e, 0xc0, 0xa1, 0x54, 0xc6, 0xdd, 0x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, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0], - pcap: "chrome-grease-single.pcap", - expected_ja3_str: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53-10,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0", - expected_ja3_hash: "66918128f1b9b03303d77c6f2eefd128", - }, TestCase { - client_hello: vec![0x3, 0x3, 0xf6, 0x65, 0xb, 0x22, 0x13, 0xf1, 0xc3, 0xe9, 0xe7, 0xb3, 0xdc, 0x9, 0xe4, 0x4b, 0xcb, 0x6e, 0x5, 0xaf, 0x8f, 0x2f, 0x41, 0x8d, 0x15, 0xa8, 0x88, 0x46, 0x24, 0x83, 0xca, 0x9, 0x7c, 0x95, 0x20, 0x12, 0xc4, 0x5e, 0x71, 0x8b, 0xb9, 0xc9, 0xa9, 0x37, 0x93, 0x4c, 0x41, 0xa6, 0xe8, 0x9e, 0x8f, 0x15, 0x78, 0x52, 0xe, 0x3c, 0x28, 0xba, 0xab, 0xa3, 0x34, 0x8b, 0x53, 0x82, 0x83, 0x75, 0x24, 0x0, 0x3e, 0x13, 0x2, 0x13, 0x3, 0x13, 0x1, 0xc0, 0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 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0], - pcap: "curl.pcap", - expected_ja3_str: "771,4866-4867-4865-49196-49200-159-52393-52392-52394-49195-49199-158-49188-49192-107-49187-49191-103-49162-49172-57-49161-49171-51-157-156-61-60-53-47-255,0-11-10-13172-16-22-23-13-43-45-51-21,29-23-30-25-24,0-1-2", - expected_ja3_hash: "456523fc94726331a4d5a2e1d40b2cd7", - }]; + let test_cases = [ + TestCase { + client_hello: vec![ + 0x3, 0x3, 0x86, 0xad, 0xa4, 0xcc, 0x19, 0xe7, 0x14, 0x54, 0x54, 0xfd, 0xe7, + 0x37, 0x33, 0xdf, 0x66, 0xcb, 0xf6, 0xef, 0x3e, 0xc0, 0xa1, 0x54, 0xc6, 0xdd, + 0x14, 0x5e, 0xc0, 0x83, 0xac, 0xb9, 0xb4, 0xe7, 0x20, 0x1c, 0x64, 0xae, 0xa7, + 0xa2, 0xc3, 0xe1, 0x8c, 0xd1, 0x25, 0x2, 0x4d, 0xf7, 0x86, 0x4a, 0xc7, 0x19, + 0xd0, 0xc4, 0xbd, 0xfb, 0x40, 0xc2, 0xef, 0x7f, 0x6d, 0xd3, 0x9a, 0xa7, 0x53, + 0xdf, 0xdd, 0x0, 0x22, 0x1a, 0x1a, 0x13, 0x1, 0x13, 0x2, 0x13, 0x3, 0xc0, 0x2b, + 0xc0, 0x2f, 0xc0, 0x2c, 0xc0, 0x30, 0xcc, 0xa9, 0xcc, 0xa8, 0xc0, 0x13, 0xc0, + 0x14, 0x0, 0x9c, 0x0, 0x9d, 0x0, 0x2f, 0x0, 0x35, 0x0, 0xa, 0x1, 0x0, 0x1, + 0x91, 0xa, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0,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", + expected_ja3_str: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53-10,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0", + expected_ja3_hash: "66918128f1b9b03303d77c6f2eefd128", + }, + TestCase { + client_hello: vec![ + 0x3, 0x3, 0xf6, 0x65, 0xb, 0x22, 0x13, 0xf1, 0xc3, 0xe9, 0xe7, 0xb3, 0xdc, 0x9, + 0xe4, 0x4b, 0xcb, 0x6e, 0x5, 0xaf, 0x8f, 0x2f, 0x41, 0x8d, 0x15, 0xa8, 0x88, + 0x46, 0x24, 0x83, 0xca, 0x9, 0x7c, 0x95, 0x20, 0x12, 0xc4, 0x5e, 0x71, 0x8b, + 0xb9, 0xc9, 0xa9, 0x37, 0x93, 0x4c, 0x41, 0xa6, 0xe8, 0x9e, 0x8f, 0x15, 0x78, + 0x52, 0xe, 0x3c, 0x28, 0xba, 0xab, 0xa3, 0x34, 0x8b, 0x53, 0x82, 0x83, 0x75, + 0x24, 0x0, 0x3e, 0x13, 0x2, 0x13, 0x3, 0x13, 0x1, 0xc0, 0x2c, 0xc0, 0x30, 0x0, + 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f, 0x0, 0x9e, + 0xc0, 0x24, 0xc0, 0x28, 0x0, 0x6b, 0xc0, 0x23, 0xc0, 0x27, 0x0, 0x67, 0xc0, + 0xa, 0xc0, 0x14, 0x0, 0x39, 0xc0, 0x9, 0xc0, 0x13, 0x0, 0x33, 0x0, 0x9d, 0x0, + 0x9c, 0x0, 0x3d, 0x0, 0x3c, 0x0, 0x35, 0x0, 0x2f, 0x0, 0xff, 0x1, 0x0, 0x1, + 0x75, 0x0, 0x0, 0x0, 0x10, 0x0, 0xe, 0x0, 0x0, 0xb, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x0, 0xb, 0x0, 0x4, 0x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0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + ], + pcap: "curl.pcap", + expected_ja3_str: "771,4866-4867-4865-49196-49200-159-52393-52392-52394-49195-49199-158-49188-49192-107-49187-49191-103-49162-49172-57-49161-49171-51-157-156-61-60-53-47-255,0-11-10-13172-16-22-23-13-43-45-51-21,29-23-30-25-24,0-1-2", + expected_ja3_hash: "456523fc94726331a4d5a2e1d40b2cd7", + }, + ]; for test_case in test_cases { let mut ext = Extensions::new(); ext.insert(SecureTransport::with_client_hello( diff --git a/rama-net/src/fingerprint/ja4/http.rs b/rama-net/src/fingerprint/ja4/http.rs index bfd72785a..fc7195e2f 100644 --- a/rama-net/src/fingerprint/ja4/http.rs +++ b/rama-net/src/fingerprint/ja4/http.rs @@ -19,9 +19,9 @@ use std::{ }; use rama_http_types::{ + Method, Request, Version, header::{ACCEPT_LANGUAGE, COOKIE, REFERER}, proto::h1::Http1HeaderMap, - Method, Request, Version, }; #[derive(Clone)] diff --git a/rama-net/src/fingerprint/ja4/tls.rs b/rama-net/src/fingerprint/ja4/tls.rs index c4da806fd..69a42d78b 100644 --- a/rama-net/src/fingerprint/ja4/tls.rs +++ b/rama-net/src/fingerprint/ja4/tls.rs @@ -4,8 +4,8 @@ use std::{borrow::Cow, fmt}; use rama_core::context::Extensions; use crate::tls::{ - client::NegotiatedTlsParameters, ApplicationProtocol, CipherSuite, ExtensionId, - ProtocolVersion, SecureTransport, SignatureScheme, + ApplicationProtocol, CipherSuite, ExtensionId, ProtocolVersion, SecureTransport, + SignatureScheme, client::NegotiatedTlsParameters, }; #[derive(Clone)] @@ -326,31 +326,294 @@ mod tests { // src: // + random wireshark // + random curl to echo.ramaproxy.org over http/1.1 - let test_cases = [TestCase { - client_hello: vec![0x3, 0x3, 0x86, 0xad, 0xa4, 0xcc, 0x19, 0xe7, 0x14, 0x54, 0x54, 0xfd, 0xe7, 0x37, 0x33, 0xdf, 0x66, 0xcb, 0xf6, 0xef, 0x3e, 0xc0, 0xa1, 0x54, 0xc6, 0xdd, 0x14, 0x5e, 0xc0, 0x83, 0xac, 0xb9, 0xb4, 0xe7, 0x20, 0x1c, 0x64, 0xae, 0xa7, 0xa2, 0xc3, 0xe1, 0x8c, 0xd1, 0x25, 0x2, 0x4d, 0xf7, 0x86, 0x4a, 0xc7, 0x19, 0xd0, 0xc4, 0xbd, 0xfb, 0x40, 0xc2, 0xef, 0x7f, 0x6d, 0xd3, 0x9a, 0xa7, 0x53, 0xdf, 0xdd, 0x0, 0x22, 0x1a, 0x1a, 0x13, 0x1, 0x13, 0x2, 0x13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 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0], - negotiated_protocol_version: Some(ProtocolVersion::TLSv1_3), - pcap: "chrome-grease-single.pcap", - expected_ja4_str: "t13d1615h2_000a,002f,0035,009c,009d,1301,1302,1303,c013,c014,c02b,c02c,c02f,c030,cca8,cca9_0005,000a,000b,000d,0012,0015,0017,001b,0023,002b,002d,0033,ff01_0403,0804,0401,0503,0805,0501,0806,0601,0201", - expected_ja4_hash: "t13d1615h2_46e7e9700bed_45f260be83e2", - }, TestCase { - client_hello: vec![0x03, 0x03, 0x95, 0xb9, 0xc5, 0xa1, 0x35, 0x0d, 0xc2, 0x47, 0x9d, 0x37, 0x77, 0x94, 0x51, 0x39, 0x08, 0xc1, 0x67, 0x43, 0x08, 0xa4, 0x53, 0xb3, 0x18, 0x7e, 0x0c, 0xde, 0x18, 0xd6, 0x77, 0x1d, 0xd7, 0x0c, 0x20, 0x5b, 0x41, 0xe2, 0xb4, 0xe3, 0x28, 0x26, 0xfd, 0x1a, 0x14, 0xab, 0x14, 0x04, 0x0b, 0xe2, 0xe1, 0x66, 0x12, 0xbd, 0x44, 0x41, 0x38, 0xcd, 0xb3, 0xcf, 0xa1, 0x44, 0xe0, 0xa4, 0xf7, 0x5d, 0x90, 0x00, 0x3e, 0x13, 0x02, 0x13, 0x03, 0x13, 0x01, 0xc0, 0x2c, 0xc0, 0x30, 0x00, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f, 0x00, 0x9e, 0xc0, 0x24, 0xc0, 0x28, 0x00, 0x6b, 0xc0, 0x23, 0xc0, 0x27, 0x00, 0x67, 0xc0, 0x0a, 0xc0, 0x14, 0x00, 0x39, 0xc0, 0x09, 0xc0, 0x13, 0x00, 0x33, 0x00, 0x9d, 0x00, 0x9c, 0x00, 0x3d, 0x00, 0x3c, 0x00, 0x35, 0x00, 0x2f, 0x00, 0xff, 0x01, 0x00, 0x01, 0x75, 0x00, 0x00, 0x00, 0x17, 0x00, 0x15, 0x00, 0x00, 0x12, 0x65, 0x63, 0x68, 0x6f, 0x2e, 0x72, 0x61, 0x6d, 0x61, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x6f, 0x72, 0x67, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a, 0x00, 0x16, 0x00, 0x14, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x1e, 0x00, 0x19, 0x00, 0x18, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x01, 0x04, 0x33, 0x74, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x09, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x2a, 0x00, 0x28, 0x04, 0x03, 0x05, 0x03, 0x06, 0x03, 0x08, 0x07, 0x08, 0x08, 0x08, 0x09, 0x08, 0x0a, 0x08, 0x0b, 0x08, 0x04, 0x08, 0x05, 0x08, 0x06, 0x04, 0x01, 0x05, 0x01, 0x06, 0x01, 0x03, 0x03, 0x03, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x02, 0x06, 0x02, 0x00, 0x2b, 0x00, 0x05, 0x04, 0x03, 0x04, 0x03, 0x03, 0x00, 0x2d, 0x00, 0x02, 0x01, 0x01, 0x00, 0x33, 0x00, 0x26, 0x00, 0x24, 0x00, 0x1d, 0x00, 0x20, 0xe3, 0x86, 0xb6, 0x7d, 0x52, 0x0e, 0xd1, 0x7f, 0xbe, 0xed, 0xc0, 0xe8, 0xd9, 0x94, 0x4a, 0x7b, 0xff, 0xb8, 0xa0, 0x13, 0xa8, 0x5f, 0xbd, 0x2b, 0x10, 0x51, 0xa1, 0x3f, 0xb2, 0xe3, 0x37, 0x5d, 0x00, 0x15, 0x00, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], - negotiated_protocol_version: Some(ProtocolVersion::TLSv1_3), - pcap: "curl_http1.1.pcap", - expected_ja4_str: "t13d3113h1_002f,0033,0035,0039,003c,003d,0067,006b,009c,009d,009e,009f,00ff,1301,1302,1303,c009,c00a,c013,c014,c023,c024,c027,c028,c02b,c02c,c02f,c030,cca8,cca9,ccaa_000a,000b,000d,0015,0016,0017,002b,002d,0031,0033,3374_0403,0503,0603,0807,0808,0809,080a,080b,0804,0805,0806,0401,0501,0601,0303,0301,0302,0402,0502,0602", - expected_ja4_hash: "t13d3113h1_e8f1e7e78f70_ce5650b735ce", - }, TestCase { - client_hello: vec![0x3, 0x3, 0xf6, 0x65, 0xb, 0x22, 0x13, 0xf1, 0xc3, 0xe9, 0xe7, 0xb3, 0xdc, 0x9, 0xe4, 0x4b, 0xcb, 0x6e, 0x5, 0xaf, 0x8f, 0x2f, 0x41, 0x8d, 0x15, 0xa8, 0x88, 0x46, 0x24, 0x83, 0xca, 0x9, 0x7c, 0x95, 0x20, 0x12, 0xc4, 0x5e, 0x71, 0x8b, 0xb9, 0xc9, 0xa9, 0x37, 0x93, 0x4c, 0x41, 0xa6, 0xe8, 0x9e, 0x8f, 0x15, 0x78, 0x52, 0xe, 0x3c, 0x28, 0xba, 0xab, 0xa3, 0x34, 0x8b, 0x53, 0x82, 0x83, 0x75, 0x24, 0x0, 0x3e, 0x13, 0x2, 0x13, 0x3, 0x13, 0x1, 0xc0, 0x2c, 0xc0, 0x30, 0x0, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f, 0x0, 0x9e, 0xc0, 0x24, 0xc0, 0x28, 0x0, 0x6b, 0xc0, 0x23, 0xc0, 0x27, 0x0, 0x67, 0xc0, 0xa, 0xc0, 0x14, 0x0, 0x39, 0xc0, 0x9, 0xc0, 0x13, 0x0, 0x33, 0x0, 0x9d, 0x0, 0x9c, 0x0, 0x3d, 0x0, 0x3c, 0x0, 0x35, 0x0, 0x2f, 0x0, 0xff,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028,c02b,c02c,c02f,c030,cca8,cca9,ccaa_000a,000b,000d,0015,0016,0017,002b,002d,0033,3374_0403,0503,0603,0807,0808,0809,080a,080b,0804,0805,0806,0401,0501,0601,0303,0203,0301,0201,0302,0202,0402,0502,0602", - expected_ja4_hash: "t13d3112h2_e8f1e7e78f70_f4b9272caa35", - }, TestCase { - client_hello: vec![0x3, 0x3, 0x14, 0x67, 0xca, 0x9a, 0xe4, 0x41, 0xc2, 0x31, 0xe7, 0xa4, 0x87, 0xfa, 0x83, 0xdf, 0x5c, 0xe4, 0xa1, 0x9d, 0xa1, 0x42, 0x39, 0xda, 0xd, 0xf0, 0x3e, 0xc3, 0xfb, 0xb3, 0xaf, 0xec, 0x5b, 0x14, 0x20, 0x6e, 0xd5, 0x9f, 0x39, 0x1d, 0x5e, 0x20, 0x51, 0x38, 0xdc, 0x63, 0x5d, 0xe0, 0xbf, 0x1b, 0xff, 0xa0, 0x3d, 0xde, 0x20, 0x59, 0x33, 0x40, 0x30, 0x6e, 0x31, 0x2c, 0xdf, 0x8e, 0x7a, 0xd5, 0xe9, 0x0, 0x22, 0x13, 0x1, 0x13, 0x3, 0x13, 0x2, 0xc0, 0x2b, 0xc0, 0x2f, 0xcc, 0xa9, 0xcc, 0xa8, 0xc0, 0x2c, 0xc0, 0x30, 0xc0, 0xa, 0xc0, 0x9, 0xc0, 0x13, 0xc0, 0x14, 0x0, 0x9c, 0x0, 0x9d, 0x0, 0x2f, 0x0, 0x35, 0x1, 0x0, 0x6, 0xf2, 0x0, 0x0, 0x0, 0x12, 0x0, 0x10, 0x0, 0x0, 0xd, 0x72, 0x61, 0x6d, 0x61, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x6f, 0x72, 0x67, 0x0, 0x17, 0x0, 0x0, 0xff, 0x1, 0x0, 0x1, 0x0, 0x0, 0xa, 0x0, 0x10, 0x0, 0xe, 0x11, 0xec, 0x0, 0x1d, 0x0, 0x17, 0x0, 0x18, 0x0, 0x19, 0x1, 0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, 0x14, 0x42, 0x3, 0x74, 0x9, 0xd3, 0xd3, 0xb, 0xfb, 0x6, 0xf3, 0xcb, 0x37, 0x41, 0xc3, 0x13, 0xd6, 0xca, 0x9b, 0x53, 0x17, 0x22, 0xfd, 0x52, 0xdf, 0x28, 0x9e, 0x13, 0xd8, 0xfd, 0x95, 0x3b, 0xb1, 0x5a, 0xc8, 0x14, 0x23, 0xb, 0x4b, 0xf, 0x22, 0x85, 0xe7, 0x1c, 0x3b, 0xbc, 0xd3], - negotiated_protocol_version: Some(ProtocolVersion::TLSv1_3), - pcap: "wireshark_macos_firefox_133_ramaproxy.org.pcap", - expected_ja4_str: "t13d1716h2_002f,0035,009c,009d,1301,1302,1303,c009,c00a,c013,c014,c02b,c02c,c02f,c030,cca8,cca9_0005,000a,000b,000d,0017,001b,001c,0022,0023,002b,002d,0033,fe0d,ff01_0403,0503,0603,0804,0805,0806,0401,0501,0601,0203,0201", - expected_ja4_hash: "t13d1716h2_5b57614c22b0_eeeea6562960", - }]; + let test_cases = [ + TestCase { + client_hello: vec![ + 0x3, 0x3, 0x86, 0xad, 0xa4, 0xcc, 0x19, 0xe7, 0x14, 0x54, 0x54, 0xfd, 0xe7, + 0x37, 0x33, 0xdf, 0x66, 0xcb, 0xf6, 0xef, 0x3e, 0xc0, 0xa1, 0x54, 0xc6, 0xdd, + 0x14, 0x5e, 0xc0, 0x83, 0xac, 0xb9, 0xb4, 0xe7, 0x20, 0x1c, 0x64, 0xae, 0xa7, + 0xa2, 0xc3, 0xe1, 0x8c, 0xd1, 0x25, 0x2, 0x4d, 0xf7, 0x86, 0x4a, 0xc7, 0x19, + 0xd0, 0xc4, 0xbd, 0xfb, 0x40, 0xc2, 0xef, 0x7f, 0x6d, 0xd3, 0x9a, 0xa7, 0x53, + 0xdf, 0xdd, 0x0, 0x22, 0x1a, 0x1a, 0x13, 0x1, 0x13, 0x2, 0x13, 0x3, 0xc0, 0x2b, + 0xc0, 0x2f, 0xc0, 0x2c, 0xc0, 0x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+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + ], + negotiated_protocol_version: Some(ProtocolVersion::TLSv1_3), + pcap: "chrome-grease-single.pcap", + expected_ja4_str: "t13d1615h2_000a,002f,0035,009c,009d,1301,1302,1303,c013,c014,c02b,c02c,c02f,c030,cca8,cca9_0005,000a,000b,000d,0012,0015,0017,001b,0023,002b,002d,0033,ff01_0403,0804,0401,0503,0805,0501,0806,0601,0201", + expected_ja4_hash: "t13d1615h2_46e7e9700bed_45f260be83e2", + }, + TestCase { + client_hello: vec![ + 0x03, 0x03, 0x95, 0xb9, 0xc5, 0xa1, 0x35, 0x0d, 0xc2, 0x47, 0x9d, 0x37, 0x77, + 0x94, 0x51, 0x39, 0x08, 0xc1, 0x67, 0x43, 0x08, 0xa4, 0x53, 0xb3, 0x18, 0x7e, + 0x0c, 0xde, 0x18, 0xd6, 0x77, 0x1d, 0xd7, 0x0c, 0x20, 0x5b, 0x41, 0xe2, 0xb4, + 0xe3, 0x28, 0x26, 0xfd, 0x1a, 0x14, 0xab, 0x14, 0x04, 0x0b, 0xe2, 0xe1, 0x66, + 0x12, 0xbd, 0x44, 0x41, 0x38, 0xcd, 0xb3, 0xcf, 0xa1, 0x44, 0xe0, 0xa4, 0xf7, + 0x5d, 0x90, 0x00, 0x3e, 0x13, 0x02, 0x13, 0x03, 0x13, 0x01, 0xc0, 0x2c, 0xc0, + 0x30, 0x00, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f, + 0x00, 0x9e, 0xc0, 0x24, 0xc0, 0x28, 0x00, 0x6b, 0xc0, 0x23, 0xc0, 0x27, 0x00, + 0x67, 0xc0, 0x0a, 0xc0, 0x14, 0x00, 0x39, 0xc0, 0x09, 0xc0, 0x13, 0x00, 0x33, + 0x00, 0x9d, 0x00, 0x9c, 0x00, 0x3d, 0x00, 0x3c, 0x00, 0x35, 0x00, 0x2f, 0x00, + 0xff, 0x01, 0x00, 0x01, 0x75, 0x00, 0x00, 0x00, 0x17, 0x00, 0x15, 0x00, 0x00, + 0x12, 0x65, 0x63, 0x68, 0x6f, 0x2e, 0x72, 0x61, 0x6d, 0x61, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x6f, 0x72, 0x67, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, + 0x02, 0x00, 0x0a, 0x00, 0x16, 0x00, 0x14, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x1e, + 0x00, 0x19, 0x00, 0x18, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x01, + 0x04, 0x33, 0x74, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x09, 0x08, 0x68, + 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, + 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x2a, 0x00, 0x28, 0x04, + 0x03, 0x05, 0x03, 0x06, 0x03, 0x08, 0x07, 0x08, 0x08, 0x08, 0x09, 0x08, 0x0a, + 0x08, 0x0b, 0x08, 0x04, 0x08, 0x05, 0x08, 0x06, 0x04, 0x01, 0x05, 0x01, 0x06, + 0x01, 0x03, 0x03, 0x03, 0x01, 0x03, 0x02, 0x04, 0x02, 0x05, 0x02, 0x06, 0x02, + 0x00, 0x2b, 0x00, 0x05, 0x04, 0x03, 0x04, 0x03, 0x03, 0x00, 0x2d, 0x00, 0x02, + 0x01, 0x01, 0x00, 0x33, 0x00, 0x26, 0x00, 0x24, 0x00, 0x1d, 0x00, 0x20, 0xe3, + 0x86, 0xb6, 0x7d, 0x52, 0x0e, 0xd1, 0x7f, 0xbe, 0xed, 0xc0, 0xe8, 0xd9, 0x94, + 0x4a, 0x7b, 0xff, 0xb8, 0xa0, 0x13, 0xa8, 0x5f, 0xbd, 0x2b, 0x10, 0x51, 0xa1, + 0x3f, 0xb2, 0xe3, 0x37, 0x5d, 0x00, 0x15, 0x00, 0xae, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, + ], + negotiated_protocol_version: Some(ProtocolVersion::TLSv1_3), + pcap: "curl_http1.1.pcap", + expected_ja4_str: "t13d3113h1_002f,0033,0035,0039,003c,003d,0067,006b,009c,009d,009e,009f,00ff,1301,1302,1303,c009,c00a,c013,c014,c023,c024,c027,c028,c02b,c02c,c02f,c030,cca8,cca9,ccaa_000a,000b,000d,0015,0016,0017,002b,002d,0031,0033,3374_0403,0503,0603,0807,0808,0809,080a,080b,0804,0805,0806,0401,0501,0601,0303,0301,0302,0402,0502,0602", + expected_ja4_hash: "t13d3113h1_e8f1e7e78f70_ce5650b735ce", + }, + TestCase { + client_hello: vec![ + 0x3, 0x3, 0xf6, 0x65, 0xb, 0x22, 0x13, 0xf1, 0xc3, 0xe9, 0xe7, 0xb3, 0xdc, 0x9, + 0xe4, 0x4b, 0xcb, 0x6e, 0x5, 0xaf, 0x8f, 0x2f, 0x41, 0x8d, 0x15, 0xa8, 0x88, + 0x46, 0x24, 0x83, 0xca, 0x9, 0x7c, 0x95, 0x20, 0x12, 0xc4, 0x5e, 0x71, 0x8b, + 0xb9, 0xc9, 0xa9, 0x37, 0x93, 0x4c, 0x41, 0xa6, 0xe8, 0x9e, 0x8f, 0x15, 0x78, + 0x52, 0xe, 0x3c, 0x28, 0xba, 0xab, 0xa3, 0x34, 0x8b, 0x53, 0x82, 0x83, 0x75, + 0x24, 0x0, 0x3e, 0x13, 0x2, 0x13, 0x3, 0x13, 0x1, 0xc0, 0x2c, 0xc0, 0x30, 0x0, + 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f, 0x0, 0x9e, + 0xc0, 0x24, 0xc0, 0x28, 0x0, 0x6b, 0xc0, 0x23, 0xc0, 0x27, 0x0, 0x67, 0xc0, + 0xa, 0xc0, 0x14, 0x0, 0x39, 0xc0, 0x9, 0xc0, 0x13, 0x0, 0x33, 0x0, 0x9d, 0x0, + 0x9c, 0x0, 0x3d, 0x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,0035,0039,003c,003d,0067,006b,009c,009d,009e,009f,00ff,1301,1302,1303,c009,c00a,c013,c014,c023,c024,c027,c028,c02b,c02c,c02f,c030,cca8,cca9,ccaa_000a,000b,000d,0015,0016,0017,002b,002d,0033,3374_0403,0503,0603,0807,0808,0809,080a,080b,0804,0805,0806,0401,0501,0601,0303,0203,0301,0201,0302,0202,0402,0502,0602", + expected_ja4_hash: "t13d3112h2_e8f1e7e78f70_f4b9272caa35", + }, + TestCase { + client_hello: vec![ + 0x3, 0x3, 0x14, 0x67, 0xca, 0x9a, 0xe4, 0x41, 0xc2, 0x31, 0xe7, 0xa4, 0x87, + 0xfa, 0x83, 0xdf, 0x5c, 0xe4, 0xa1, 0x9d, 0xa1, 0x42, 0x39, 0xda, 0xd, 0xf0, + 0x3e, 0xc3, 0xfb, 0xb3, 0xaf, 0xec, 0x5b, 0x14, 0x20, 0x6e, 0xd5, 0x9f, 0x39, + 0x1d, 0x5e, 0x20, 0x51, 0x38, 0xdc, 0x63, 0x5d, 0xe0, 0xbf, 0x1b, 0xff, 0xa0, + 0x3d, 0xde, 0x20, 0x59, 0x33, 0x40, 0x30, 0x6e, 0x31, 0x2c, 0xdf, 0x8e, 0x7a, + 0xd5, 0xe9, 0x0, 0x22, 0x13, 0x1, 0x13, 0x3, 0x13, 0x2, 0xc0, 0x2b, 0xc0, 0x2f, + 0xcc, 0xa9, 0xcc, 0xa8, 0xc0, 0x2c, 0xc0, 0x30, 0xc0, 0xa, 0xc0, 0x9, 0xc0, + 0x13, 0xc0, 0x14, 0x0, 0x9c, 0x0, 0x9d, 0x0, 0x2f, 0x0, 0x35, 0x1, 0x0, 0x6, + 0xf2, 0x0, 0x0, 0x0, 0x12, 0x0, 0x10, 0x0, 0x0, 0xd, 0x72, 0x61, 0x6d, 0x61, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x6f, 0x72, 0x67, 0x0, 0x17, 0x0, 0x0, + 0xff, 0x1, 0x0, 0x1, 0x0, 0x0, 0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83, 0xb8, 0xd2, 0xb3, 0x97, 0xc1, + 0x26, 0x44, 0x3a, 0x22, 0x55, 0xe9, 0x7f, 0x4c, 0x3f, 0xf5, 0xac, 0xf1, 0xd2, + 0x95, 0x94, 0xa7, 0x2a, 0x33, 0x20, 0x53, 0xcc, 0xac, 0xd6, 0xd6, 0x89, 0x84, + 0xed, 0xcf, 0xc9, 0x6f, 0x85, 0x2a, 0x14, 0x42, 0x3, 0x74, 0x9, 0xd3, 0xd3, + 0xb, 0xfb, 0x6, 0xf3, 0xcb, 0x37, 0x41, 0xc3, 0x13, 0xd6, 0xca, 0x9b, 0x53, + 0x17, 0x22, 0xfd, 0x52, 0xdf, 0x28, 0x9e, 0x13, 0xd8, 0xfd, 0x95, 0x3b, 0xb1, + 0x5a, 0xc8, 0x14, 0x23, 0xb, 0x4b, 0xf, 0x22, 0x85, 0xe7, 0x1c, 0x3b, 0xbc, + 0xd3, + ], + negotiated_protocol_version: Some(ProtocolVersion::TLSv1_3), + pcap: "wireshark_macos_firefox_133_ramaproxy.org.pcap", + expected_ja4_str: "t13d1716h2_002f,0035,009c,009d,1301,1302,1303,c009,c00a,c013,c014,c02b,c02c,c02f,c030,cca8,cca9_0005,000a,000b,000d,0017,001b,001c,0022,0023,002b,002d,0033,fe0d,ff01_0403,0503,0603,0804,0805,0806,0401,0501,0601,0203,0201", + expected_ja4_hash: "t13d1716h2_5b57614c22b0_eeeea6562960", + }, + ]; for test_case in test_cases { let mut ext = Extensions::new(); ext.insert(SecureTransport::with_client_hello( diff --git a/rama-net/src/forwarded/element/parser.rs b/rama-net/src/forwarded/element/parser.rs index 30a49e8f7..3a8f1f8b0 100644 --- a/rama-net/src/forwarded/element/parser.rs +++ b/rama-net/src/forwarded/element/parser.rs @@ -140,7 +140,9 @@ fn parse_next_forwarded_element( // > // > remark: we do not apply any validation here if !quoted && value.contains(['[', ']', ':']) { - return Err(OpaqueError::from_display(format!("Forwarded Element pair's value was expected to be a quoted string due to the chars it contains: {value}"))); + return Err(OpaqueError::from_display(format!( + "Forwarded Element pair's value was expected to be a quoted string due to the chars it contains: {value}" + ))); } match_ignore_ascii_case_str! { diff --git a/rama-net/src/forwarded/mod.rs b/rama-net/src/forwarded/mod.rs index e807789f1..840fe6c74 100644 --- a/rama-net/src/forwarded/mod.rs +++ b/rama-net/src/forwarded/mod.rs @@ -8,9 +8,9 @@ use std::{fmt, net::SocketAddr}; #[cfg(feature = "http")] use rama_http_types::{ + HeaderName, HeaderValue, header::FORWARDED, headers::{self, Header}, - HeaderName, HeaderValue, }; mod obfuscated; @@ -386,10 +386,12 @@ mod tests { r##"for=192.0.2.43,for=198.51.100.17;by=203.0.113.60;proto=http;host=example.com"##, Forwarded { first: ForwardedElement::forwarded_for(NodeId::try_from("192.0.2.43").unwrap()), - others: vec![ForwardedElement::try_from( - "for=198.51.100.17;by=203.0.113.60;proto=http;host=example.com", - ) - .unwrap()], + others: vec![ + ForwardedElement::try_from( + "for=198.51.100.17;by=203.0.113.60;proto=http;host=example.com", + ) + .unwrap(), + ], }, ), ( @@ -398,10 +400,12 @@ mod tests { first: ForwardedElement::forwarded_for( NodeId::try_from("192.0.2.43:4000").unwrap(), ), - others: vec![ForwardedElement::try_from( - "for=198.51.100.17;by=203.0.113.60;proto=http;host=example.com", - ) - .unwrap()], + others: vec![ + ForwardedElement::try_from( + "for=198.51.100.17;by=203.0.113.60;proto=http;host=example.com", + ) + .unwrap(), + ], }, ), ] { diff --git a/rama-net/src/forwarded/node.rs b/rama-net/src/forwarded/node.rs index 9740d8f94..246b93a12 100644 --- a/rama-net/src/forwarded/node.rs +++ b/rama-net/src/forwarded/node.rs @@ -481,44 +481,73 @@ mod tests { "foo:_b+r", "😀", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", - ] { let node_result = s.parse::(); - assert!(node_result.is_err(), "parse invalid: {}; parsed: {:?}", s, node_result); + assert!( + node_result.is_err(), + "parse invalid: {}; parsed: {:?}", + s, + node_result + ); } } #[test] fn test_parse_node_id_lossy() { for (s, expected) in [ - ("", NodeId { - name: NodeName::Obf(ObfNode::from_static("_")), - port: None, - }), - ("@", NodeId { - name: NodeName::Obf(ObfNode::from_static("_")), - port: None, - }), - ("2001:db8:3333:4444:5555:6666:7777:8888:80", NodeId { - name: NodeName::Obf(ObfNode::from_static("2001_db8_3333_4444_5555_6666_7777_8888_80")), - port: None, - }), - ("foo:bar", NodeId { - name: NodeName::Obf(ObfNode::from_static("foo")), - port: Some(NodePort::Obf(ObfPort::from_static("_bar"))), - }), - ("foo:_b+r", NodeId { - name: NodeName::Obf(ObfNode::from_static("foo")), - port: Some(NodePort::Obf(ObfPort::from_static("_b_r"))), - }), - ("😀", NodeId { - name: NodeName::Obf(ObfNode::from_static("____")), - port: None, - }), - ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", NodeId { - name: NodeName::Obf(ObfNode::from_static("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv")), - port: None, - }), + ( + "", + NodeId { + name: NodeName::Obf(ObfNode::from_static("_")), + port: None, + }, + ), + ( + "@", + NodeId { + name: NodeName::Obf(ObfNode::from_static("_")), + port: None, + }, + ), + ( + "2001:db8:3333:4444:5555:6666:7777:8888:80", + NodeId { + name: NodeName::Obf(ObfNode::from_static( + "2001_db8_3333_4444_5555_6666_7777_8888_80", + )), + port: None, + }, + ), + ( + "foo:bar", + NodeId { + name: NodeName::Obf(ObfNode::from_static("foo")), + port: Some(NodePort::Obf(ObfPort::from_static("_bar"))), + }, + ), + ( + "foo:_b+r", + NodeId { + name: NodeName::Obf(ObfNode::from_static("foo")), + port: Some(NodePort::Obf(ObfPort::from_static("_b_r"))), + }, + ), + ( + "😀", + NodeId { + name: NodeName::Obf(ObfNode::from_static("____")), + port: None, + }, + ), + ( + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", + NodeId { + name: NodeName::Obf(ObfNode::from_static( + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv", + )), + port: None, + }, + ), ] { let node_id = NodeId::from_str_lossy(s); assert_eq!(node_id, expected, "parse str: {}", s); diff --git a/rama-net/src/forwarded/obfuscated.rs b/rama-net/src/forwarded/obfuscated.rs index 7260c9a1f..7e5c1fba0 100644 --- a/rama-net/src/forwarded/obfuscated.rs +++ b/rama-net/src/forwarded/obfuscated.rs @@ -207,11 +207,7 @@ const fn is_valid_obf_node(s: &[u8]) -> bool { } fn fix_obf_node(vec: Vec) -> Vec { - if vec.is_empty() { - vec![b'_'] - } else { - vec - } + if vec.is_empty() { vec![b'_'] } else { vec } } /// The maximum length of an obf string. @@ -291,13 +287,13 @@ mod tests { ("@", "_"), ("wh@t", "wh_t"), ("😀", "____"), - ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv"), + ( + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv", + ), ] { assert_eq!(ObfNode::from_str_lossy(str), expected); - assert_eq!( - ObfNode::from_bytes_lossy(str.as_bytes().to_vec()), - expected - ); + assert_eq!(ObfNode::from_bytes_lossy(str.as_bytes().to_vec()), expected); } } @@ -348,13 +344,13 @@ mod tests { ("@", "__"), ("wh@t", "_wh_t"), ("😀", "_____"), - ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "_abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu"), + ( + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", + "_abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu", + ), ] { assert_eq!(ObfPort::from_str_lossy(str), expected); - assert_eq!( - ObfPort::from_bytes_lossy(str.as_bytes().to_vec()), - expected - ); + assert_eq!(ObfPort::from_bytes_lossy(str.as_bytes().to_vec()), expected); } } diff --git a/rama-net/src/http/request_context.rs b/rama-net/src/http/request_context.rs index 54e45c6f0..ecb286d48 100644 --- a/rama-net/src/http/request_context.rs +++ b/rama-net/src/http/request_context.rs @@ -1,13 +1,13 @@ use crate::forwarded::Forwarded; use crate::transport::{TransportContext, TransportProtocol, TryRefIntoTransportContext}; use crate::{ - address::{Authority, Host}, Protocol, + address::{Authority, Host}, }; -use rama_core::error::OpaqueError; use rama_core::Context; +use rama_core::error::OpaqueError; use rama_http_types::Method; -use rama_http_types::{dep::http::request::Parts, Request, Uri, Version}; +use rama_http_types::{Request, Uri, Version, dep::http::request::Parts}; use tracing::{trace, warn}; #[cfg(feature = "tls")] diff --git a/rama-net/src/proto.rs b/rama-net/src/proto.rs index c248bcbee..d1d6e50e2 100644 --- a/rama-net/src/proto.rs +++ b/rama-net/src/proto.rs @@ -482,7 +482,10 @@ mod tests { ("example.com", Some((None, 0))), ("127.0.0.1", Some((None, 0))), ("127.0.0.1:8080", Some((None, 0))), - ("longlonglongwaytoolongforsomethingusefulorvaliddontyouthinkmydearreader://example.com", None), + ( + "longlonglongwaytoolongforsomethingusefulorvaliddontyouthinkmydearreader://example.com", + None, + ), ] { let result = try_to_extract_protocol_from_uri_scheme(s.as_bytes()); match expected { diff --git a/rama-net/src/stream/layer/opentelemetry.rs b/rama-net/src/stream/layer/opentelemetry.rs index 5538d8831..5b8f13fe4 100644 --- a/rama-net/src/stream/layer/opentelemetry.rs +++ b/rama-net/src/stream/layer/opentelemetry.rs @@ -9,12 +9,12 @@ use rama_core::telemetry::opentelemetry::semantic_conventions::resource::{ use rama_core::telemetry::opentelemetry::semantic_conventions::trace::{ NETWORK_TRANSPORT, NETWORK_TYPE, }; +use rama_core::telemetry::opentelemetry::{AttributesFactory, MeterOptions, ServiceInfo}; use rama_core::telemetry::opentelemetry::{ - global, + InstrumentationScope, KeyValue, global, metrics::{Counter, Histogram, Meter}, - semantic_conventions, InstrumentationScope, KeyValue, + semantic_conventions, }; -use rama_core::telemetry::opentelemetry::{AttributesFactory, MeterOptions, ServiceInfo}; use rama_core::{Context, Layer, Service}; use rama_utils::macros::define_inner_service_accessors; use std::borrow::Cow; @@ -271,15 +271,21 @@ mod tests { fn test_default_svc_compute_attributes_default() { let svc = NetworkMetricsService::new(()); let attributes = svc.compute_attributes(&Context::default()); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT)); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT) + ); } #[test] @@ -295,15 +301,21 @@ mod tests { .layer(()); let attributes = svc.compute_attributes(&Context::default()); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT)); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT) + ); } #[test] @@ -320,18 +332,26 @@ mod tests { .layer(()); let attributes = svc.compute_attributes(&Context::default()); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn")); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn") + ); } #[test] @@ -352,17 +372,25 @@ mod tests { .layer(()); let attributes = svc.compute_attributes(&Context::default()); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42")); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT)); - assert!(attributes - .iter() - .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn")); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_NAME && attr.value.as_str() == "test") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == SERVICE_VERSION && attr.value.as_str() == "42") + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == NETWORK_TRANSPORT) + ); + assert!( + attributes + .iter() + .any(|attr| attr.key.as_str() == "test" && attr.value.as_str() == "attribute_fn") + ); } } diff --git a/rama-net/src/stream/layer/tracker/bytes.rs b/rama-net/src/stream/layer/tracker/bytes.rs index 6757e04b0..80ec71f3b 100644 --- a/rama-net/src/stream/layer/tracker/bytes.rs +++ b/rama-net/src/stream/layer/tracker/bytes.rs @@ -13,8 +13,8 @@ use std::{ fmt, io, pin::Pin, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, task::{Context, Poll}, }; @@ -119,7 +119,8 @@ where } std::cmp::Ordering::Less => { tracing::error!( - "BytesRWTracker: poll_read returned Ok(()) with filled buffer smaller then before"); + "BytesRWTracker: poll_read returned Ok(()) with filled buffer smaller then before" + ); } std::cmp::Ordering::Equal => { tracing::trace!("BytesRWTracker: poll_read returned Ok(()) with nothing read"); diff --git a/rama-net/src/stream/matcher/ip.rs b/rama-net/src/stream/matcher/ip.rs index 8ffeabe7e..4134d1065 100644 --- a/rama-net/src/stream/matcher/ip.rs +++ b/rama-net/src/stream/matcher/ip.rs @@ -2,7 +2,7 @@ pub use crate::stream::dep::ipnet::{IpNet, Ipv4Net, Ipv6Net}; -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; #[cfg(feature = "http")] use crate::stream::SocketInfo; diff --git a/rama-net/src/stream/matcher/loopback.rs b/rama-net/src/stream/matcher/loopback.rs index 9dd7177a7..d860d690d 100644 --- a/rama-net/src/stream/matcher/loopback.rs +++ b/rama-net/src/stream/matcher/loopback.rs @@ -1,4 +1,4 @@ -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; #[cfg(feature = "http")] use crate::stream::SocketInfo; diff --git a/rama-net/src/stream/matcher/mod.rs b/rama-net/src/stream/matcher/mod.rs index 261635a37..82dc2bd9a 100644 --- a/rama-net/src/stream/matcher/mod.rs +++ b/rama-net/src/stream/matcher/mod.rs @@ -26,7 +26,7 @@ pub mod ip; #[doc(inline)] pub use ip::IpNetMatcher; -use rama_core::{context::Extensions, matcher::IteratorMatcherExt, Context}; +use rama_core::{Context, context::Extensions, matcher::IteratorMatcherExt}; use std::{fmt, sync::Arc}; #[cfg(feature = "http")] @@ -474,11 +474,7 @@ where req: &Request, ) -> bool { let result = self.kind.matches(ext, ctx, req); - if self.negate { - !result - } else { - result - } + if self.negate { !result } else { result } } } @@ -508,11 +504,7 @@ where { fn matches(&self, ext: Option<&mut Extensions>, ctx: &Context, stream: &Socket) -> bool { let result = self.kind.matches(ext, ctx, stream); - if self.negate { - !result - } else { - result - } + if self.negate { !result } else { result } } } diff --git a/rama-net/src/stream/matcher/port.rs b/rama-net/src/stream/matcher/port.rs index 87192c90f..842718876 100644 --- a/rama-net/src/stream/matcher/port.rs +++ b/rama-net/src/stream/matcher/port.rs @@ -1,4 +1,4 @@ -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; #[cfg(feature = "http")] use crate::stream::SocketInfo; diff --git a/rama-net/src/stream/matcher/private_ip.rs b/rama-net/src/stream/matcher/private_ip.rs index da5e7defe..e516573b6 100644 --- a/rama-net/src/stream/matcher/private_ip.rs +++ b/rama-net/src/stream/matcher/private_ip.rs @@ -1,5 +1,5 @@ use crate::stream::dep::ipnet::IpNet; -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; #[cfg(feature = "http")] use crate::stream::SocketInfo; diff --git a/rama-net/src/stream/matcher/socket.rs b/rama-net/src/stream/matcher/socket.rs index ee7f74778..a5269ce60 100644 --- a/rama-net/src/stream/matcher/socket.rs +++ b/rama-net/src/stream/matcher/socket.rs @@ -1,4 +1,4 @@ -use rama_core::{context::Extensions, Context}; +use rama_core::{Context, context::Extensions}; use std::net::SocketAddr; #[cfg(feature = "http")] diff --git a/rama-net/src/stream/read.rs b/rama-net/src/stream/read.rs index 80e25168b..882321627 100644 --- a/rama-net/src/stream/read.rs +++ b/rama-net/src/stream/read.rs @@ -4,7 +4,7 @@ use std::{ fmt, io::Cursor, pin::Pin, - task::{ready, Context, Poll}, + task::{Context, Poll, ready}, }; use tokio::io::{self, AsyncBufRead, AsyncRead, ReadBuf}; diff --git a/rama-net/src/stream/service/echo.rs b/rama-net/src/stream/service/echo.rs index f9240212d..b4abf2e8e 100644 --- a/rama-net/src/stream/service/echo.rs +++ b/rama-net/src/stream/service/echo.rs @@ -1,7 +1,7 @@ //! An async service which echoes the incoming bytes back on the same stream. use crate::stream::Stream; -use rama_core::{error::BoxError, Context, Service}; +use rama_core::{Context, Service, error::BoxError}; /// An async service which echoes the incoming bytes back on the same stream. /// diff --git a/rama-net/src/tls/client/config.rs b/rama-net/src/tls/client/config.rs index a938a49a1..2c73e9805 100644 --- a/rama-net/src/tls/client/config.rs +++ b/rama-net/src/tls/client/config.rs @@ -1,4 +1,4 @@ -use super::{merge_client_hello_lists, ClientHelloExtension}; +use super::{ClientHelloExtension, merge_client_hello_lists}; use crate::tls::{CipherSuite, CompressionAlgorithm, DataEncoding, KeyLogIntent}; #[derive(Debug, Clone, Default)] diff --git a/rama-net/src/tls/client/hello/mod.rs b/rama-net/src/tls/client/hello/mod.rs index 6d8d67fd3..20191a633 100644 --- a/rama-net/src/tls/client/hello/mod.rs +++ b/rama-net/src/tls/client/hello/mod.rs @@ -1,7 +1,7 @@ use crate::address::Host; use crate::tls::{ - enums::CompressionAlgorithm, ApplicationProtocol, CipherSuite, ECPointFormat, ExtensionId, - ProtocolVersion, SignatureScheme, SupportedGroup, + ApplicationProtocol, CipherSuite, ECPointFormat, ExtensionId, ProtocolVersion, SignatureScheme, + SupportedGroup, enums::CompressionAlgorithm, }; #[cfg(feature = "rustls")] @@ -52,7 +52,7 @@ impl ClientHello { /// See [`ClientHelloExtension::ServerName`] for more information about the server name. pub fn ext_server_name(&self) -> Option<&Host> { for ext in &self.extensions { - if let ClientHelloExtension::ServerName(ref host) = ext { + if let ClientHelloExtension::ServerName(host) = ext { return host.as_ref(); } } @@ -65,7 +65,7 @@ impl ClientHello { /// See [`ClientHelloExtension::SupportedGroups`] for more information about these curves. pub fn ext_supported_groups(&self) -> Option<&[SupportedGroup]> { for ext in &self.extensions { - if let ClientHelloExtension::SupportedGroups(ref groups) = ext { + if let ClientHelloExtension::SupportedGroups(groups) = ext { return Some(&groups[..]); } } @@ -78,7 +78,7 @@ impl ClientHello { /// See [`ClientHelloExtension::ECPointFormats`] for more information about this. pub fn ext_ec_point_formats(&self) -> Option<&[ECPointFormat]> { for ext in &self.extensions { - if let ClientHelloExtension::ECPointFormats(ref formats) = ext { + if let ClientHelloExtension::ECPointFormats(formats) = ext { return Some(&formats[..]); } } @@ -91,7 +91,7 @@ impl ClientHello { /// See [`ClientHelloExtension::SignatureAlgorithms`] for more information about these algorithms pub fn ext_signature_algorithms(&self) -> Option<&[SignatureScheme]> { for ext in &self.extensions { - if let ClientHelloExtension::SignatureAlgorithms(ref algos) = ext { + if let ClientHelloExtension::SignatureAlgorithms(algos) = ext { return Some(&algos[..]); } } @@ -104,7 +104,7 @@ impl ClientHello { /// See [`ClientHelloExtension::ApplicationLayerProtocolNegotiation`] for more information about these protocols (ALPN). pub fn ext_alpn(&self) -> Option<&[ApplicationProtocol]> { for ext in &self.extensions { - if let ClientHelloExtension::ApplicationLayerProtocolNegotiation(ref alpns) = ext { + if let ClientHelloExtension::ApplicationLayerProtocolNegotiation(alpns) = ext { return Some(&alpns[..]); } } @@ -117,7 +117,7 @@ impl ClientHello { /// See [`ClientHelloExtension::SupportedVersions`] for more information about these versions pub fn supported_versions(&self) -> Option<&[ProtocolVersion]> { for ext in &self.extensions { - if let ClientHelloExtension::SupportedVersions(ref versions) = ext { + if let ClientHelloExtension::SupportedVersions(versions) = ext { return Some(&versions[..]); } } diff --git a/rama-net/src/tls/client/parser.rs b/rama-net/src/tls/client/parser.rs index 7128be7bd..1717bf3f3 100644 --- a/rama-net/src/tls/client/parser.rs +++ b/rama-net/src/tls/client/parser.rs @@ -6,15 +6,15 @@ use super::{ClientHello, ClientHelloExtension}; use crate::address::Host; use crate::tls::{ - enums::CompressionAlgorithm, ApplicationProtocol, CipherSuite, ExtensionId, ProtocolVersion, + ApplicationProtocol, CipherSuite, ExtensionId, ProtocolVersion, enums::CompressionAlgorithm, }; use nom::{ + IResult, Parser, bytes::streaming::take, combinator::{complete, cond, map, map_parser, opt, verify}, - error::{make_error, ErrorKind}, + error::{ErrorKind, make_error}, multi::{length_data, many0}, - number::streaming::{be_u16, be_u8}, - IResult, Parser, + number::streaming::{be_u8, be_u16}, }; use rama_core::error::OpaqueError; use std::str; @@ -77,7 +77,7 @@ fn parse_cipher_suites(i: &[u8], len: usize) -> IResult<&[u8], Vec> } let v = (i[..len]) .chunks(2) - .map(|chunk| CipherSuite::from((chunk[0] as u16) << 8 | chunk[1] as u16)) + .map(|chunk| CipherSuite::from(((chunk[0] as u16) << 8) | chunk[1] as u16)) .collect(); Ok((&i[len..], v)) } @@ -276,7 +276,7 @@ fn parse_u16_type>(i: &[u8]) -> IResult<&[u8], Vec> { } let v = (i[..len]) .chunks(2) - .map(|chunk| T::from((chunk[0] as u16) << 8 | chunk[1] as u16)) + .map(|chunk| T::from(((chunk[0] as u16) << 8) | chunk[1] as u16)) .collect(); Ok((&i[len..], v)) } diff --git a/rama-net/src/tls/enums/mod.rs b/rama-net/src/tls/enums/mod.rs index 3596f3cc6..bcaea6e94 100644 --- a/rama-net/src/tls/enums/mod.rs +++ b/rama-net/src/tls/enums/mod.rs @@ -232,7 +232,7 @@ macro_rules! enum_builder { fn from(e: &$enum_name) -> Self { match e { $($enum_name::$enum_var => $enum_val.to_vec()),* - , $enum_name::Unknown(ref v) => v.clone(), + , $enum_name::Unknown(v) => v.clone(), } } } diff --git a/rama-net/src/tls/server/config.rs b/rama-net/src/tls/server/config.rs index 1127828e1..9610290f7 100644 --- a/rama-net/src/tls/server/config.rs +++ b/rama-net/src/tls/server/config.rs @@ -1,6 +1,6 @@ use crate::{ address::Host, - tls::{client::ClientHello, ApplicationProtocol, DataEncoding, KeyLogIntent, ProtocolVersion}, + tls::{ApplicationProtocol, DataEncoding, KeyLogIntent, ProtocolVersion, client::ClientHello}, }; use rama_core::error::OpaqueError; use serde::{Deserialize, Serialize}; diff --git a/rama-net/src/transport.rs b/rama-net/src/transport.rs index 9a4b012b0..98ad4949c 100644 --- a/rama-net/src/transport.rs +++ b/rama-net/src/transport.rs @@ -3,9 +3,9 @@ //! See [`TransportContext`] for the centerpiece of this module. use crate::http::RequestContext; -use crate::{address::Authority, Protocol}; -use rama_core::{error::OpaqueError, Context}; -use rama_http_types::{dep::http::request::Parts as HttpParts, Request, Version}; +use crate::{Protocol, address::Authority}; +use rama_core::{Context, error::OpaqueError}; +use rama_http_types::{Request, Version, dep::http::request::Parts as HttpParts}; #[derive(Debug, Clone, PartialEq, Eq)] /// The context as relevant to the transport layer, diff --git a/rama-net/src/user/auth.rs b/rama-net/src/user/auth.rs index 14447a9b4..dd8c54789 100644 --- a/rama-net/src/user/auth.rs +++ b/rama-net/src/user/auth.rs @@ -2,7 +2,7 @@ use crate::user::{Basic, UserId}; use rama_core::context::Extensions; -use rama_core::username::{parse_username, UsernameLabelParser}; +use rama_core::username::{UsernameLabelParser, parse_username}; use std::future::Future; // TODO: decouple this from http diff --git a/rama-net/src/user/credentials/basic.rs b/rama-net/src/user/credentials/basic.rs index 5b12539b0..4b496eb1d 100644 --- a/rama-net/src/user/credentials/basic.rs +++ b/rama-net/src/user/credentials/basic.rs @@ -1,10 +1,10 @@ -use base64::engine::general_purpose::STANDARD as ENGINE; use base64::Engine; +use base64::engine::general_purpose::STANDARD as ENGINE; use rama_core::error::{ErrorContext, OpaqueError}; use std::borrow::Cow; #[cfg(feature = "http")] -use rama_http_types::{headers::authorization, HeaderValue}; +use rama_http_types::{HeaderValue, headers::authorization}; #[derive(Debug, Clone)] /// Basic credentials. diff --git a/rama-net/src/user/credentials/bearer.rs b/rama-net/src/user/credentials/bearer.rs index a48ab8092..4606635bb 100644 --- a/rama-net/src/user/credentials/bearer.rs +++ b/rama-net/src/user/credentials/bearer.rs @@ -2,7 +2,7 @@ use rama_core::error::{ErrorContext, OpaqueError}; use std::borrow::Cow; #[cfg(feature = "http")] -use rama_http_types::{headers::authorization, HeaderValue}; +use rama_http_types::{HeaderValue, headers::authorization}; #[derive(Debug, Clone, PartialEq, Eq)] /// Bearer credentials. diff --git a/rama-proxy/README.md b/rama-proxy/README.md index 6f82cadd4..f11c8f7a5 100644 --- a/rama-proxy/README.md +++ b/rama-proxy/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-proxy/src/lib.rs b/rama-proxy/src/lib.rs index ca615cecc..7fecc88a7 100644 --- a/rama-proxy/src/lib.rs +++ b/rama-proxy/src/lib.rs @@ -262,7 +262,7 @@ pub use proxydb::layer::{ProxyDBLayer, ProxyDBService, ProxyFilterMode, Username #[cfg(feature = "live-update")] #[doc(inline)] -pub use proxydb::{proxy_db_updater, LiveUpdateProxyDB, LiveUpdateProxyDBSetter}; +pub use proxydb::{LiveUpdateProxyDB, LiveUpdateProxyDBSetter, proxy_db_updater}; #[cfg(feature = "memory-db")] #[doc(inline)] diff --git a/rama-proxy/src/proxydb/csv.rs b/rama-proxy/src/proxydb/csv.rs index 1c6f8a1cc..0dad22e40 100644 --- a/rama-proxy/src/proxydb/csv.rs +++ b/rama-proxy/src/proxydb/csv.rs @@ -215,7 +215,7 @@ impl From for ProxyCsvRowReaderError { #[cfg(test)] mod tests { use super::*; - use crate::{proxydb::ProxyContext, ProxyFilter}; + use crate::{ProxyFilter, proxydb::ProxyContext}; use rama_net::transport::TransportProtocol; use rama_utils::str::NonEmptyString; use std::str::FromStr; @@ -298,7 +298,7 @@ mod tests { ( "id,true,false,true,,false,,true,false,true,authority,pool_id,,country,,city,carrier,,Basic dXNlcm5hbWU6cGFzc3dvcmQ=", Proxy { - id: NonEmptyString::from_static("id"), + id: NonEmptyString::from_static("id"), address: ProxyAddress::from_str("username:password@authority").unwrap(), tcp: true, udp: false, @@ -321,7 +321,7 @@ mod tests { ( "123,1,0,False,,True,,null,false,true,host:1234,,americas,*,*,*,carrier,13335,", Proxy { - id: NonEmptyString::from_static("123"), + id: NonEmptyString::from_static("123"), address: ProxyAddress::from_str("host:1234").unwrap(), tcp: true, udp: false, @@ -344,7 +344,7 @@ mod tests { ( "123,1,0,False,,True,,null,false,true,host:1234,,europe,*,,*,carrier,0", Proxy { - id: NonEmptyString::from_static("123"), + id: NonEmptyString::from_static("123"), address: ProxyAddress::from_str("host:1234").unwrap(), tcp: true, udp: false, @@ -367,7 +367,7 @@ mod tests { ( "foo,1,0,1,,0,,1,0,0,bar,baz,,US,,,,", Proxy { - id: NonEmptyString::from_static("foo"), + id: NonEmptyString::from_static("foo"), address: ProxyAddress::from_str("bar").unwrap(), tcp: true, udp: false, @@ -441,7 +441,9 @@ mod tests { #[tokio::test] async fn test_proxy_csv_row_reader_happy_one_row() { - let mut reader = ProxyCsvRowReader::raw("id,true,false,true,,false,,true,false,true,authority,pool_id,continent,country,state,city,carrier,13335,Basic dXNlcm5hbWU6cGFzc3dvcmQ="); + let mut reader = ProxyCsvRowReader::raw( + "id,true,false,true,,false,,true,false,true,authority,pool_id,continent,country,state,city,carrier,13335,Basic dXNlcm5hbWU6cGFzc3dvcmQ=", + ); let proxy = reader.next().await.unwrap().unwrap(); assert_eq!(proxy.id, "id"); @@ -470,7 +472,9 @@ mod tests { #[tokio::test] async fn test_proxy_csv_row_reader_happy_multi_row() { - let mut reader = ProxyCsvRowReader::raw("id,true,false,false,true,true,false,true,false,true,authority,pool_id,continent,country,state,city,carrier,42,Basic dXNlcm5hbWU6cGFzc3dvcmQ=\nid2,1,0,0,0,0,0,1,0,0,authority2,pool_id2,continent2,country2,state2,city2,carrier2,1"); + let mut reader = ProxyCsvRowReader::raw( + "id,true,false,false,true,true,false,true,false,true,authority,pool_id,continent,country,state,city,carrier,42,Basic dXNlcm5hbWU6cGFzc3dvcmQ=\nid2,1,0,0,0,0,0,1,0,0,authority2,pool_id2,continent2,country2,state2,city2,carrier2,1", + ); let proxy = reader.next().await.unwrap().unwrap(); assert_eq!(proxy.id, "id"); diff --git a/rama-proxy/src/proxydb/internal.rs b/rama-proxy/src/proxydb/internal.rs index ff5668b76..038ebb326 100644 --- a/rama-proxy/src/proxydb/internal.rs +++ b/rama-proxy/src/proxydb/internal.rs @@ -176,7 +176,7 @@ impl Proxy { #[cfg(test)] mod tests { use super::*; - use crate::proxydb::csv::{parse_csv_row, ProxyCsvRowReader}; + use crate::proxydb::csv::{ProxyCsvRowReader, parse_csv_row}; use crate::proxydb::internal::{ProxyDB, ProxyDBErrorKind}; use itertools::Itertools; @@ -347,7 +347,9 @@ mod tests { #[tokio::test] async fn test_proxy_db_invalid_row_cases() { let mut db = ProxyDB::new(); - let mut reader = ProxyCsvRowReader::raw("id1,1,,,,,,,,,authority,,,,,,,\nid2,,1,,,,,,,,authority,,,,,,,\nid3,,1,1,,,,,,,authority,,,,,,,\nid4,,1,1,,,,,1,,authority,,,,,,,\nid5,,1,1,,,,,1,,authority,,,,,,,"); + let mut reader = ProxyCsvRowReader::raw( + "id1,1,,,,,,,,,authority,,,,,,,\nid2,,1,,,,,,,,authority,,,,,,,\nid3,,1,1,,,,,,,authority,,,,,,,\nid4,,1,1,,,,,1,,authority,,,,,,,\nid5,,1,1,,,,,1,,authority,,,,,,,", + ); while let Some(proxy) = reader.next().await.unwrap() { assert_eq!( ProxyDBErrorKind::InvalidRow, diff --git a/rama-proxy/src/proxydb/layer.rs b/rama-proxy/src/proxydb/layer.rs index 1b04262a9..87ef0949f 100644 --- a/rama-proxy/src/proxydb/layer.rs +++ b/rama-proxy/src/proxydb/layer.rs @@ -1,13 +1,13 @@ use super::{Proxy, ProxyContext, ProxyDB, ProxyFilter, ProxyQueryPredicate}; use rama_core::{ - error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, Context, Layer, Service, + error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, }; use rama_net::{ + Protocol, address::ProxyAddress, transport::{TransportProtocol, TryRefIntoTransportContext}, user::{Basic, ProxyCredential}, - Protocol, }; use rama_utils::macros::define_inner_service_accessors; use std::fmt; @@ -507,9 +507,9 @@ mod tests { use rama_core::service::service_fn; use rama_http_types::{Body, Request, Version}; use rama_net::{ + Protocol, address::{Authority, ProxyAddress}, asn::Asn, - Protocol, }; use rama_utils::str::NonEmptyString; use std::{convert::Infallible, str::FromStr, sync::Arc}; @@ -895,7 +895,11 @@ mod tests { })); for (filter, expected_addresses, req_info) in [ - (None, "0.20.204.227:8373,104.207.92.167:9387,105.150.55.60:4898,106.213.197.28:9110,113.6.21.212:4525,115.29.251.35:5712,119.146.94.132:7851,129.204.152.130:6524,134.190.189.202:5772,136.186.95.10:7095,137.220.180.169:4929,140.249.154.18:5800,145.57.31.149:6304,151.254.135.9:6961,153.206.209.221:8696,162.97.174.152:1673,169.179.161.206:6843,171.174.56.89:5744,178.189.117.217:6496,182.34.76.182:2374,184.209.230.177:1358,193.188.239.29:3541,193.26.37.125:3780,204.168.216.113:1096,208.224.120.97:7118,209.176.177.182:4311,215.49.63.89:9458,223.234.242.63:7211,230.159.143.41:7296,233.22.59.115:1653,24.155.249.112:2645,247.118.71.100:1033,249.221.15.121:7434,252.69.242.136:4791,253.138.153.41:2640,28.139.151.127:2809,4.20.243.186:9155,42.54.35.118:6846,45.59.69.12:5934,46.247.45.238:3522,54.226.47.54:7442,61.112.212.160:3842,66.142.40.209:4251,66.171.139.181:4449,69.246.162.84:8964,75.43.123.181:7719,76.128.58.167:4797,85.14.163.105:8362,92.227.104.237:6161,97.192.206.72:6067", (Version::HTTP_11, "GET", "http://example.com")), + ( + None, + "0.20.204.227:8373,104.207.92.167:9387,105.150.55.60:4898,106.213.197.28:9110,113.6.21.212:4525,115.29.251.35:5712,119.146.94.132:7851,129.204.152.130:6524,134.190.189.202:5772,136.186.95.10:7095,137.220.180.169:4929,140.249.154.18:5800,145.57.31.149:6304,151.254.135.9:6961,153.206.209.221:8696,162.97.174.152:1673,169.179.161.206:6843,171.174.56.89:5744,178.189.117.217:6496,182.34.76.182:2374,184.209.230.177:1358,193.188.239.29:3541,193.26.37.125:3780,204.168.216.113:1096,208.224.120.97:7118,209.176.177.182:4311,215.49.63.89:9458,223.234.242.63:7211,230.159.143.41:7296,233.22.59.115:1653,24.155.249.112:2645,247.118.71.100:1033,249.221.15.121:7434,252.69.242.136:4791,253.138.153.41:2640,28.139.151.127:2809,4.20.243.186:9155,42.54.35.118:6846,45.59.69.12:5934,46.247.45.238:3522,54.226.47.54:7442,61.112.212.160:3842,66.142.40.209:4251,66.171.139.181:4449,69.246.162.84:8964,75.43.123.181:7719,76.128.58.167:4797,85.14.163.105:8362,92.227.104.237:6161,97.192.206.72:6067", + (Version::HTTP_11, "GET", "http://example.com"), + ), ( Some(ProxyFilter { country: Some(vec![StringFilter::new("BE")]), diff --git a/rama-proxy/src/proxydb/mod.rs b/rama-proxy/src/proxydb/mod.rs index 478eae9cf..11a69f7d9 100644 --- a/rama-proxy/src/proxydb/mod.rs +++ b/rama-proxy/src/proxydb/mod.rs @@ -8,7 +8,7 @@ use std::{fmt, future::Future}; mod update; #[cfg(feature = "live-update")] #[doc(inline)] -pub use update::{proxy_db_updater, LiveUpdateProxyDB, LiveUpdateProxyDBSetter}; +pub use update::{LiveUpdateProxyDB, LiveUpdateProxyDBSetter, proxy_db_updater}; mod context; pub use context::ProxyContext; @@ -1033,22 +1033,30 @@ mod memdb { ] { let proxy = db.get_proxy(ctx.clone(), filter.clone()).await.unwrap(); assert!(filter.id.map(|id| proxy.id == id).unwrap_or(true)); - assert!(filter - .pool_id - .map(|pool_id| pool_id.contains(proxy.pool_id.as_ref().unwrap())) - .unwrap_or(true)); - assert!(filter - .country - .map(|country| country.contains(proxy.country.as_ref().unwrap())) - .unwrap_or(true)); - assert!(filter - .city - .map(|city| city.contains(proxy.city.as_ref().unwrap())) - .unwrap_or(true)); - assert!(filter - .carrier - .map(|carrier| carrier.contains(proxy.carrier.as_ref().unwrap())) - .unwrap_or(true)); + assert!( + filter + .pool_id + .map(|pool_id| pool_id.contains(proxy.pool_id.as_ref().unwrap())) + .unwrap_or(true) + ); + assert!( + filter + .country + .map(|country| country.contains(proxy.country.as_ref().unwrap())) + .unwrap_or(true) + ); + assert!( + filter + .city + .map(|city| city.contains(proxy.city.as_ref().unwrap())) + .unwrap_or(true) + ); + assert!( + filter + .carrier + .map(|carrier| carrier.contains(proxy.carrier.as_ref().unwrap())) + .unwrap_or(true) + ); } } diff --git a/rama-proxy/src/proxydb/update.rs b/rama-proxy/src/proxydb/update.rs index 099c1d877..49aa74026 100644 --- a/rama-proxy/src/proxydb/update.rs +++ b/rama-proxy/src/proxydb/update.rs @@ -118,7 +118,7 @@ impl fmt::Debug for LiveUpdateProxyDBSetter { #[cfg(test)] mod tests { - use crate::{proxydb::ProxyContext, Proxy, ProxyFilter}; + use crate::{Proxy, ProxyFilter, proxydb::ProxyContext}; use rama_net::{asn::Asn, transport::TransportProtocol}; use rama_utils::str::NonEmptyString; @@ -127,30 +127,34 @@ mod tests { #[tokio::test] async fn test_empty_live_update_db() { let (reader, _) = proxy_db_updater::(); - assert!(reader - .get_proxy( - ProxyContext { - protocol: TransportProtocol::Tcp, - }, - ProxyFilter::default(), - ) - .await - .is_err()); + assert!( + reader + .get_proxy( + ProxyContext { + protocol: TransportProtocol::Tcp, + }, + ProxyFilter::default(), + ) + .await + .is_err() + ); } #[tokio::test] async fn test_live_update_db_updated() { let (reader, writer) = proxy_db_updater(); - assert!(reader - .get_proxy( - ProxyContext { - protocol: TransportProtocol::Tcp, - }, - ProxyFilter::default(), - ) - .await - .is_err()); + assert!( + reader + .get_proxy( + ProxyContext { + protocol: TransportProtocol::Tcp, + }, + ProxyFilter::default(), + ) + .await + .is_err() + ); writer.set(Proxy { id: NonEmptyString::from_static("id"), @@ -187,15 +191,17 @@ mod tests { .id ); - assert!(reader - .get_proxy( - ProxyContext { - protocol: TransportProtocol::Udp, - }, - ProxyFilter::default(), - ) - .await - .is_err()); + assert!( + reader + .get_proxy( + ProxyContext { + protocol: TransportProtocol::Udp, + }, + ProxyFilter::default(), + ) + .await + .is_err() + ); assert_eq!( "id", diff --git a/rama-proxy/src/username.rs b/rama-proxy/src/username.rs index 8ba4a4bbb..64550dc5f 100644 --- a/rama-proxy/src/username.rs +++ b/rama-proxy/src/username.rs @@ -1,7 +1,7 @@ use super::ProxyFilter; use rama_core::{ context::Extensions, - error::{error, OpaqueError}, + error::{OpaqueError, error}, username::{UsernameLabelParser, UsernameLabelState, UsernameLabelWriter}, }; use rama_utils::macros::match_ignore_ascii_case_str; @@ -267,25 +267,21 @@ mod tests { #[test] fn test_username_config() { let test_cases = [ - ( - "john", - String::from("john"), - None, - ), + ("john", String::from("john"), None), ( "john-datacenter", String::from("john"), Some(ProxyFilter { datacenter: Some(true), ..Default::default() - }) + }), ), ( "john-!datacenter", String::from("john"), Some(ProxyFilter { - datacenter: Some(false), - ..Default::default() + datacenter: Some(false), + ..Default::default() }), ), ( @@ -498,7 +494,10 @@ mod tests { "john-continent-europe-continent-asia", String::from("john"), Some(ProxyFilter { - continent: Some(vec![StringFilter::from("europe"), StringFilter::from("asia")]), + continent: Some(vec![ + StringFilter::from("europe"), + StringFilter::from("asia"), + ]), ..Default::default() }), ), diff --git a/rama-socks5/README.md b/rama-socks5/README.md index cc926b31e..04874c9de 100644 --- a/rama-socks5/README.md +++ b/rama-socks5/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-tcp/README.md b/rama-tcp/README.md index ff4c5cb71..1e2973dec 100644 --- a/rama-tcp/README.md +++ b/rama-tcp/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-tcp/src/client/connect.rs b/rama-tcp/src/client/connect.rs index db857d063..7ccccfdc0 100644 --- a/rama-tcp/src/client/connect.rs +++ b/rama-tcp/src/client/connect.rs @@ -1,7 +1,7 @@ use rama_core::{ + Context, combinators::Either, error::{BoxError, ErrorContext, OpaqueError}, - Context, }; use rama_dns::{DnsOverwrite, DnsResolver, HickoryDns}; use rama_net::address::{Authority, Domain, Host}; @@ -11,16 +11,16 @@ use std::{ net::{IpAddr, SocketAddr}, ops::Deref, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, time::Duration, }; use tokio::{ net::TcpStream, sync::{ - mpsc::{channel, Sender}, Semaphore, + mpsc::{Sender, channel}, }, }; @@ -291,11 +291,15 @@ async fn tcp_connect_inner_branch( let sem = match (ip.is_ipv4(), connect_mode) { (true, ConnectIpMode::Ipv6) => { - tracing::trace!("[{ip_kind:?}] #{index}: abort connect loop to {addr} (IPv4 address is not allowed)"); + tracing::trace!( + "[{ip_kind:?}] #{index}: abort connect loop to {addr} (IPv4 address is not allowed)" + ); continue; } (false, ConnectIpMode::Ipv4) => { - tracing::trace!("[{ip_kind:?}] #{index}: abort connect loop to {addr} (IPv6 address is not allowed)"); + tracing::trace!( + "[{ip_kind:?}] #{index}: abort connect loop to {addr} (IPv6 address is not allowed)" + ); continue; } _ => sem.clone(), @@ -314,7 +318,9 @@ async fn tcp_connect_inner_branch( } if connected.load(Ordering::Acquire) { - tracing::trace!("[{ip_kind:?}] #{index}: abort connect loop to {addr} (connection already established)"); + tracing::trace!( + "[{ip_kind:?}] #{index}: abort connect loop to {addr} (connection already established)" + ); return; } @@ -322,7 +328,9 @@ async fn tcp_connect_inner_branch( tokio::spawn(async move { let _permit = sem.acquire().await.unwrap(); if connected.load(Ordering::Acquire) { - tracing::trace!("[{ip_kind:?}] #{index}: abort spawned attempt to {addr} (connection already established)"); + tracing::trace!( + "[{ip_kind:?}] #{index}: abort spawned attempt to {addr} (connection already established)" + ); return; } diff --git a/rama-tcp/src/client/mod.rs b/rama-tcp/src/client/mod.rs index 6c7517e7e..ec678ae54 100644 --- a/rama-tcp/src/client/mod.rs +++ b/rama-tcp/src/client/mod.rs @@ -5,7 +5,7 @@ pub mod service; mod connect; #[doc(inline)] -pub use connect::{default_tcp_connect, tcp_connect, TcpStreamConnector}; +pub use connect::{TcpStreamConnector, default_tcp_connect, tcp_connect}; #[cfg(feature = "http")] mod request; diff --git a/rama-tcp/src/client/request.rs b/rama-tcp/src/client/request.rs index 79197cecb..5e75318a9 100644 --- a/rama-tcp/src/client/request.rs +++ b/rama-tcp/src/client/request.rs @@ -1,9 +1,9 @@ use rama_core::Context; use rama_http_types::Version; use rama_net::{ + Protocol, address::Authority, transport::{TransportContext, TransportProtocol, TryRefIntoTransportContext}, - Protocol, }; use std::convert::Infallible; diff --git a/rama-tcp/src/client/service/connector.rs b/rama-tcp/src/client/service/connector.rs index 02e317e04..d76e0cdc8 100644 --- a/rama-tcp/src/client/service/connector.rs +++ b/rama-tcp/src/client/service/connector.rs @@ -1,6 +1,6 @@ use rama_core::{ - error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, Context, Service, + error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, }; use rama_dns::{DnsResolver, HickoryDns}; use rama_net::{ diff --git a/rama-tcp/src/client/service/forward.rs b/rama-tcp/src/client/service/forward.rs index 43e6261b3..6989799a1 100644 --- a/rama-tcp/src/client/service/forward.rs +++ b/rama-tcp/src/client/service/forward.rs @@ -1,8 +1,8 @@ use super::TcpConnector; use crate::{client::Request as TcpRequest, utils::is_connection_error}; use rama_core::{ - error::{BoxError, ErrorExt, OpaqueError}, Context, Layer, Service, + error::{BoxError, ErrorExt, OpaqueError}, }; use rama_net::{ address::Authority, @@ -137,11 +137,11 @@ where S: Clone + Send + Sync + 'static, T: Stream + Unpin, C: ConnectorService< - S, - crate::client::Request, - Connection: Stream + Unpin, - Error: Into, - >, + S, + crate::client::Request, + Connection: Stream + Unpin, + Error: Into, + >, L: Layer< ForwarderService, Service: Service>, diff --git a/rama-tcp/src/client/service/select.rs b/rama-tcp/src/client/service/select.rs index 5a0552366..62af3a879 100644 --- a/rama-tcp/src/client/service/select.rs +++ b/rama-tcp/src/client/service/select.rs @@ -1,5 +1,5 @@ -use rama_core::error::BoxError; use rama_core::Context; +use rama_core::error::BoxError; use std::fmt; use std::{convert::Infallible, future::Future, sync::Arc}; @@ -67,8 +67,8 @@ pub trait TcpStreamConnectorFactory: Send + Sync + 'static { &self, ctx: Context, ) -> impl Future, Self::Error>> - + Send - + '_; + + Send + + '_; } impl TcpStreamConnectorFactory for () { @@ -79,8 +79,8 @@ impl TcpStreamConnectorFactory for () { &self, ctx: Context, ) -> impl Future, Self::Error>> - + Send - + '_ { + + Send + + '_ { std::future::ready(Ok(CreatedTcpStreamConnector { ctx, connector: () })) } } @@ -125,8 +125,8 @@ where &self, ctx: Context, ) -> impl Future, Self::Error>> - + Send - + '_ { + + Send + + '_ { std::future::ready(Ok(CreatedTcpStreamConnector { ctx, connector: self.0.clone(), @@ -146,8 +146,8 @@ where &self, ctx: Context, ) -> impl Future, Self::Error>> - + Send - + '_ { + + Send + + '_ { (**self).make_connector(ctx) } } diff --git a/rama-tcp/src/server/listener.rs b/rama-tcp/src/server/listener.rs index b403b0e6d..ed7fb83df 100644 --- a/rama-tcp/src/server/listener.rs +++ b/rama-tcp/src/server/listener.rs @@ -1,8 +1,8 @@ +use rama_core::Context; +use rama_core::Service; use rama_core::error::BoxError; use rama_core::graceful::ShutdownGuard; use rama_core::rt::Executor; -use rama_core::Context; -use rama_core::Service; use rama_net::address::SocketAddress; use rama_net::stream::SocketInfo; use std::fmt; diff --git a/rama-tls/README.md b/rama-tls/README.md index e08fe90bb..dc4e5dbc3 100644 --- a/rama-tls/README.md +++ b/rama-tls/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-tls/src/boring/client/connector.rs b/rama-tls/src/boring/client/connector.rs index eb66c4272..2552bee69 100644 --- a/rama-tls/src/boring/client/connector.rs +++ b/rama-tls/src/boring/client/connector.rs @@ -7,8 +7,8 @@ use rama_core::{Context, Layer, Service}; use rama_net::address::Host; use rama_net::client::{ConnectorService, EstablishedClientConnection}; use rama_net::stream::Stream; -use rama_net::tls::client::NegotiatedTlsParameters; use rama_net::tls::ApplicationProtocol; +use rama_net::tls::client::NegotiatedTlsParameters; use rama_net::transport::TryRefIntoTransportContext; use std::fmt; use tokio::io::{AsyncRead, AsyncWrite}; @@ -460,7 +460,7 @@ impl TlsConnector { return Err(OpaqueError::from_display( "boring ssl connector: failed to establish session...", ) - .into_boxed()) + .into_boxed()); } }; diff --git a/rama-tls/src/boring/client/connector_data.rs b/rama-tls/src/boring/client/connector_data.rs index 5cc486037..8e38e1c40 100644 --- a/rama-tls/src/boring/client/connector_data.rs +++ b/rama-tls/src/boring/client/connector_data.rs @@ -6,16 +6,16 @@ use boring::{ rsa::Rsa, ssl::{ConnectConfiguration, SslCurve, SslSignatureAlgorithm, SslVerifyMode, SslVersion}, x509::{ - extension::{BasicConstraints, KeyUsage, SubjectKeyIdentifier}, X509, + extension::{BasicConstraints, KeyUsage, SubjectKeyIdentifier}, }, }; use rama_core::error::{ErrorContext, ErrorExt, OpaqueError}; +use rama_net::tls::{ApplicationProtocol, KeyLogIntent, openssl_cipher_list_str_from_cipher_list}; use rama_net::tls::{ - client::{ClientAuth, ClientHelloExtension}, DataEncoding, + client::{ClientAuth, ClientHelloExtension}, }; -use rama_net::tls::{openssl_cipher_list_str_from_cipher_list, ApplicationProtocol, KeyLogIntent}; use rama_net::{address::Host, tls::client::ServerVerifyMode}; use std::{fmt, sync::Arc}; use tracing::trace; @@ -352,15 +352,23 @@ impl TryFrom for TlsConnectorData { ClientHelloExtension::ServerName(maybe_host) => { server_name = match maybe_host { Some(Host::Name(_)) => { - trace!("TlsConnectorData: builder: from std client config: set server (domain) name from host: {:?}", maybe_host); + trace!( + "TlsConnectorData: builder: from std client config: set server (domain) name from host: {:?}", + maybe_host + ); maybe_host.clone() } Some(Host::Address(_)) => { - trace!("TlsConnectorData: builder: from std client config: set server (ip) name from host: {:?}", maybe_host); + trace!( + "TlsConnectorData: builder: from std client config: set server (ip) name from host: {:?}", + maybe_host + ); maybe_host.clone() } None => { - trace!("TlsConnectorData: builder: from std client config: ignore server null value"); + trace!( + "TlsConnectorData: builder: from std client config: ignore server null value" + ); None } }; @@ -391,7 +399,10 @@ impl TryFrom for TlsConnectorData { }).collect()); } ClientHelloExtension::SupportedVersions(versions) => { - trace!("TlsConnectorData: builder: from std client config: supported versions: {:?}", versions); + trace!( + "TlsConnectorData: builder: from std client config: supported versions: {:?}", + versions + ); if let Some(min_ver) = versions.iter().min() { trace!( @@ -416,7 +427,10 @@ impl TryFrom for TlsConnectorData { } } ClientHelloExtension::SignatureAlgorithms(schemes) => { - trace!("TlsConnectorData: builder: from std client config: signature algorithms: {:?}", schemes); + trace!( + "TlsConnectorData: builder: from std client config: signature algorithms: {:?}", + schemes + ); verify_algorithm_prefs = Some(schemes.iter().filter_map(|s| match (*s).try_into() { Ok(v) => Some(v), Err(s) => { diff --git a/rama-tls/src/boring/server/acceptor_data.rs b/rama-tls/src/boring/server/acceptor_data.rs index f042f2667..33c06d12a 100644 --- a/rama-tls/src/boring/server/acceptor_data.rs +++ b/rama-tls/src/boring/server/acceptor_data.rs @@ -6,8 +6,8 @@ use crate::boring::dep::boring::{ pkey::{PKey, Private}, rsa::Rsa, x509::{ + X509, X509NameBuilder, extension::{BasicConstraints, KeyUsage, SubjectKeyIdentifier}, - X509NameBuilder, X509, }, }; use boring::{ @@ -20,12 +20,12 @@ use rama_core::error::{ErrorContext, OpaqueError}; use rama_net::{ address::{Domain, Host}, tls::{ + ApplicationProtocol, DataEncoding, KeyLogIntent, ProtocolVersion, client::ClientHello as RamaClientHello, server::{ CacheKind, ClientVerifyMode, DynamicIssuer, SelfSignedData, ServerAuth, ServerAuthData, ServerCertIssuerKind, }, - ApplicationProtocol, DataEncoding, KeyLogIntent, ProtocolVersion, }, }; use std::{sync::Arc, time::Duration}; @@ -257,10 +257,11 @@ impl TryFrom for TlsAcceptorData { // no client auth ClientVerifyMode::Auto | ClientVerifyMode::Disable => None, // client auth enabled - ClientVerifyMode::ClientAuth(DataEncoding::Der(bytes)) => Some(vec![X509::from_der( - &bytes[..], - ) - .context("boring/TlsAcceptorData: parse x509 client cert from DER content")?]), + ClientVerifyMode::ClientAuth(DataEncoding::Der(bytes)) => { + Some(vec![X509::from_der(&bytes[..]).context( + "boring/TlsAcceptorData: parse x509 client cert from DER content", + )?]) + } ClientVerifyMode::ClientAuth(DataEncoding::DerStack(bytes_list)) => Some( bytes_list .into_iter() @@ -390,8 +391,10 @@ fn server_auth_data_to_private_key_and_ca_chain( }; let cert_chain = match &data.cert_chain { - DataEncoding::Der(raw_data) => vec![X509::from_der(&raw_data[..]) - .context("boring/TlsAcceptorData: parse x509 server cert from DER content")?], + DataEncoding::Der(raw_data) => vec![ + X509::from_der(&raw_data[..]) + .context("boring/TlsAcceptorData: parse x509 server cert from DER content")?, + ], DataEncoding::DerStack(raw_data_list) => raw_data_list .iter() .map(|raw_data| { diff --git a/rama-tls/src/boring/server/service.rs b/rama-tls/src/boring/server/service.rs index 53180eadf..61f5b76ba 100644 --- a/rama-tls/src/boring/server/service.rs +++ b/rama-tls/src/boring/server/service.rs @@ -9,13 +9,13 @@ use crate::{ }; use parking_lot::Mutex; use rama_core::{ - error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, Context, Service, + error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, }; use rama_net::{ http::RequestContext, stream::Stream, - tls::{client::NegotiatedTlsParameters, ApplicationProtocol, DataEncoding}, + tls::{ApplicationProtocol, DataEncoding, client::NegotiatedTlsParameters}, transport::TransportContext, }; use rama_utils::macros::define_inner_service_accessors; @@ -239,7 +239,7 @@ where return Err(OpaqueError::from_display( "boring ssl acceptor: failed to establish session...", ) - .into_boxed()) + .into_boxed()); } } diff --git a/rama-tls/src/keylog.rs b/rama-tls/src/keylog.rs index 027e5cb37..a91fcc0a6 100644 --- a/rama-tls/src/keylog.rs +++ b/rama-tls/src/keylog.rs @@ -7,7 +7,7 @@ use parking_lot::RwLock; use rama_core::error::{ErrorContext, OpaqueError}; use std::{ - collections::{hash_map::Entry, HashMap}, + collections::{HashMap, hash_map::Entry}, fs::OpenOptions, io::Write, path::{Component, Path, PathBuf}, diff --git a/rama-tls/src/lib.rs b/rama-tls/src/lib.rs index a10b07d9d..2a9842204 100644 --- a/rama-tls/src/lib.rs +++ b/rama-tls/src/lib.rs @@ -35,7 +35,7 @@ pub mod types { //! common tls types #[doc(inline)] pub use ::rama_net::tls::{ - client, ApplicationProtocol, CipherSuite, CompressionAlgorithm, ECPointFormat, ExtensionId, - ProtocolVersion, SecureTransport, SignatureScheme, SupportedGroup, TlsTunnel, + ApplicationProtocol, CipherSuite, CompressionAlgorithm, ECPointFormat, ExtensionId, + ProtocolVersion, SecureTransport, SignatureScheme, SupportedGroup, TlsTunnel, client, }; } diff --git a/rama-tls/src/rustls/client/connector.rs b/rama-tls/src/rustls/client/connector.rs index 168061cbd..bc509be50 100644 --- a/rama-tls/src/rustls/client/connector.rs +++ b/rama-tls/src/rustls/client/connector.rs @@ -1,5 +1,5 @@ use super::TlsConnectorData; -use crate::rustls::dep::tokio_rustls::{client::TlsStream, TlsConnector as RustlsConnector}; +use crate::rustls::dep::tokio_rustls::{TlsConnector as RustlsConnector, client::TlsStream}; use crate::types::TlsTunnel; use pin_project_lite::pin_project; use private::{ConnectorKindAuto, ConnectorKindSecure, ConnectorKindTunnel}; @@ -9,8 +9,8 @@ use rama_core::{Context, Layer, Service}; use rama_net::address::Host; use rama_net::client::{ConnectorService, EstablishedClientConnection}; use rama_net::stream::Stream; -use rama_net::tls::client::NegotiatedTlsParameters; use rama_net::tls::ApplicationProtocol; +use rama_net::tls::client::NegotiatedTlsParameters; use rama_net::transport::TryRefIntoTransportContext; use std::fmt; use std::sync::Arc; diff --git a/rama-tls/src/rustls/client/connector_data.rs b/rama-tls/src/rustls/client/connector_data.rs index 699f6c1eb..93e8fe34c 100644 --- a/rama-tls/src/rustls/client/connector_data.rs +++ b/rama-tls/src/rustls/client/connector_data.rs @@ -1,9 +1,9 @@ use crate::rustls::dep::pemfile; use crate::rustls::dep::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer}; use crate::rustls::dep::rcgen::{self, KeyPair}; -use crate::rustls::dep::rustls::client::danger::ServerCertVerifier; use crate::rustls::dep::rustls::RootCertStore; -use crate::rustls::dep::rustls::{ClientConfig, SupportedProtocolVersion, ALL_VERSIONS}; +use crate::rustls::dep::rustls::client::danger::ServerCertVerifier; +use crate::rustls::dep::rustls::{ALL_VERSIONS, ClientConfig, SupportedProtocolVersion}; use crate::rustls::key_log::KeyLogFile; use crate::rustls::verify::NoServerCertVerifier; use rama_core::error::{ErrorContext, OpaqueError}; @@ -326,8 +326,8 @@ pub(super) fn client_root_certs() -> Arc { .clone() } -fn self_signed_client_auth( -) -> Result<(Vec>, PrivateKeyDer<'static>), OpaqueError> { +fn self_signed_client_auth() +-> Result<(Vec>, PrivateKeyDer<'static>), OpaqueError> { // Create a client end entity cert. let alg = &rcgen::PKCS_ECDSA_P256_SHA256; let client_key_pair = diff --git a/rama-tls/src/rustls/key_log.rs b/rama-tls/src/rustls/key_log.rs index 23be947b3..e19e6b6dd 100644 --- a/rama-tls/src/rustls/key_log.rs +++ b/rama-tls/src/rustls/key_log.rs @@ -1,6 +1,6 @@ use std::fmt; -use crate::keylog::{new_key_log_file_handle, KeyLogFileHandle}; +use crate::keylog::{KeyLogFileHandle, new_key_log_file_handle}; use crate::rustls::dep::rustls::KeyLog; use rama_core::error::OpaqueError; diff --git a/rama-tls/src/rustls/server/acceptor_data.rs b/rama-tls/src/rustls/server/acceptor_data.rs index 2031c44d0..003c62704 100644 --- a/rama-tls/src/rustls/server/acceptor_data.rs +++ b/rama-tls/src/rustls/server/acceptor_data.rs @@ -1,12 +1,12 @@ use crate::rustls::dep::pemfile; use crate::rustls::dep::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer}; use crate::rustls::dep::rcgen::{self, KeyPair}; -use crate::rustls::dep::rustls::{self, server::WebPkiClientVerifier, RootCertStore}; +use crate::rustls::dep::rustls::{self, RootCertStore, server::WebPkiClientVerifier}; use crate::rustls::key_log::KeyLogFile; use rama_core::error::{ErrorContext, OpaqueError}; use rama_net::address::{Domain, Host}; -use rama_net::tls::server::{ClientVerifyMode, SelfSignedData, ServerAuth}; use rama_net::tls::DataEncoding; +use rama_net::tls::server::{ClientVerifyMode, SelfSignedData, ServerAuth}; use std::io::BufReader; use std::sync::Arc; @@ -187,7 +187,9 @@ impl TryFrom for TlsAcceptorData { } ServerAuth::CertIssuer { .. } => { - return Err(OpaqueError::from_display("CertIssuer not supported for Rustls (open an PR with a patch to add support for it if you want this or use boring instead)")); + return Err(OpaqueError::from_display( + "CertIssuer not supported for Rustls (open an PR with a patch to add support for it if you want this or use boring instead)", + )); } }; diff --git a/rama-tls/src/rustls/server/service.rs b/rama-tls/src/rustls/server/service.rs index de7051a6b..8f4fd068a 100644 --- a/rama-tls/src/rustls/server/service.rs +++ b/rama-tls/src/rustls/server/service.rs @@ -1,17 +1,17 @@ use crate::{ rustls::dep::{ rustls::server::Acceptor, - tokio_rustls::{server::TlsStream, LazyConfigAcceptor}, + tokio_rustls::{LazyConfigAcceptor, server::TlsStream}, }, types::SecureTransport, }; use rama_core::{ - error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, Context, Service, + error::{BoxError, ErrorContext, ErrorExt, OpaqueError}, }; use rama_net::{ stream::Stream, - tls::{client::NegotiatedTlsParameters, ApplicationProtocol}, + tls::{ApplicationProtocol, client::NegotiatedTlsParameters}, }; use rama_utils::macros::define_inner_service_accessors; diff --git a/rama-tls/src/rustls/verify.rs b/rama-tls/src/rustls/verify.rs index 5506d3ec7..7c9474628 100644 --- a/rama-tls/src/rustls/verify.rs +++ b/rama-tls/src/rustls/verify.rs @@ -5,8 +5,8 @@ use crate::rustls::dep::{ pki_types::{CertificateDer, ServerName, UnixTime}, rustls::{ - client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}, DigitallySignedStruct, SignatureScheme, + client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}, }, }; diff --git a/rama-ua/README.md b/rama-ua/README.md index ad8a8a188..f202c3870 100644 --- a/rama-ua/README.md +++ b/rama-ua/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-ua/src/info.rs b/rama-ua/src/info.rs index 25c4c441a..6b12217a4 100644 --- a/rama-ua/src/info.rs +++ b/rama-ua/src/info.rs @@ -394,7 +394,10 @@ mod tests { #[test] fn test_user_agent_new() { let ua = UserAgent::new("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36".to_owned()); - assert_eq!(ua.header_str(), "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"); + assert_eq!( + ua.header_str(), + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + ); assert_eq!( ua.info(), Some(UserAgentInfo { @@ -411,7 +414,10 @@ mod tests { #[test] fn test_user_agent_parse() { let ua: UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36".parse().unwrap(); - assert_eq!(ua.header_str(), "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"); + assert_eq!( + ua.header_str(), + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + ); assert_eq!( ua.info(), Some(UserAgentInfo { @@ -428,7 +434,10 @@ mod tests { #[test] fn test_user_agent_display() { let ua: UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36".parse().unwrap(); - assert_eq!(ua.to_string(), "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"); + assert_eq!( + ua.to_string(), + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + ); } #[test] diff --git a/rama-ua/src/parse.rs b/rama-ua/src/parse.rs index 75f2e8dee..7e375ae6a 100644 --- a/rama-ua/src/parse.rs +++ b/rama-ua/src/parse.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] use super::{ - info::{UserAgentData, UserAgentInfo}, DeviceKind, PlatformKind, UserAgent, UserAgentKind, + info::{UserAgentData, UserAgentInfo}, }; /// Maximum length of a User Agent string that we take into consideration. @@ -32,7 +32,7 @@ pub(crate) fn parse_http_user_agent_header(header: String) -> UserAgent { http_agent_overwrite: None, tls_agent_overwrite: None, preserve_ua_header: false, - } + }; } } } else { diff --git a/rama-ua/src/parse_tests.rs b/rama-ua/src/parse_tests.rs index 944634e30..7fc6b229a 100644 --- a/rama-ua/src/parse_tests.rs +++ b/rama-ua/src/parse_tests.rs @@ -377,11 +377,15 @@ fn test_parse_happy_uas() { let ua = UserAgent::new(test_case.ua); assert_eq!(ua.header_str(), test_case.ua); - assert_eq!(ua.info(), test_case.kind.map(|kind| UserAgentInfo { - kind, - version: test_case.version, - }), - "UA = '{}'", test_case.ua); + assert_eq!( + ua.info(), + test_case.kind.map(|kind| UserAgentInfo { + kind, + version: test_case.version, + }), + "UA = '{}'", + test_case.ua + ); assert_eq!(ua.platform(), test_case.platform, "UA: {}", test_case.ua); } } diff --git a/rama-udp/README.md b/rama-udp/README.md index b00ba89ac..81152cf42 100644 --- a/rama-udp/README.md +++ b/rama-udp/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/rama-utils/README.md b/rama-utils/README.md index e7e8ee438..a012495dc 100644 --- a/rama-utils/README.md +++ b/rama-utils/README.md @@ -20,7 +20,7 @@ [license-mit-url]: https://github.com/plabayo/rama/blob/main/LICENSE-MIT [license-apache-badge]: https://img.shields.io/badge/license-APACHE-blue.svg [license-apache-url]: https://github.com/plabayo/rama/blob/main/LICENSE-APACHE -[rust-version-badge]: https://img.shields.io/badge/rustc-1.84+-blue?style=flat-square&logo=rust +[rust-version-badge]: https://img.shields.io/badge/rustc-1.85+-blue?style=flat-square&logo=rust [rust-version-url]: https://www.rust-lang.org [actions-badge]: https://github.com/plabayo/rama/workflows/CI/badge.svg [actions-url]: https://github.com/plabayo/rama/actions diff --git a/src/cli/args.rs b/src/cli/args.rs index 9e297a572..981c8add5 100644 --- a/src/cli/args.rs +++ b/src/cli/args.rs @@ -3,11 +3,11 @@ use crate::{ error::{ErrorContext, OpaqueError}, http::{ - header::{Entry, HeaderValue, ACCEPT, CONTENT_LENGTH, CONTENT_TYPE}, Body, Method, Request, Uri, + header::{ACCEPT, CONTENT_LENGTH, CONTENT_TYPE, Entry, HeaderValue}, }, }; -use rama_http::proto::h1::{headers::original::OriginalHttp1Headers, Http1HeaderName}; +use rama_http::proto::h1::{Http1HeaderName, headers::original::OriginalHttp1Headers}; use rama_utils::macros::match_ignore_ascii_case_str; use serde_json::Value; use std::collections::HashMap; @@ -83,9 +83,9 @@ impl RequestArgsBuilder { body: HashMap::new(), }), BuilderState::Data { - ref mut query, - ref mut headers, - ref mut body, + query, + headers, + body, .. } => match parse_arg_as_data(arg, query, headers, body) { Ok(_) => None, @@ -94,9 +94,7 @@ impl RequestArgsBuilder { ignored: vec![], }), }, - BuilderState::Error { - ref mut ignored, .. - } => { + BuilderState::Error { ignored, .. } => { ignored.push(arg); None } @@ -478,11 +476,7 @@ mod tests { (vec![":8080"], "GET / HTTP/1.1\r\n\r\n"), (vec!["HeAD", ":8000/foo"], "HEAD /foo HTTP/1.1\r\n\r\n"), ( - vec![ - "example.com/bar", - "FOO:bar", - "AnSweR:42", - ], + vec!["example.com/bar", "FOO:bar", "AnSweR:42"], "GET /bar HTTP/1.1\r\nFOO: bar\r\nAnSweR: 42\r\n\r\n", ), ( @@ -494,64 +488,35 @@ mod tests { "POST /foo HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\ncontent-length: 3\r\n\r\nc=d", ), ( - vec![ - "example.com/foo", - "a=b", - "Content-Type:application/json", - ], + vec!["example.com/foo", "a=b", "Content-Type:application/json"], "POST /foo HTTP/1.1\r\nContent-Type: application/json\r\naccept: application/json\r\ncontent-length: 9\r\n\r\n{\"a\":\"b\"}", ), ( - vec![ - "example.com/foo", - "a=b", - ], + vec!["example.com/foo", "a=b"], "POST /foo HTTP/1.1\r\ncontent-type: application/json\r\naccept: application/json\r\ncontent-length: 9\r\n\r\n{\"a\":\"b\"}", ), ( - vec![ - "example.com/foo", - "x-a:1", - "a=b", - ], + vec!["example.com/foo", "x-a:1", "a=b"], "POST /foo HTTP/1.1\r\nx-a: 1\r\ncontent-type: application/json\r\naccept: application/json\r\ncontent-length: 9\r\n\r\n{\"a\":\"b\"}", ), ( - vec![ - "put", - "example.com/foo?a=2", - "x-a:1", - "a:=42", - "a==3" - ], + vec!["put", "example.com/foo?a=2", "x-a:1", "a:=42", "a==3"], "PUT /foo?a=2&a=3 HTTP/1.1\r\nx-a: 1\r\ncontent-type: application/json\r\naccept: application/json\r\ncontent-length: 8\r\n\r\n{\"a\":42}", ), ( - vec![ - ":3000", - "Cookie:foo=bar", - ], + vec![":3000", "Cookie:foo=bar"], "GET / HTTP/1.1\r\nCookie: foo=bar\r\n\r\n", ), ( - vec![ - ":/foo", - "search==rama", - ], + vec![":/foo", "search==rama"], "GET /foo?search=rama HTTP/1.1\r\n\r\n", ), ( - vec![ - "example.com", - "description='CLI HTTP client'", - ], + vec!["example.com", "description='CLI HTTP client'"], "POST / HTTP/1.1\r\ncontent-type: application/json\r\naccept: application/json\r\ncontent-length: 35\r\n\r\n{\"description\":\"'CLI HTTP client'\"}", ), ( - vec![ - "example.com", - "x-cfg:a=1&foo=bar&foo=baz", - ], + vec!["example.com", "x-cfg:a=1&foo=bar&foo=baz"], "GET / HTTP/1.1\r\nx-cfg: a=1&foo=bar&foo=baz\r\n\r\n", ), ] { @@ -570,15 +535,10 @@ mod tests { #[tokio::test] async fn test_request_args_builder_form_happy() { - for (args, expected_request_str) in [ - ( - vec![ - "example.com/foo", - "c=d", - ], - "POST /foo HTTP/1.1\r\ncontent-type: application/x-www-form-urlencoded\r\ncontent-length: 3\r\n\r\nc=d", - ), - ] { + for (args, expected_request_str) in [( + vec!["example.com/foo", "c=d"], + "POST /foo HTTP/1.1\r\ncontent-type: application/x-www-form-urlencoded\r\ncontent-length: 3\r\n\r\nc=d", + )] { let mut builder = RequestArgsBuilder::new_form(); for arg in args { builder.parse_arg(arg.to_owned()); @@ -594,15 +554,10 @@ mod tests { #[tokio::test] async fn test_request_args_builder_json_happy() { - for (args, expected_request_str) in [ - ( - vec![ - "example.com/foo", - "a=b", - ], - "POST /foo HTTP/1.1\r\ncontent-type: application/json\r\naccept: application/json\r\ncontent-length: 9\r\n\r\n{\"a\":\"b\"}", - ), - ] { + for (args, expected_request_str) in [( + vec!["example.com/foo", "a=b"], + "POST /foo HTTP/1.1\r\ncontent-type: application/json\r\naccept: application/json\r\ncontent-length: 9\r\n\r\n{\"a\":\"b\"}", + )] { let mut builder = RequestArgsBuilder::new(); for arg in args { builder.parse_arg(arg.to_owned()); diff --git a/src/cli/service/echo.rs b/src/cli/service/echo.rs index ef90ef8f0..d1d12bedc 100644 --- a/src/cli/service/echo.rs +++ b/src/cli/service/echo.rs @@ -6,10 +6,12 @@ //! [`tls`]: crate::tls use crate::{ + Context, Layer, Service, cli::ForwardKind, combinators::{Either3, Either7}, error::{BoxError, OpaqueError}, http::{ + IntoResponse, Request, Response, Version, dep::http_body_util::BodyExt, headers::{CFConnectingIp, ClientIp, TrueClientIp, XClientIp, XRealIp}, layer::{ @@ -22,16 +24,14 @@ use crate::{ proto::h2::PseudoHeaderOrder, response::Json, server::HttpServer, - IntoResponse, Request, Response, Version, }, - layer::{limit::policy::ConcurrentPolicy, ConsumeErrLayer, LimitLayer, TimeoutLayer}, + layer::{ConsumeErrLayer, LimitLayer, TimeoutLayer, limit::policy::ConcurrentPolicy}, net::fingerprint::Ja4H, net::forwarded::Forwarded, net::http::RequestContext, - net::stream::{layer::http::BodyLimitLayer, SocketInfo}, + net::stream::{SocketInfo, layer::http::BodyLimitLayer}, proxy::haproxy::server::HaProxyLayer, rt::Executor, - Context, Layer, Service, }; use serde_json::json; use std::{convert::Infallible, time::Duration}; @@ -42,7 +42,7 @@ use crate::{ net::fingerprint::{Ja3, Ja4}, net::tls::server::ServerConfig, tls::std::server::TlsAcceptorLayer, - tls::types::{client::ClientHelloExtension, SecureTransport}, + tls::types::{SecureTransport, client::ClientHelloExtension}, }; #[derive(Debug, Clone)] @@ -284,7 +284,7 @@ where Either3::B(HttpServer::http1().service(http_service)) } Some(_) => { - return Err(OpaqueError::from_display("unsupported http version").into_boxed()) + return Err(OpaqueError::from_display("unsupported http version").into_boxed()); } None => Either3::C(HttpServer::auto(executor).service(http_service)), }; diff --git a/src/cli/service/ip.rs b/src/cli/service/ip.rs index 68a92ec07..2cf43021c 100644 --- a/src/cli/service/ip.rs +++ b/src/cli/service/ip.rs @@ -3,24 +3,24 @@ //! [`Service`]: crate::Service use crate::{ + Context, Layer, Service, cli::ForwardKind, combinators::Either7, error::{BoxError, OpaqueError}, http::{ + IntoResponse, Request, Response, StatusCode, headers::{CFConnectingIp, ClientIp, TrueClientIp, XClientIp, XRealIp}, layer::{ forwarded::GetForwardedHeadersLayer, required_header::AddRequiredResponseHeadersLayer, trace::TraceLayer, ua::UserAgentClassifierLayer, }, server::HttpServer, - IntoResponse, Request, Response, StatusCode, }, - layer::{limit::policy::ConcurrentPolicy, ConsumeErrLayer, LimitLayer, TimeoutLayer}, + layer::{ConsumeErrLayer, LimitLayer, TimeoutLayer, limit::policy::ConcurrentPolicy}, net::forwarded::Forwarded, - net::stream::{layer::http::BodyLimitLayer, SocketInfo, Stream}, + net::stream::{SocketInfo, Stream, layer::http::BodyLimitLayer}, proxy::haproxy::server::HaProxyLayer, rt::Executor, - Context, Layer, Service, }; use std::{convert::Infallible, marker::PhantomData, time::Duration}; use tokio::{io::AsyncWriteExt, net::TcpStream}; @@ -272,7 +272,7 @@ impl IpServiceBuilder { return Err(OpaqueError::from_display(format!( "invalid forward kind for Transport mode: {other:?}" )) - .into()) + .into()); } }; diff --git a/src/http.rs b/src/http.rs index 4e5ef3eac..471ebd1d2 100644 --- a/src/http.rs +++ b/src/http.rs @@ -5,10 +5,10 @@ #[doc(inline)] pub use ::rama_http::{ - dep, header, headers, io, matcher, proto, + Body, BodyDataStream, BodyExtractExt, BodyLimit, HeaderMap, HeaderName, HeaderValue, Method, + Request, Scheme, StatusCode, Uri, Version, dep, header, headers, io, matcher, proto, response::{self, IntoResponse, Response}, - service, Body, BodyDataStream, BodyExtractExt, BodyLimit, HeaderMap, HeaderName, HeaderValue, - Method, Request, Scheme, StatusCode, Uri, Version, + service, }; #[cfg(feature = "http-full")] diff --git a/src/lib.rs b/src/lib.rs index d19943a88..37d16256c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -321,8 +321,8 @@ #[doc(inline)] pub use ::rama_core::{ - combinators, context, error, graceful, layer, matcher, rt, service, username, Context, Layer, - Service, + Context, Layer, Service, combinators, context, error, graceful, layer, matcher, rt, service, + username, }; #[cfg(feature = "tcp")] diff --git a/tests/http-core/client.rs b/tests/http-core/client.rs index 4d8f013c0..2b4f44d22 100644 --- a/tests/http-core/client.rs +++ b/tests/http-core/client.rs @@ -406,9 +406,7 @@ macro_rules! test { } macro_rules! __client_req_prop { - ($req_builder:ident, $body:ident, $addr:ident, headers: $map:tt) => {{ - __client_req_header!($req_builder, $map) - }}; + ($req_builder:ident, $body:ident, $addr:ident, headers: $map:tt) => {{ __client_req_header!($req_builder, $map) }}; ($req_builder:ident, $body:ident, $addr:ident, method: $method:ident) => {{ $req_builder = $req_builder.method(Method::$method); @@ -1493,7 +1491,7 @@ mod conn { use bytes::{Buf, Bytes}; use futures_channel::{mpsc, oneshot}; - use futures_util::future::{self, poll_fn, FutureExt, TryFutureExt}; + use futures_util::future::{self, FutureExt, TryFutureExt, poll_fn}; use tokio::io::{AsyncRead, AsyncReadExt as _, AsyncWrite, AsyncWriteExt as _, ReadBuf}; use tokio::net::{TcpListener as TkTcpListener, TcpStream}; @@ -1506,7 +1504,7 @@ mod conn { use rama::http::{Method, Request, Response, StatusCode}; use rama::rt::Executor; - use super::{concat, s, support, tcp_connect, FutureHyperExt}; + use super::{FutureHyperExt, concat, s, support, tcp_connect}; async fn setup_tk_test_server() -> (TkTcpListener, SocketAddr) { let listener = TkTcpListener::bind(SocketAddr::from(([127, 0, 0, 1], 0))) @@ -2092,8 +2090,8 @@ mod conn { #[tokio::test] async fn client_on_informational_ext() { - use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; + use std::sync::atomic::{AtomicUsize, Ordering}; let (server, addr) = setup_std_test_server(); thread::spawn(move || { @@ -2164,14 +2162,16 @@ mod conn { let mut fut1 = std::pin::pin!(client.send_request(rama::http::Request::new(Empty::new()))); #[allow(clippy::never_loop)] - let _res1 = future::poll_fn(|cx| loop { - if let Poll::Ready(res) = fut1.as_mut().poll(cx) { - return Poll::Ready(res); + let _res1 = future::poll_fn(|cx| { + loop { + if let Poll::Ready(res) = fut1.as_mut().poll(cx) { + return Poll::Ready(res); + } + return match Pin::new(&mut conn).poll(cx) { + Poll::Ready(_) => panic!("ruh roh"), + Poll::Pending => Poll::Pending, + }; } - return match Pin::new(&mut conn).poll(cx) { - Poll::Ready(_) => panic!("ruh roh"), - Poll::Pending => Poll::Pending, - }; }) .await .expect("resp 1"); diff --git a/tests/http-core/examples/example_tests/utils/mod.rs b/tests/http-core/examples/example_tests/utils/mod.rs index 67ddc0329..aa98f15db 100644 --- a/tests/http-core/examples/example_tests/utils/mod.rs +++ b/tests/http-core/examples/example_tests/utils/mod.rs @@ -5,7 +5,7 @@ use std::{ sync::Once, }; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; /// Runner for examples. pub(super) struct ExampleRunner { diff --git a/tests/http-core/h2/client_request.rs b/tests/http-core/h2/client_request.rs index 157fa572b..11157927d 100644 --- a/tests/http-core/h2/client_request.rs +++ b/tests/http-core/h2/client_request.rs @@ -1,6 +1,6 @@ -use futures::future::{ready, Either}; -use futures::stream::FuturesUnordered; use futures::StreamExt; +use futures::future::{Either, ready}; +use futures::stream::FuturesUnordered; use h2_support::prelude::*; use std::pin::Pin; use std::task::Context; diff --git a/tests/http-core/h2/hammer.rs b/tests/http-core/h2/hammer.rs index cbed33896..d67a28abd 100644 --- a/tests/http-core/h2/hammer.rs +++ b/tests/http-core/h2/hammer.rs @@ -6,8 +6,8 @@ use std::io; use std::{ net::SocketAddr, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, }; use tokio::net::{TcpListener, TcpStream}; diff --git a/tests/http-core/h2/ping_pong.rs b/tests/http-core/h2/ping_pong.rs index aac893b6b..aaf42e013 100644 --- a/tests/http-core/h2/ping_pong.rs +++ b/tests/http-core/h2/ping_pong.rs @@ -1,5 +1,5 @@ -use futures::channel::oneshot; use futures::StreamExt; +use futures::channel::oneshot; use h2_support::assert_ping; use h2_support::prelude::*; diff --git a/tests/http-core/h2/prioritization.rs b/tests/http-core/h2/prioritization.rs index 6ca1c4925..7b2187e07 100644 --- a/tests/http-core/h2/prioritization.rs +++ b/tests/http-core/h2/prioritization.rs @@ -1,7 +1,7 @@ -use futures::{pin_mut, FutureExt, StreamExt}; +use futures::{FutureExt, StreamExt, pin_mut}; -use h2_support::prelude::*; use h2_support::DEFAULT_WINDOW_SIZE; +use h2_support::prelude::*; use std::task::Context; #[tokio::test] diff --git a/tests/http-core/h2/server.rs b/tests/http-core/h2/server.rs index 4696cfba1..806fed763 100644 --- a/tests/http-core/h2/server.rs +++ b/tests/http-core/h2/server.rs @@ -1485,9 +1485,11 @@ async fn reject_informational_status_header_in_request() { let _ = client.assert_server_handshake().await; let status_code = 128; - assert!(StatusCode::from_u16(status_code) - .unwrap() - .is_informational()); + assert!( + StatusCode::from_u16(status_code) + .unwrap() + .is_informational() + ); client .send_frame(frames::headers(1).response(status_code)) diff --git a/tests/http-core/server.rs b/tests/http-core/server.rs index a6d9c40e1..4525efc72 100644 --- a/tests/http-core/server.rs +++ b/tests/http-core/server.rs @@ -20,7 +20,7 @@ use rama::error::{BoxError, OpaqueError}; use rama::http::core::h2::client::SendRequest; use rama::http::core::h2::{RecvStream, SendStream}; use rama::http::core::service::RamaHttpService; -use rama::http::dep::http_body_util::{combinators::BoxBody, BodyExt, Empty, Full, StreamBody}; +use rama::http::dep::http_body_util::{BodyExt, Empty, Full, StreamBody, combinators::BoxBody}; use rama::http::header::{HeaderMap, HeaderName, HeaderValue}; use rama::rt::Executor; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}; @@ -29,7 +29,7 @@ use tokio::net::{TcpListener as TkTcpListener, TcpListener, TcpStream as TkTcpSt use rama::http::core::body::{Body, Incoming as IncomingBody}; use rama::http::core::server::conn::{http1, http2}; use rama::http::{Method, Request, Response, StatusCode, Uri, Version}; -use rama::service::{service_fn, Service}; +use rama::service::{Service, service_fn}; use tokio::pin; use super::support; @@ -2033,8 +2033,8 @@ async fn h2_connect() { #[tokio::test] async fn h2_connect_multiplex() { - use futures_util::stream::FuturesUnordered; use futures_util::StreamExt; + use futures_util::stream::FuturesUnordered; let (listener, addr) = setup_tcp_listener(); let conn = connect_async(addr).await; @@ -3192,8 +3192,8 @@ impl Service<(), Request> for HelloWorld { } } -fn unreachable_service( -) -> impl Service<(), rama::http::Request, Response = rama::http::Response, Error = Infallible> + Clone +fn unreachable_service() +-> impl Service<(), rama::http::Request, Response = rama::http::Response, Error = Infallible> + Clone { service_fn(|_req| async move { unreachable!() }) } diff --git a/tests/http-core/support/mod.rs b/tests/http-core/support/mod.rs index 8f88d5475..5e3fbdfeb 100644 --- a/tests/http-core/support/mod.rs +++ b/tests/http-core/support/mod.rs @@ -3,17 +3,17 @@ use std::convert::Infallible; use std::future::Future; use std::pin::Pin; use std::sync::{ - atomic::{AtomicUsize, Ordering}, Arc, Mutex, + atomic::{AtomicUsize, Ordering}, }; use bytes::Bytes; use http::StatusCode; +use rama::Context; use rama::http::core::server; use rama::http::core::service::RamaHttpService; use rama::http::dep::http_body_util::{BodyExt, Full}; use rama::rt::Executor; -use rama::Context; use tokio::net::{TcpListener, TcpStream}; use rama::http::{Request, Response, Version}; @@ -21,7 +21,7 @@ use rama::service::service_fn; #[allow(unused_imports)] pub(crate) use futures_util::{ - future, FutureExt as _, StreamExt as _, TryFutureExt as _, TryStreamExt as _, + FutureExt as _, StreamExt as _, TryFutureExt as _, TryStreamExt as _, future, }; pub(crate) use rama::http::HeaderMap; pub(crate) use std::net::SocketAddr; diff --git a/tests/integration/examples/example_tests/http_conn_state.rs b/tests/integration/examples/example_tests/http_conn_state.rs index cfd1cabd8..5903ad53b 100644 --- a/tests/integration/examples/example_tests/http_conn_state.rs +++ b/tests/integration/examples/example_tests/http_conn_state.rs @@ -1,7 +1,7 @@ use super::utils; use rama::{ - http::{BodyExtractExt, StatusCode}, Context, + http::{BodyExtractExt, StatusCode}, }; #[tokio::test] diff --git a/tests/integration/examples/example_tests/http_connect_proxy.rs b/tests/integration/examples/example_tests/http_connect_proxy.rs index 5bed5a342..587e11b66 100644 --- a/tests/integration/examples/example_tests/http_connect_proxy.rs +++ b/tests/integration/examples/example_tests/http_connect_proxy.rs @@ -1,12 +1,12 @@ use super::utils; use rama::{ - http::{response::Json, server::HttpServer, BodyExtractExt, Request}, + Context, + http::{BodyExtractExt, Request, response::Json, server::HttpServer}, net::address::ProxyAddress, rt::Executor, service::service_fn, - Context, }; -use serde_json::{json, Value}; +use serde_json::{Value, json}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/http_form.rs b/tests/integration/examples/example_tests/http_form.rs index c919587de..b19ae66dd 100644 --- a/tests/integration/examples/example_tests/http_form.rs +++ b/tests/integration/examples/example_tests/http_form.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; use serde::Serialize; #[tokio::test] diff --git a/tests/integration/examples/example_tests/http_health_check.rs b/tests/integration/examples/example_tests/http_health_check.rs index 833cbeb9a..701c6f545 100644 --- a/tests/integration/examples/example_tests/http_health_check.rs +++ b/tests/integration/examples/example_tests/http_health_check.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::StatusCode, Context}; +use rama::{Context, http::StatusCode}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/http_k8s_health.rs b/tests/integration/examples/example_tests/http_k8s_health.rs index 06a6e72da..7a1b0b2d0 100644 --- a/tests/integration/examples/example_tests/http_k8s_health.rs +++ b/tests/integration/examples/example_tests/http_k8s_health.rs @@ -1,5 +1,5 @@ use super::*; -use rama::{http::StatusCode, Context}; +use rama::{Context, http::StatusCode}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/http_key_value_store.rs b/tests/integration/examples/example_tests/http_key_value_store.rs index 2a9581898..63bb87bbf 100644 --- a/tests/integration/examples/example_tests/http_key_value_store.rs +++ b/tests/integration/examples/example_tests/http_key_value_store.rs @@ -1,8 +1,8 @@ use super::utils; use itertools::Itertools; use rama::{ - http::{BodyExtractExt, StatusCode}, Context, + http::{BodyExtractExt, StatusCode}, }; use serde_json::json; diff --git a/tests/integration/examples/example_tests/http_listener_hello.rs b/tests/integration/examples/example_tests/http_listener_hello.rs index d4094f56f..d5066018d 100644 --- a/tests/integration/examples/example_tests/http_listener_hello.rs +++ b/tests/integration/examples/example_tests/http_listener_hello.rs @@ -1,7 +1,7 @@ use super::utils; -use rama::http::BodyExtractExt; use rama::Context; -use serde_json::{self, json, Value}; +use rama::http::BodyExtractExt; +use serde_json::{self, Value, json}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/http_mitm_proxy.rs b/tests/integration/examples/example_tests/http_mitm_proxy.rs index c3a18c8f0..429d52b65 100644 --- a/tests/integration/examples/example_tests/http_mitm_proxy.rs +++ b/tests/integration/examples/example_tests/http_mitm_proxy.rs @@ -1,18 +1,18 @@ use super::utils; use rama::{ - http::{response::Json, server::HttpServer, BodyExtractExt, Request}, + Context, Layer, + http::{BodyExtractExt, Request, response::Json, server::HttpServer}, net::address::ProxyAddress, net::tls::{ - server::{SelfSignedData, ServerAuth, ServerConfig}, ApplicationProtocol, + server::{SelfSignedData, ServerAuth, ServerConfig}, }, rt::Executor, service::service_fn, tcp::server::TcpListener, tls::rustls::server::TlsAcceptorLayer, - Context, Layer, }; -use serde_json::{json, Value}; +use serde_json::{Value, json}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/http_rate_limit.rs b/tests/integration/examples/example_tests/http_rate_limit.rs index b6990bbb2..a6fe4f127 100644 --- a/tests/integration/examples/example_tests/http_rate_limit.rs +++ b/tests/integration/examples/example_tests/http_rate_limit.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::StatusCode, Context}; +use rama::{Context, http::StatusCode}; use std::sync::Arc; #[tokio::test] diff --git a/tests/integration/examples/example_tests/http_service_fs.rs b/tests/integration/examples/example_tests/http_service_fs.rs index 259959cc5..a6bd38a9c 100644 --- a/tests/integration/examples/example_tests/http_service_fs.rs +++ b/tests/integration/examples/example_tests/http_service_fs.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; const EXPECTED_FILE_CONTENT: &str = include_str!("../../../../test-files/index.html"); diff --git a/tests/integration/examples/example_tests/http_service_hello.rs b/tests/integration/examples/example_tests/http_service_hello.rs index 97a2dd147..d7bd743d8 100644 --- a/tests/integration/examples/example_tests/http_service_hello.rs +++ b/tests/integration/examples/example_tests/http_service_hello.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; use regex::Regex; #[tokio::test] diff --git a/tests/integration/examples/example_tests/http_service_match.rs b/tests/integration/examples/example_tests/http_service_match.rs index c20c71c4c..480da86f6 100644 --- a/tests/integration/examples/example_tests/http_service_match.rs +++ b/tests/integration/examples/example_tests/http_service_match.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; const ADDRESS: &str = "127.0.0.1:62011"; diff --git a/tests/integration/examples/example_tests/http_telemetry.rs b/tests/integration/examples/example_tests/http_telemetry.rs index 3628228e7..700651de8 100644 --- a/tests/integration/examples/example_tests/http_telemetry.rs +++ b/tests/integration/examples/example_tests/http_telemetry.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/http_user_agent_classifier.rs b/tests/integration/examples/example_tests/http_user_agent_classifier.rs index c870860cb..3e7414a97 100644 --- a/tests/integration/examples/example_tests/http_user_agent_classifier.rs +++ b/tests/integration/examples/example_tests/http_user_agent_classifier.rs @@ -1,7 +1,7 @@ use super::utils; -use rama::http::{headers, BodyExtractExt}; -use rama::ua::{HttpAgent, TlsAgent, UserAgentOverwrites}; use rama::Context; +use rama::http::{BodyExtractExt, headers}; +use rama::ua::{HttpAgent, TlsAgent, UserAgentOverwrites}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/http_web_service_dir_and_api.rs b/tests/integration/examples/example_tests/http_web_service_dir_and_api.rs index 824c822d3..507b14c3c 100644 --- a/tests/integration/examples/example_tests/http_web_service_dir_and_api.rs +++ b/tests/integration/examples/example_tests/http_web_service_dir_and_api.rs @@ -1,7 +1,7 @@ use super::utils; use rama::{ - http::{BodyExtractExt, StatusCode}, Context, + http::{BodyExtractExt, StatusCode}, }; #[tokio::test] diff --git a/tests/integration/examples/example_tests/https_connect_proxy.rs b/tests/integration/examples/example_tests/https_connect_proxy.rs index 03b1401ef..cc005f487 100644 --- a/tests/integration/examples/example_tests/https_connect_proxy.rs +++ b/tests/integration/examples/example_tests/https_connect_proxy.rs @@ -1,14 +1,14 @@ use super::utils; use rama::{ + Context, Layer, http::{ - headers::Accept, response::Json, server::HttpServer, BodyExtractExt, IntoResponse, Request, + BodyExtractExt, IntoResponse, Request, headers::Accept, response::Json, server::HttpServer, }, net::address::ProxyAddress, rt::Executor, service::service_fn, - Context, Layer, }; -use serde_json::{json, Value}; +use serde_json::{Value, json}; #[cfg(feature = "compression")] use rama::http::layer::compression::CompressionLayer; diff --git a/tests/integration/examples/example_tests/mtls_tunnel_and_service.rs b/tests/integration/examples/example_tests/mtls_tunnel_and_service.rs index f99dc50bf..4e3fee19c 100644 --- a/tests/integration/examples/example_tests/mtls_tunnel_and_service.rs +++ b/tests/integration/examples/example_tests/mtls_tunnel_and_service.rs @@ -1,7 +1,7 @@ use super::utils; -use rama::http::layer::retry::managed::DoNotRetry; -use rama::http::BodyExtractExt; use rama::Context; +use rama::http::BodyExtractExt; +use rama::http::layer::retry::managed::DoNotRetry; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/tcp_listener_hello.rs b/tests/integration/examples/example_tests/tcp_listener_hello.rs index 34043cb87..686eab172 100644 --- a/tests/integration/examples/example_tests/tcp_listener_hello.rs +++ b/tests/integration/examples/example_tests/tcp_listener_hello.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; const EXPECTED_FILE_CONTENT: &str = include_str!("../../../../examples/tcp_listener_hello.rs"); diff --git a/tests/integration/examples/example_tests/tcp_listener_layers.rs b/tests/integration/examples/example_tests/tcp_listener_layers.rs index 3d69eecd4..68b6a4e12 100644 --- a/tests/integration/examples/example_tests/tcp_listener_layers.rs +++ b/tests/integration/examples/example_tests/tcp_listener_layers.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{tcp::client::default_tcp_connect, Context}; +use rama::{Context, tcp::client::default_tcp_connect}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; #[tokio::test] diff --git a/tests/integration/examples/example_tests/tls_boring_dynamic_certs.rs b/tests/integration/examples/example_tests/tls_boring_dynamic_certs.rs index 4f369eb7d..0e81fdcb3 100644 --- a/tests/integration/examples/example_tests/tls_boring_dynamic_certs.rs +++ b/tests/integration/examples/example_tests/tls_boring_dynamic_certs.rs @@ -1,10 +1,11 @@ use super::utils::{self, ClientService}; use rama::{ + Context, Layer, Service, error::{BoxError, OpaqueError}, layer::MapResultLayer, - Context, Layer, Service, }; use rama_http::{ + Request, Response, dep::http_body, layer::{ decompression::DecompressionLayer, @@ -13,15 +14,14 @@ use rama_http::{ retry::{ManagedPolicy, RetryLayer}, trace::TraceLayer, }, - Request, Response, }; use rama_http_backend::client::HttpConnector; use rama_net::{ address::{Domain, Host}, client::{ConnectorService, EstablishedClientConnection}, tls::{ - client::{ClientConfig, ClientHelloExtension, NegotiatedTlsParameters, ServerVerifyMode}, ApplicationProtocol, DataEncoding, + client::{ClientConfig, ClientHelloExtension, NegotiatedTlsParameters, ServerVerifyMode}, }, }; use rama_tcp::client::service::TcpConnector; diff --git a/tests/integration/examples/example_tests/tls_boring_termination.rs b/tests/integration/examples/example_tests/tls_boring_termination.rs index d480e05d2..b4a3c43e6 100644 --- a/tests/integration/examples/example_tests/tls_boring_termination.rs +++ b/tests/integration/examples/example_tests/tls_boring_termination.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/tls_termination.rs b/tests/integration/examples/example_tests/tls_termination.rs index 945b95741..ddb1de59a 100644 --- a/tests/integration/examples/example_tests/tls_termination.rs +++ b/tests/integration/examples/example_tests/tls_termination.rs @@ -1,5 +1,5 @@ use super::utils; -use rama::{http::BodyExtractExt, Context}; +use rama::{Context, http::BodyExtractExt}; #[tokio::test] #[ignore] diff --git a/tests/integration/examples/example_tests/utils/mod.rs b/tests/integration/examples/example_tests/utils/mod.rs index 2a927a3f1..7eed3cc01 100644 --- a/tests/integration/examples/example_tests/utils/mod.rs +++ b/tests/integration/examples/example_tests/utils/mod.rs @@ -1,10 +1,12 @@ #![allow(dead_code)] use rama::{ + Layer, Service, error::BoxError, http::client::proxy::layer::SetProxyAuthHttpHeaderLayer, http::service::client::{HttpClientExt, IntoUrl, RequestBuilder}, http::{ + Request, Response, client::HttpClient, layer::{ follow_redirect::FollowRedirectLayer, @@ -12,12 +14,10 @@ use rama::{ retry::{ManagedPolicy, RetryLayer}, trace::TraceLayer, }, - Request, Response, }, layer::MapResultLayer, service::BoxService, utils::{backoff::ExponentialBackoff, rng::HasherRng}, - Layer, Service, }; use std::{ process::{Child, ExitStatus}, @@ -25,15 +25,15 @@ use std::{ time::Duration, }; use tracing::level_filters::LevelFilter; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; +use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[cfg(feature = "compression")] use rama::http::layer::decompression::DecompressionLayer; #[cfg(any(feature = "rustls", feature = "boring"))] use rama::net::tls::{ - client::{ClientConfig, ClientHelloExtension, ServerVerifyMode}, ApplicationProtocol, + client::{ClientConfig, ClientHelloExtension, ServerVerifyMode}, }; pub(super) type ClientService = BoxService;