Commit f33c4ed1 authored by Rytis Slatkevièius's avatar Rytis Slatkevièius
Browse files

Sched: use X-Forwarded-For as the client's IP address in case it is set (if...

Sched: use X-Forwarded-For as the client's IP address in case it is set (if the scheduler is behind a load balancer, environment's remote_addr will contain load balancer's IP).
parent 1a023a5a
......@@ -498,6 +498,17 @@ got_host:
return 0;
}
inline static const char* get_remote_addr() {
// Server is behind a load balancer or proxy
const char* p = getenv("HTTP_X_FORWARDED_FOR");
if (p) {
return p;
}
const char * r = getenv("REMOTE_ADDR");
return r ? r : "?.?.?.?";
}
// modify host struct based on request.
// Copy all fields that are determined by the client.
//
......@@ -585,7 +596,7 @@ static int update_host_record(HOST& initial_host, HOST& xhost, USER& user) {
md5_block((const unsigned char*)buf, strlen(buf), host.host_cpid);
}
char* p = getenv("REMOTE_ADDR");
const char* p = get_remote_addr();
if (p) {
strlcpy(host.external_ip_addr, p, sizeof(host.external_ip_addr));
}
......@@ -1044,11 +1055,6 @@ bool wrong_core_client_version() {
return true;
}
inline static const char* get_remote_addr() {
const char * r = getenv("REMOTE_ADDR");
return r ? r : "?.?.?.?";
}
void handle_msgs_from_host() {
unsigned int i;
DB_MSG_FROM_HOST mfh;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment