Skip to content

Commit 75178eb

Browse files
committed
fix: allow x-forwarder-for with ports
1 parent bfe199c commit 75178eb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/key_extractor.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ fn maybe_x_forwarded_for(headers: &HeaderMap) -> Option<IpAddr> {
131131
headers
132132
.get(X_FORWARDED_FOR)
133133
.and_then(|hv| hv.to_str().ok())
134-
.and_then(|s| s.split(',').find_map(|s| s.trim().parse::<IpAddr>().ok()))
134+
.and_then(|s| {
135+
s.split(',')
136+
.find_map(|s| s.trim().split(':').next()?.parse::<IpAddr>().ok())
137+
})
135138
}
136139

137140
/// Tries to parse the `x-real-ip` header

0 commit comments

Comments
 (0)