comparison 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
parents 3632836f35b0
children 28f6322fad50
comparison
equal deleted inserted replaced
4778:229f2a79ad6f 4779:6395d4732bc6
6 local async = require "util.async"; 6 local async = require "util.async";
7 local set = require "util.set"; 7 local set = require "util.set";
8 local nameprep = require"util.encodings".stringprep.nameprep; 8 local nameprep = require"util.encodings".stringprep.nameprep;
9 local idna_to_ascii = require"util.encodings".idna.to_ascii; 9 local idna_to_ascii = require"util.encodings".idna.to_ascii;
10 10
11 local services = { "xmpp-client"; "xmpps-client"; "xmpp-server"; "xmpps-server" } 11 local virtualhost_services = { "xmpp-client"; "xmpps-client"; "xmpp-server"; "xmpps-server" }
12 local component_services = { "xmpp-server"; "xmpps-server" }
12 13
13 local function validate_dnsname_option(options, option_name, default) 14 local function validate_dnsname_option(options, option_name, default)
14 local host = options[option_name]; 15 local host = options[option_name];
15 if host == nil then return default end 16 if host == nil then return default end
16 local normalized = nameprep(host); 17 local normalized = nameprep(host);
52 local ihost = idna_to_ascii(vhost); 53 local ihost = idna_to_ascii(vhost);
53 if not ihost then 54 if not ihost then
54 module:log("error", "Host %q falis IDNA", vhost); 55 module:log("error", "Host %q falis IDNA", vhost);
55 return 1; 56 return 1;
56 end 57 end
57 if not config.get(vhost, "defined") then 58 local is_component = config.get(vhost, "component_module");
59 if not is_component and not config.get(vhost, "defined") then
58 module:log("error", "Host %q is not defined in the config", vhost); 60 module:log("error", "Host %q is not defined in the config", vhost);
59 return 1; 61 return 1;
60 end 62 end
63
64 local services = virtualhost_services;
65 if is_component then services = component_services; end
61 66
62 local domain = validate_dnsname_option(opts, "domain"); 67 local domain = validate_dnsname_option(opts, "domain");
63 if not domain then 68 if not domain then
64 module:log("error", "--domain is required"); 69 module:log("error", "--domain is required");
65 return 1; 70 return 1;