File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ edition = "2021"
4
4
license = " MIT"
5
5
name = " axum-client-ip"
6
6
repository = " https://github.com/imbolc/axum-client-ip"
7
- version = " 0.3.0 "
7
+ version = " 0.3.1 "
8
8
9
9
[dependencies ]
10
10
axum = " 0.6"
Original file line number Diff line number Diff line change @@ -82,7 +82,11 @@ fn maybe_x_forwarded_for(headers: &HeaderMap) -> Option<IpAddr> {
82
82
headers
83
83
. get ( X_FORWARDED_FOR )
84
84
. and_then ( |hv| hv. to_str ( ) . ok ( ) )
85
- . and_then ( |s| s. split ( ',' ) . find_map ( |s| s. trim ( ) . parse :: < IpAddr > ( ) . ok ( ) ) )
85
+ . and_then ( |s| {
86
+ s. split ( ',' )
87
+ . rev ( )
88
+ . find_map ( |s| s. trim ( ) . parse :: < IpAddr > ( ) . ok ( ) )
89
+ } )
86
90
}
87
91
88
92
/// Tries to parse the `x-real-ip` header
@@ -149,7 +153,7 @@ mod tests {
149
153
. body ( Body :: empty ( ) )
150
154
. unwrap ( ) ;
151
155
let res = app ( ) . oneshot ( req) . await . unwrap ( ) ;
152
- assert_eq ! ( body_string( res. into_body( ) ) . await , "1.1.1.1 " ) ;
156
+ assert_eq ! ( body_string( res. into_body( ) ) . await , "2.2.2.2 " ) ;
153
157
}
154
158
155
159
#[ tokio:: test]
You can’t perform that action at this time.
0 commit comments