changeset 14050:64cd905cb1de

util.prosodyctl.check: Do not suggest renaming domain to public suffix Adds optional dependency on https://github.com/daurnimator/lua-psl
author Kim Alvefur <zash@zash.se>
date Thu, 22 Jan 2026 17:54:30 +0100
parents 04c3687b5641
children 797f4c7e5f3e
files util/prosodyctl/check.lua
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/prosodyctl/check.lua	Tue Jan 20 11:45:19 2026 +0000
+++ b/util/prosodyctl/check.lua	Thu Jan 22 17:54:30 2026 +0100
@@ -12,6 +12,7 @@
 local async = require "prosody.util.async";
 local httputil = require "prosody.util.http";
 local human_units = require "prosody.util.human.units";
+local have_psl, publicsuffix = pcall(require, "psl");
 
 local function api(host)
 	return setmetatable({ name = "prosodyctl.check"; host = host; log = prosody.log }, { __index = moduleapi })
@@ -588,15 +589,16 @@
 				print("    You need to move the following option"..(n>1 and "s" or "")..": "..table.concat(it.to_array(misplaced_options), ", "));
 			end
 		end
+		local psl = have_psl and publicsuffix.latest(api("*"):get_option_string("public_suffix_file", nil));
 		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.
+			-- unless lua-psl is installed
 			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") and (suggestion:match("%."))then
+			   or subdomain == "chat" or subdomain == "im") and (suggestion:match("%.") or psl and not psl:is_public_suffix(suggestion)) then
 				print("");
 				print("    Suggestion: If "..host.. " is a new host with no real users yet, consider renaming it now to");
 				print("     "..suggestion..". You can use SRV records to redirect XMPP clients and servers to "..host..".");