Software /
code /
prosody-modules
Diff
mod_dnsupdate/mod_dnsupdate.lua @ 6255:52e239aa96af
mod_dnsupdate: Use modulemanager to check which of c2s and s2s are enabled
This also makes it deny services that are disabled
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 12 May 2025 12:16:25 +0200 |
parent | 6254:b6e390a97c85 |
child | 6256:62adec551585 |
line wrap: on
line diff
--- a/mod_dnsupdate/mod_dnsupdate.lua Mon May 12 12:15:10 2025 +0200 +++ b/mod_dnsupdate/mod_dnsupdate.lua Mon May 12 12:16:25 2025 +0200 @@ -1,6 +1,7 @@ module:set_global(); local config = require "core.configmanager"; +local modulemanager = require "core.modulemanager"; local argparse = require "util.argparse"; local dns = require"net.adns".resolver(); local async = require "util.async"; @@ -8,8 +9,7 @@ local nameprep = require"util.encodings".stringprep.nameprep; local idna_to_ascii = require"util.encodings".idna.to_ascii; -local virtualhost_services = { "xmpp-client"; "xmpps-client"; "xmpp-server"; "xmpps-server" } -local component_services = { "xmpp-server"; "xmpps-server" } +local services = { "xmpp-client"; "xmpps-client"; "xmpp-server"; "xmpps-server" } local function validate_dnsname_option(options, option_name, default) local host = options[option_name]; @@ -56,15 +56,11 @@ module:log("error", "Host %q fails IDNA", vhost); return 1; end - local is_component = config.get(vhost, "component_module"); - if not is_component and not config.get(vhost, "defined") then + if not config.get(vhost, "component_module") and not config.get(vhost, "defined") then module:log("error", "Host %q is not defined in the config", vhost); return 1; end - local services = virtualhost_services; - if is_component then services = component_services; end - local domain = validate_dnsname_option(opts, "domain"); if not domain then module:log("error", "--domain is required"); @@ -86,6 +82,17 @@ ["xmpps-server"] = module:get_option_array("s2s_direct_tls_ports", {}); }; + local modules_enabled = modulemanager.get_modules_for_host(vhost); + print(modules_enabled) + if not modules_enabled:contains("c2s") then + configured_ports["xmpp-client"] = {}; + configured_ports["xmpps-client"] = {}; + end + if not modules_enabled:contains("s2s") then + configured_ports["xmpp-server"] = {}; + configured_ports["xmpps-server"] = {}; + end + if opts.multiplex then for opt, ports in pairs(configured_ports) do ports:append(module:get_option_array(opt:sub(1, 5) == "xmpps" and "ssl_ports" or "ports", {}));