aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-03-02 15:45:24 +0000
committerMatthew Wild <mwild1@gmail.com>2022-03-02 15:45:24 +0000
commit7198c65a154445377ccefa4c54f48b7f956ae79b (patch)
tree25d3e992d283a1f5371d98721223581853daaa93 /util
parent0fe2f4a5270b7980cb25ec19a75441ebe994fa55 (diff)
downloadprosody-7198c65a154445377ccefa4c54f48b7f956ae79b.tar.gz
prosody-7198c65a154445377ccefa4c54f48b7f956ae79b.zip
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Diffstat (limited to 'util')
-rw-r--r--util/prosodyctl/check.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/util/prosodyctl/check.lua b/util/prosodyctl/check.lua
index 09d787ec..31adee8f 100644
--- a/util/prosodyctl/check.lua
+++ b/util/prosodyctl/check.lua
@@ -431,6 +431,41 @@ local function check(arg)
end
end
+ do
+ local orphan_components = {};
+ local referenced_components = set.new();
+ local enabled_hosts_set = set.new();
+ for host, host_options in it.filter("*", pairs(configmanager.getconfig())) do
+ if host_options.enabled ~= false then
+ enabled_hosts_set:add(host);
+ for _, disco_item in ipairs(host_options.disco_items or {}) do
+ referenced_components:add(disco_item[1]);
+ end
+ end
+ end
+ for host, host_config in enabled_hosts() do
+ local is_component = not not host_config.component_module;
+ if is_component then
+ local parent_domain = host:match("^[^.]+%.(.+)$");
+ local is_orphan = not (enabled_hosts_set:contains(parent_domain) or referenced_components:contains(host));
+ if is_orphan then
+ table.insert(orphan_components, host);
+ end
+ end
+ end
+ if #orphan_components > 0 then
+ table.sort(orphan_components);
+ print("");
+ print(" Your configuration contains the following unreferenced components:\n");
+ print(" "..table.concat(orphan_components, "\n "));
+ print("");
+ print(" Clients may not be able to discover these services because they are not linked to");
+ print(" any VirtualHost. They are automatically linked if they are direct subdomains of a");
+ print(" VirtualHost. Alternatively, you can explicitly link them using the disco_items option.");
+ print(" For more information see https://prosody.im/doc/modules/mod_disco#items");
+ end
+ end
+
print("Done.\n");
end
if not what or what == "dns" then