diff mod_s2sout_override/mod_s2sout_override.lua @ 5622:ae62d92506dc

mod_s2sout_override: Add support for one-level wildcards (e.g. *.example.net)
author Kim Alvefur <zash@zash.se>
date Thu, 27 Jul 2023 15:04:38 +0200
parents b87a23b45725
children
line wrap: on
line diff
--- a/mod_s2sout_override/mod_s2sout_override.lua	Thu Jul 27 15:00:26 2023 +0200
+++ b/mod_s2sout_override/mod_s2sout_override.lua	Thu Jul 27 15:04:38 2023 +0200
@@ -6,7 +6,7 @@
 local override_for = module:get_option(module.name, {}); -- map of host to "tcp://example.com:5269"
 
 module:hook("s2sout-pre-connect", function(event)
-	local override = override_for[event.session.to_host] or override_for["*"];
+	local override = override_for[event.session.to_host] or override_for[event.session.to_host:gsub("^[^.]+%.", "*.")] or override_for["*"];
 	if type(override) == "string" then
 		override = url.parse(override);
 	end