Software /
code /
prosody-modules
Comparison
mod_s2sout_override/mod_s2sout_override.lua @ 5632: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 |
parent | 5631:b87a23b45725 |
comparison
equal
deleted
inserted
replaced
5631:b87a23b45725 | 5632:ae62d92506dc |
---|---|
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] or override_for["*"]; | 9 local override = override_for[event.session.to_host] or override_for[event.session.to_host:gsub("^[^.]+%.", "*.")] 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, {}); |