Diff

mod_dnsupdate/mod_dnsupdate.lua @ 4779:6395d4732bc6

mod_dnsupdate: Add support for components
author Kim Alvefur <zash@zash.se>
date Fri, 19 Nov 2021 13:45:21 +0100
parent 4765:3632836f35b0
child 4882:28f6322fad50
line wrap: on
line diff
--- a/mod_dnsupdate/mod_dnsupdate.lua	Thu Nov 18 19:39:38 2021 +0100
+++ b/mod_dnsupdate/mod_dnsupdate.lua	Fri Nov 19 13:45:21 2021 +0100
@@ -8,7 +8,8 @@
 local nameprep = require"util.encodings".stringprep.nameprep;
 local idna_to_ascii = require"util.encodings".idna.to_ascii;
 
-local services = { "xmpp-client"; "xmpps-client"; "xmpp-server"; "xmpps-server" }
+local virtualhost_services = { "xmpp-client"; "xmpps-client"; "xmpp-server"; "xmpps-server" }
+local component_services = { "xmpp-server"; "xmpps-server" }
 
 local function validate_dnsname_option(options, option_name, default)
 	local host = options[option_name];
@@ -54,11 +55,15 @@
 		module:log("error", "Host %q falis IDNA", vhost);
 		return 1;
 	end
-	if not config.get(vhost, "defined") then
+	local is_component = config.get(vhost, "component_module");
+	if not is_component 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");