Skip to content

Commit 85b5883

Browse files
committed
fix(su): utilize correct incoming ip
1 parent 479438a commit 85b5883

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

servers/su/src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,13 @@ fn process_whitelist_check(deps: &Arc<Deps>, process_id: &str) -> Option<HttpRes
8080
}
8181

8282
fn get_client_ip(req: &HttpRequest) -> Option<String> {
83-
req.connection_info()
84-
.realip_remote_addr()
85-
.map(|ip| ip.to_string())
83+
req.headers()
84+
.get("X-Real-IP")
85+
.and_then(|v| v.to_str().ok())
86+
.map(|s| s.to_string())
8687
}
8788

8889
fn is_ip_allowed(ip: &str, whitelist: &IpWhitelist) -> bool {
89-
if ip == "127.0.0.1" {
90-
return true;
91-
}
92-
9390
match whitelist.read() {
9491
Ok(ips) => ips.contains(ip),
9592
Err(_) => false,

servers/su/su

-9.52 KB
Binary file not shown.

0 commit comments

Comments
 (0)