From 0e6a6fff961c238057e93c5ff90e69b6dce0afb0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 18 Feb 2021 10:41:04 +0100 Subject: mod_http: Optimize proxy IP check No need to do a subnet match comparison to see if two IP addresses match exactly. --- plugins/mod_http.lua | 3 +++ 1 file changed, 3 insertions(+) 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 -- cgit v1.2.3