changeset 3562:b33b2fbdc713

mod_net_proxy: Ensure port numbers are coerced into numbers LuaSocket likes to use strings for port numbers for some reason, so this might help with some type related problems.
author Kim Alvefur <zash@zash.se>
date Fri, 12 Apr 2019 21:44:29 +0200 (2019-04-12)
parents deb5ece56c49
children b5f5d6bf703c
files mod_net_proxy/mod_net_proxy.lua
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_net_proxy/mod_net_proxy.lua	Tue Apr 09 23:23:30 2019 +0200
+++ b/mod_net_proxy/mod_net_proxy.lua	Fri Apr 12 21:44:29 2019 +0200
@@ -289,7 +289,7 @@
 	end
 
 	-- Attempt to find service by processing port<>service mappings
-	local mapping = mappings[conn:serverport()];
+	local mapping = mappings[tonumber(conn:serverport())];
 	if mapping == nil then
 		conn:close();
 		module:log("warn", "Connection %s@%s terminated: Could not find mapping for port %d",
@@ -443,6 +443,7 @@
 -- Process all configured port mappings and generate a list of mapped ports
 local mapped_ports = {};
 for port, mapping in pairs(config_mappings) do
+	port = tonumber(port);
 	table.insert(mapped_ports, port);
 	mappings[port] = {
 		service_name = mapping,