mirror of
https://github.com/ViViDboarder/bitwarden_rs.git
synced 2024-11-05 04:46:36 +00:00
When receiving a comma separated list as IP, pick the first
This commit is contained in:
parent
5c6081c4e2
commit
cb6f392774
@ -429,8 +429,12 @@ impl<'a, 'r> FromRequest<'a, 'r> for ClientIp {
|
|||||||
fn from_request(req: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
|
fn from_request(req: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
|
||||||
let ip = if CONFIG._ip_header_enabled() {
|
let ip = if CONFIG._ip_header_enabled() {
|
||||||
req.headers().get_one(&CONFIG.ip_header()).and_then(|ip| {
|
req.headers().get_one(&CONFIG.ip_header()).and_then(|ip| {
|
||||||
ip.parse()
|
match ip.find(',') {
|
||||||
.map_err(|_| warn_!("'{}' header is malformed: {}", CONFIG.ip_header(), ip))
|
Some(idx) => &ip[..idx],
|
||||||
|
None => ip,
|
||||||
|
}
|
||||||
|
.parse()
|
||||||
|
.map_err(|_| warn!("'{}' header is malformed: {}", CONFIG.ip_header(), ip))
|
||||||
.ok()
|
.ok()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user