Software /
code /
prosody
Changeset
11798:ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 14 Sep 2021 01:34:30 +0200 |
parents | 11797:72a2b85c0537 |
children | 11799:8c9ec2db1d95 |
files | util/prosodyctl/check.lua |
diffstat | 1 files changed, 28 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/util/prosodyctl/check.lua Sun Sep 12 21:31:04 2021 +0200 +++ b/util/prosodyctl/check.lua Tue Sep 14 01:34:30 2021 +0200 @@ -63,6 +63,7 @@ return 1; end local what = table.remove(arg, 1); + local array = require "util.array"; local set = require "util.set"; local it = require "util.iterators"; local ok = true; @@ -90,21 +91,26 @@ end if not what or what == "config" then print("Checking config..."); - local deprecated = set.new({ - "anonymous_login", - "bosh_ports", + local obsolete = set.new({ --> remove "cross_domain_bosh", "cross_domain_websocket", - "daemonize", - "disallow_s2s", - "legacy_ssl_interfaces", - "legacy_ssl_port", - "legacy_ssl_ports", - "legacy_ssl_ssl", - "no_daemonize", - "require_encryption", - "vcard_compatibility", }); + local deprecated_replacements = { + anonymous_login = "use 'authentication = \"anonymous\"'", + daemonize = "use the --daemonize/-D or --foreground/-F command line flags", + disallow_s2s = "add \"s2s\" to 'modules_disabled'", + no_daemonize = "use the --daemonize/-D or --foreground/-F flags", + require_encryption = "use 'c2s_require_encryption' and 's2s_require_encryption'", + vcard_compatibility = "use 'mod_compat_vcard' from prosody-modules", + }; + local deprecated_ports = { bosh = "http", legacy_ssl = "c2s_direct_tls" }; + local port_suffixes = set.new({ "port", "ports", "interface", "interfaces", "ssl" }); + for port, replacement in pairs(deprecated_ports) do + for suffix in port_suffixes do + deprecated_replacements[port.."_"..suffix] = "use '"..replacement.."_"..suffix.."'" + end + end + local deprecated = set.new(array.collect(it.keys(deprecated_replacements))); local known_global_options = set.new({ "access_control_allow_credentials", "access_control_allow_headers", @@ -221,13 +227,21 @@ -- Check for global options under hosts local global_options = set.new(it.to_array(it.keys(config["*"]))); + local obsolete_global_options = set.intersection(global_options, obsolete); + if not obsolete_global_options:empty() then + print(""); + print(" You have some obsolete options you can remove from the global section:"); + print(" "..tostring(obsolete_global_options)) + ok = false; + end local deprecated_global_options = set.intersection(global_options, deprecated); if not deprecated_global_options:empty() then print(""); print(" You have some deprecated options in the global section:"); - print(" "..tostring(deprecated_global_options)) + for option in deprecated_global_options do + print((" '%s' -- instead, %s"):format(option, deprecated_replacements[option])); + end ok = false; - -- FIXME show replacement options where applicable end for host, options in it.filter(function (h) return h ~= "*" end, pairs(configmanager.getconfig())) do local host_options = set.new(it.to_array(it.keys(options)));