# HG changeset patch # User Matthew Wild # Date 1646235924 0 # Node ID 239ce74aa6a4a36c909f9b9b35eac52accb6d4da # Parent b4f2027ef917052fedf186baf202bee33fea94e3 util.prosodyctl: check: warn about unreferenced components, suggest disco_items diff -r b4f2027ef917 -r 239ce74aa6a4 util/prosodyctl/check.lua --- a/util/prosodyctl/check.lua Wed Mar 02 15:22:12 2022 +0000 +++ b/util/prosodyctl/check.lua Wed Mar 02 15:45:24 2022 +0000 @@ -431,6 +431,41 @@ 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