diff --git a/Cargo.lock b/Cargo.lock index 973d7f4..428de07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,12 +150,12 @@ dependencies = [ [[package]] name = "axum-client-ip" -version = "0.7.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff8ee1869817523c8f91c20bf17fd932707f66c2e7e0b0f811b29a227289562" +checksum = "3f08a543641554404b42acd0d2494df12ca2be034d7b8ee4dbbf7446f940a2ef" dependencies = [ "axum", - "forwarded-header-value", + "client-ip", "serde", ] @@ -372,6 +372,16 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +[[package]] +name = "client-ip" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31211fc26899744f5b22521fdc971e5f3875991d8880537537470685a0e9552d" +dependencies = [ + "forwarded-header-value", + "http", +] + [[package]] name = "colorchoice" version = "1.0.4" @@ -554,7 +564,7 @@ dependencies = [ "serde", "tera", "tokio", - "toml 0.8.23", + "toml", "tower", "tower-http", ] @@ -1286,7 +1296,7 @@ dependencies = [ "mime", "serde", "tera", - "toml 0.9.8", + "toml", ] [[package]] @@ -1297,7 +1307,7 @@ checksum = "ad6270e962ff2af18516dc70519a18af0c772d9f3956eafd3618629560e55312" dependencies = [ "serde", "serde_json", - "toml 0.9.8", + "toml", ] [[package]] @@ -2081,15 +2091,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "serde_spanned" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" -dependencies = [ - "serde", -] - [[package]] name = "serde_spanned" version = "1.0.3" @@ -2428,18 +2429,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" -dependencies = [ - "serde", - "serde_spanned 0.6.9", - "toml_datetime 0.6.11", - "toml_edit", -] - [[package]] name = "toml" version = "0.9.8" @@ -2448,22 +2437,13 @@ checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" dependencies = [ "indexmap", "serde_core", - "serde_spanned 1.0.3", - "toml_datetime 0.7.3", + "serde_spanned", + "toml_datetime", "toml_parser", "toml_writer", "winnow", ] -[[package]] -name = "toml_datetime" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" -dependencies = [ - "serde", -] - [[package]] name = "toml_datetime" version = "0.7.3" @@ -2473,20 +2453,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "toml_edit" -version = "0.22.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" -dependencies = [ - "indexmap", - "serde", - "serde_spanned 0.6.9", - "toml_datetime 0.6.11", - "toml_write", - "winnow", -] - [[package]] name = "toml_parser" version = "1.0.4" @@ -2496,12 +2462,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "toml_write" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" - [[package]] name = "toml_writer" version = "1.0.4" @@ -3232,9 +3192,6 @@ name = "winnow" version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" -dependencies = [ - "memchr", -] [[package]] name = "winreg" diff --git a/Cargo.toml b/Cargo.toml index d4617cd..6fe3a90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Slatian "] lib-humus = { version="0.4", features=["axum-view+cookie"] } lib-humus-configuration = { version = "0.1.0", featres=["toml"] } -axum-client-ip = "0.7" +axum-client-ip = { version = "1.1.3", features = ["serde", "forwarded-header"] } axum-extra = { version = "0.10", features = ["cookie", "typed-header"] } axum = { version = "0.8", features = ["macros"] } clap = { version = "4.5", features = ["derive"] } @@ -28,6 +28,6 @@ regex = "1.11" serde = { version = "1", features = ["derive","rc"] } tera = "1" tokio = { version = "1", features = ["macros","signal"] } -toml = "0.8" +toml = "0.9" tower = "0.5" tower-http = { version = "0.6", features = ["fs"] } diff --git a/Configuration.md b/Configuration.md index 0639e19..6c70653 100644 --- a/Configuration.md +++ b/Configuration.md @@ -28,7 +28,8 @@ This option can be overridden by the `-l :` option on the comm Configures which http header that contains the real client IP-Address or tells the service to use the IP-Address used to connect to it when in use without a proxy server. -Possible values are best covered by the [documentation for the underlying datatype](https://docs.rs/axum-client-ip/latest/axum_client_ip/enum.SecureClientIpSource.html). +Possible values are best covered by the [documentation for the underlying datatype](https://docs.rs/axum-client-ip/latest/axum_client_ip/enum.ClientIpSource.html). +Note: The possible values stayed compatible even though there was a [major release of the ip address extration library](https://github.com/imbolc/axum-client-ip/releases/tag/v1.0.0). When using a reverse Proxy `RightmostXForwardedFor` is usually what you want. diff --git a/src/config/mod.rs b/src/config/mod.rs index 50e40ac..f04ca86 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,4 +1,4 @@ -use axum_client_ip::SecureClientIpSource; +use axum_client_ip::ClientIpSource; use serde::Deserialize; use std::net::SocketAddr; @@ -21,7 +21,7 @@ pub struct EchoIpServiceConfig { #[derive(Deserialize, Clone)] pub struct ServerConfig { pub listen_on: SocketAddr, - pub ip_header: SecureClientIpSource, + pub ip_header: ClientIpSource, pub allow_private_ip_lookup: bool, } @@ -51,7 +51,7 @@ impl Default for ServerConfig { fn default() -> Self { ServerConfig { listen_on: "127.0.0.1:3000".parse().unwrap(), - ip_header: SecureClientIpSource::ConnectInfo, + ip_header: ClientIpSource::ConnectInfo, allow_private_ip_lookup: false, } } diff --git a/src/main.rs b/src/main.rs index cc1fa20..ec50dfc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use axum::{ Router, routing::get, }; -use axum_client_ip::SecureClientIp; +use axum_client_ip::ClientIp; use axum_extra::headers; use axum_extra::TypedHeader; use clap::Parser; @@ -463,7 +463,7 @@ async fn handle_default_route( State(arc_state): State>, Extension(settings): Extension, user_agent_header: Option>, - SecureClientIp(client_ip): SecureClientIp + ClientIp(client_ip): ClientIp ) -> Response { let state = Arc::clone(&arc_state); @@ -589,7 +589,7 @@ async fn handle_ip_route_with_path( Extension(settings): Extension, State(arc_state): State>, extract::Path(query): extract::Path, - SecureClientIp(client_ip): SecureClientIp + ClientIp(client_ip): ClientIp ) -> Response { if let Ok(address) = query.parse() { return handle_ip_request(address, settings, arc_state, &client_ip).await diff --git a/src/ratelimit.rs b/src/ratelimit.rs index 2e5b05b..78947ad 100644 --- a/src/ratelimit.rs +++ b/src/ratelimit.rs @@ -1,4 +1,4 @@ -use axum_client_ip::SecureClientIp; +use axum_client_ip::ClientIp; use axum::{ body::Body, extract::Extension, @@ -43,7 +43,7 @@ pub fn build_rate_limiting_state( } pub async fn rate_limit_middleware( - SecureClientIp(address): SecureClientIp, + ClientIp(address): ClientIp, Extension(arc_limiter): Extension>>, req: Request, next: Next