# HG changeset patch # User Kim Alvefur # Date 1690462826 -7200 # Node ID b87a23b45725bbfa5892ccb5046b6b49651bb02c # Parent efdaffc878a90230d9ab5d7229d67fa519721d9c mod_s2sout_override: Add support for a catch-all target diff -r efdaffc878a9 -r b87a23b45725 mod_s2sout_override/README.md --- a/mod_s2sout_override/README.md Wed Jul 26 16:23:13 2023 +0200 +++ b/mod_s2sout_override/README.md Thu Jul 27 15:00:26 2023 +0200 @@ -18,6 +18,11 @@ URIs with IP addresses like `tcp://127.0.0.1:9999` will bypass A/AAAA DNS lookups. +The special target `"*"` may be used to redirect all servers that don't have +an exact match. + +Standard DNS SRV resolution can be restored by specifying a truthy value. + ```lua -- Global section modules_enabled = { @@ -28,7 +33,12 @@ s2sout_override = { ["example.com"] = "tcp://other.host.example:5299"; ["xmpp.example.net"] = "tcp://localhost:5999"; - ["secure.example"] = = "tls://127.0.0.1:5270"; + ["secure.example"] = "tls://127.0.0.1:5270"; + + -- catch-all: + ["*"] = "tls://127.0.0.1:5370"; + -- bypass the catch-all, use standard DNS SRV: + ["jabber.example"] = true; } ``` diff -r efdaffc878a9 -r b87a23b45725 mod_s2sout_override/mod_s2sout_override.lua --- a/mod_s2sout_override/mod_s2sout_override.lua Wed Jul 26 16:23:13 2023 +0200 +++ b/mod_s2sout_override/mod_s2sout_override.lua Thu Jul 27 15:00:26 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]; + local override = override_for[event.session.to_host] or override_for["*"]; if type(override) == "string" then override = url.parse(override); end