mod_http: Optimize proxy IP check
authorKim Alvefur <zash@zash.se>
Thu, 18 Feb 2021 10:41:04 +0100
changeset 11389 c81b6b8c6b19
parent 11388 f9edf26c66fc
child 11391 4f97b33e2596
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
--- a/plugins/mod_http.lua	Thu Feb 18 10:05:30 2021 +0100
+++ b/plugins/mod_http.lua	Thu Feb 18 10:41:04 2021 +0100
@@ -223,6 +223,9 @@
 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