diff util/prosodyctl/check.lua @ 14045:76dba6ddf502

util.prosodyctl.check: Don't suggest renaming VirtualHost to bare TLD Suggesting renaming your VirtualHost to "com" if you had "xmpp.com" is not very helpful. Unfortunately this is non-trivial given second level hierarchies like .co.uk without using something like the Public Suffix List or IETF work like draft-ietf-deleg.
author Kim Alvefur <zash@zash.se>
date Mon, 19 Jan 2026 12:09:40 +0100
parents 8078eebf5601
children f5d415d54064
line wrap: on
line diff
--- a/util/prosodyctl/check.lua	Mon Jan 12 07:45:59 2026 +0100
+++ b/util/prosodyctl/check.lua	Mon Jan 19 12:09:40 2026 +0100
@@ -591,13 +591,17 @@
 			end
 		end
 		for host, options in enabled_hosts() do
+			-- This is meant to prod people away from xmpp.example.com towards example.com,
+			-- but will not do the right thing with second level hierarchies like .co.uk
+			-- This could be improved by using the Public Suffix List or a similar method.
 			local host_options = set.new(it.to_array(it.keys(options)));
 			local subdomain = host:match("^[^.]+");
+			local suggestion = host:gsub("^[^.]+%.", "");
 			if not(host_options:contains("component_module")) and (subdomain == "jabber" or subdomain == "xmpp"
-			   or subdomain == "chat" or subdomain == "im") then
+			   or subdomain == "chat" or subdomain == "im") and (suggestion:match("%."))then
 				print("");
 				print("    Suggestion: If "..host.. " is a new host with no real users yet, consider renaming it now to");
-				print("     "..host:gsub("^[^.]+%.", "")..". You can use SRV records to redirect XMPP clients and servers to "..host..".");
+				print("     "..suggestion..". You can use SRV records to redirect XMPP clients and servers to "..host..".");
 				print("     For more information see: https://prosody.im/doc/dns");
 			end
 		end