Software /
code /
prosody
Changeset
11407:8d6e013377fa 0.11
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 Feb 2021 20:45:45 +0100 |
parents | 11386:e40ba204c612 |
children | 11408:1b6298e7b550 11507:133e8ed291fe |
files | plugins/mod_http.lua |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_http.lua Thu Feb 18 14:34:38 2021 +0100 +++ b/plugins/mod_http.lua Sat Feb 27 20:45:45 2021 +0100 @@ -161,7 +161,7 @@ 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 @@ 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