aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-18 10:41:04 +0100
committerKim Alvefur <zash@zash.se>2021-02-18 10:41:04 +0100
commit0e6a6fff961c238057e93c5ff90e69b6dce0afb0 (patch)
tree52bb44287aa2167e3a875aebb7a787c315c15717
parent231e87ab054addeb2433ecf6f87b54c641bd8865 (diff)
downloadprosody-0e6a6fff961c238057e93c5ff90e69b6dce0afb0.tar.gz
prosody-0e6a6fff961c238057e93c5ff90e69b6dce0afb0.zip
mod_http: Optimize proxy IP check
No need to do a subnet match comparison to see if two IP addresses match exactly.
-rw-r--r--plugins/mod_http.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua
index 3d2c4443..b9c0c1a4 100644
--- a/plugins/mod_http.lua
+++ b/plugins/mod_http.lua
@@ -223,6 +223,9 @@ module.add_host(module); -- set up handling on global context too
local trusted_proxies = module:get_option_set("trusted_proxies", { "127.0.0.1", "::1" })._items;
local function is_trusted_proxy(ip)
+ if trusted_proxies[ip] then
+ return true;
+ end
local parsed_ip = new_ip(ip)
for trusted_proxy in trusted_proxies do
if match_ip(parsed_ip, parse_cidr(trusted_proxy)) then