# HG changeset patch # User Kim Alvefur # Date 1690463078 -7200 # Node ID ae62d92506dc6fa70785f9db3065b98ad30d04a6 # Parent b87a23b45725bbfa5892ccb5046b6b49651bb02c mod_s2sout_override: Add support for one-level wildcards (e.g. *.example.net) diff -r b87a23b45725 -r ae62d92506dc mod_s2sout_override/README.md --- a/mod_s2sout_override/README.md Thu Jul 27 15:00:26 2023 +0200 +++ b/mod_s2sout_override/README.md Thu Jul 27 15:04:38 2023 +0200 @@ -21,6 +21,8 @@ The special target `"*"` may be used to redirect all servers that don't have an exact match. +One-level wildcards like `"*.example.net"` also work. + Standard DNS SRV resolution can be restored by specifying a truthy value. ```lua @@ -34,6 +36,7 @@ ["example.com"] = "tcp://other.host.example:5299"; ["xmpp.example.net"] = "tcp://localhost:5999"; ["secure.example"] = "tls://127.0.0.1:5270"; + ["*.allthese.example"] = = "tcp://198.51.100.123:9999"; -- catch-all: ["*"] = "tls://127.0.0.1:5370"; diff -r b87a23b45725 -r ae62d92506dc mod_s2sout_override/mod_s2sout_override.lua --- 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