Skip to content

Commit c070366

Browse files
committed
Bump
1 parent 2115d60 commit c070366

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

server/src/http.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,19 @@ async fn rate_limit_middleware(
8787
) -> Result<Response, StatusCode> {
8888
let ip = req
8989
.headers()
90-
.get("x-forwarded-for")
90+
.get("CF-Connecting-IP")
9191
.and_then(|hv| hv.to_str().ok())
92-
.unwrap_or("unknown")
92+
.unwrap_or_else(|| {
93+
req.headers()
94+
.get("x-real-ip")
95+
.and_then(|hv| hv.to_str().ok())
96+
.unwrap_or_else(|| {
97+
req.headers()
98+
.get("x-forwarded-for")
99+
.and_then(|hv| hv.to_str().ok())
100+
.unwrap_or("unknown")
101+
})
102+
})
93103
.to_string();
94104

95105
let path = req

0 commit comments

Comments
 (0)