Improve some code
This commit is contained in:
		@@ -25,16 +25,13 @@ 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: Vec<String> = header
 | 
					                let header = header
 | 
				
			||||||
                    .to_str()
 | 
					                    .to_str()
 | 
				
			||||||
                    .unwrap()
 | 
					                    .unwrap()
 | 
				
			||||||
                    .to_string()
 | 
					                    .split_once(',');
 | 
				
			||||||
                    .split(',')
 | 
					 | 
				
			||||||
                    .map(|f| f.to_string())
 | 
					 | 
				
			||||||
                    .collect();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if !header.is_empty() {
 | 
					                if let Some((upstream_ip, _)) = header {
 | 
				
			||||||
                    ip = header[0].to_string();
 | 
					                    ip = upstream_ip.to_string();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user