aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-27 20:45:45 +0100
committerKim Alvefur <zash@zash.se>2021-02-27 20:45:45 +0100
commitaa9e2741d5555d7188b7559b3c089f66ca54e528 (patch)
tree1106ff1be040201ff63db4ee0e7a9a7f22178647
parente52a77ff84ec319ea060af26cc301d4486395c00 (diff)
downloadprosody-aa9e2741d5555d7188b7559b3c089f66ca54e528.tar.gz
prosody-aa9e2741d5555d7188b7559b3c089f66ca54e528.zip
mod_http: Restore ip field for requests without proxies
8603011e51fe optimized out more than just the loop, leaving the .ip field blank when the request wasn't from a proxy.
-rw-r--r--plugins/mod_http.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua
index a1873e70..b6ba23ac 100644
--- a/plugins/mod_http.lua
+++ b/plugins/mod_http.lua
@@ -161,7 +161,7 @@ local trusted_proxies = module:get_option_set("trusted_proxies", { "127.0.0.1",
local function get_ip_from_request(request)
local ip = request.conn:ip();
local forwarded_for = request.headers.x_forwarded_for;
- if forwarded_for then
+ if forwarded_for and trusted_proxies[ip] then
forwarded_for = forwarded_for..", "..ip;
for forwarded_ip in forwarded_for:gmatch("[^%s,]+") do
if not trusted_proxies[forwarded_ip] then
@@ -174,7 +174,7 @@ end
module:wrap_object_event(server._events, false, function (handlers, event_name, event_data)
local request = event_data.request;
- if request and trusted_proxies[request.conn:ip()] then
+ if request then
-- Not included in eg http-error events
request.ip = get_ip_from_request(request);
end