Changeset

11385:c81b6b8c6b19

mod_http: Optimize proxy IP check No need to do a subnet match comparison to see if two IP addresses match exactly.
author Kim Alvefur <zash@zash.se>
date Thu, 18 Feb 2021 10:41:04 +0100
parents 11384:f9edf26c66fc
children 11387:4f97b33e2596
files plugins/mod_http.lua
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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