Software /
code /
prosody-modules
Comparison
mod_s2sout_override/mod_s2sout_override.lua @ 5631:b87a23b45725
mod_s2sout_override: Add support for a catch-all target
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 27 Jul 2023 15:00:26 +0200 |
parent | 5487:6cf2f32dbf40 |
child | 5632:ae62d92506dc |
comparison
equal
deleted
inserted
replaced
5630:efdaffc878a9 | 5631:b87a23b45725 |
---|---|
4 local basic_resolver = require "net.resolvers.basic"; | 4 local basic_resolver = require "net.resolvers.basic"; |
5 | 5 |
6 local override_for = module:get_option(module.name, {}); -- map of host to "tcp://example.com:5269" | 6 local override_for = module:get_option(module.name, {}); -- map of host to "tcp://example.com:5269" |
7 | 7 |
8 module:hook("s2sout-pre-connect", function(event) | 8 module:hook("s2sout-pre-connect", function(event) |
9 local override = override_for[event.session.to_host]; | 9 local override = override_for[event.session.to_host] or override_for["*"]; |
10 if type(override) == "string" then | 10 if type(override) == "string" then |
11 override = url.parse(override); | 11 override = url.parse(override); |
12 end | 12 end |
13 if type(override) == "table" and override.scheme == "tcp" and type(override.host) == "string" then | 13 if type(override) == "table" and override.scheme == "tcp" and type(override.host) == "string" then |
14 event.resolver = basic_resolver.new(override.host, tonumber(override.port) or 5269, override.scheme, {}); | 14 event.resolver = basic_resolver.new(override.host, tonumber(override.port) or 5269, override.scheme, {}); |