Software /
code /
prosody
Comparison
plugins/mod_http.lua @ 11409:d30c44a829c1
net.http.server: Set request.ip so mod_http doesn't have to
Because it already sets request.secure, which depends on the connection,
just like the IP, so it makes sense to do both in the same place.
Dealing with proxies can be left to mod_http for now, but maybe it could
move into some util some day?
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 Feb 2021 21:37:16 +0100 |
parent | 11408:1b6298e7b550 |
child | 11410:2ea70d291429 |
comparison
equal
deleted
inserted
replaced
11408:1b6298e7b550 | 11409:d30c44a829c1 |
---|---|
258 end | 258 end |
259 return false | 259 return false |
260 end | 260 end |
261 | 261 |
262 local function get_ip_from_request(request) | 262 local function get_ip_from_request(request) |
263 local ip = request.conn:ip(); | 263 local ip = request.ip; |
264 local forwarded_for = request.headers.x_forwarded_for; | 264 local forwarded_for = request.headers.x_forwarded_for; |
265 if forwarded_for and is_trusted_proxy(ip) then | 265 if forwarded_for and is_trusted_proxy(ip) then |
266 -- luacheck: ignore 631 | 266 -- luacheck: ignore 631 |
267 -- This logic looks weird at first, but it makes sense. | 267 -- This logic looks weird at first, but it makes sense. |
268 -- The for loop will take the last non-trusted-proxy IP from `forwarded_for`. | 268 -- The for loop will take the last non-trusted-proxy IP from `forwarded_for`. |