Improve some code
This commit is contained in:
parent
188b4f836d
commit
1ff9c7686e
@ -25,13 +25,12 @@ pub fn get_remote_ip(req: &HttpRequest, proxy_ip: Option<&str>) -> String {
|
|||||||
if let Some(proxy) = proxy_ip.as_ref() {
|
if let Some(proxy) = proxy_ip.as_ref() {
|
||||||
if match_ip(proxy, &ip) {
|
if match_ip(proxy, &ip) {
|
||||||
if let Some(header) = req.headers().get("X-Forwarded-For") {
|
if let Some(header) = req.headers().get("X-Forwarded-For") {
|
||||||
let header = header
|
let header = header.to_str().unwrap();
|
||||||
.to_str()
|
|
||||||
.unwrap()
|
|
||||||
.split_once(',');
|
|
||||||
|
|
||||||
if let Some((upstream_ip, _)) = header {
|
if let Some((upstream_ip, _)) = header.split_once(',') {
|
||||||
ip = upstream_ip.to_string();
|
ip = upstream_ip.to_string();
|
||||||
|
} else {
|
||||||
|
ip = header.to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user