Software /
code /
prosody
Comparison
util/prosodyctl/check.lua @ 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 |
parent | 11783:7bf246e6792b |
child | 11799:8c9ec2db1d95 |
comparison
equal
deleted
inserted
replaced
11797:72a2b85c0537 | 11798:ba88060fa145 |
---|---|
61 if arg[1] == "--help" then | 61 if arg[1] == "--help" then |
62 show_usage([[check]], [[Perform basic checks on your Prosody installation]]); | 62 show_usage([[check]], [[Perform basic checks on your Prosody installation]]); |
63 return 1; | 63 return 1; |
64 end | 64 end |
65 local what = table.remove(arg, 1); | 65 local what = table.remove(arg, 1); |
66 local array = require "util.array"; | |
66 local set = require "util.set"; | 67 local set = require "util.set"; |
67 local it = require "util.iterators"; | 68 local it = require "util.iterators"; |
68 local ok = true; | 69 local ok = true; |
69 local function disabled_hosts(host, conf) return host ~= "*" and conf.enabled ~= false; end | 70 local function disabled_hosts(host, conf) return host ~= "*" and conf.enabled ~= false; end |
70 local function enabled_hosts() return it.filter(disabled_hosts, pairs(configmanager.getconfig())); end | 71 local function enabled_hosts() return it.filter(disabled_hosts, pairs(configmanager.getconfig())); end |
88 print"" | 89 print"" |
89 end | 90 end |
90 end | 91 end |
91 if not what or what == "config" then | 92 if not what or what == "config" then |
92 print("Checking config..."); | 93 print("Checking config..."); |
93 local deprecated = set.new({ | 94 local obsolete = set.new({ --> remove |
94 "anonymous_login", | |
95 "bosh_ports", | |
96 "cross_domain_bosh", | 95 "cross_domain_bosh", |
97 "cross_domain_websocket", | 96 "cross_domain_websocket", |
98 "daemonize", | |
99 "disallow_s2s", | |
100 "legacy_ssl_interfaces", | |
101 "legacy_ssl_port", | |
102 "legacy_ssl_ports", | |
103 "legacy_ssl_ssl", | |
104 "no_daemonize", | |
105 "require_encryption", | |
106 "vcard_compatibility", | |
107 }); | 97 }); |
98 local deprecated_replacements = { | |
99 anonymous_login = "use 'authentication = \"anonymous\"'", | |
100 daemonize = "use the --daemonize/-D or --foreground/-F command line flags", | |
101 disallow_s2s = "add \"s2s\" to 'modules_disabled'", | |
102 no_daemonize = "use the --daemonize/-D or --foreground/-F flags", | |
103 require_encryption = "use 'c2s_require_encryption' and 's2s_require_encryption'", | |
104 vcard_compatibility = "use 'mod_compat_vcard' from prosody-modules", | |
105 }; | |
106 local deprecated_ports = { bosh = "http", legacy_ssl = "c2s_direct_tls" }; | |
107 local port_suffixes = set.new({ "port", "ports", "interface", "interfaces", "ssl" }); | |
108 for port, replacement in pairs(deprecated_ports) do | |
109 for suffix in port_suffixes do | |
110 deprecated_replacements[port.."_"..suffix] = "use '"..replacement.."_"..suffix.."'" | |
111 end | |
112 end | |
113 local deprecated = set.new(array.collect(it.keys(deprecated_replacements))); | |
108 local known_global_options = set.new({ | 114 local known_global_options = set.new({ |
109 "access_control_allow_credentials", | 115 "access_control_allow_credentials", |
110 "access_control_allow_headers", | 116 "access_control_allow_headers", |
111 "access_control_allow_methods", | 117 "access_control_allow_methods", |
112 "access_control_max_age", | 118 "access_control_max_age", |
219 end | 225 end |
220 end | 226 end |
221 | 227 |
222 -- Check for global options under hosts | 228 -- Check for global options under hosts |
223 local global_options = set.new(it.to_array(it.keys(config["*"]))); | 229 local global_options = set.new(it.to_array(it.keys(config["*"]))); |
230 local obsolete_global_options = set.intersection(global_options, obsolete); | |
231 if not obsolete_global_options:empty() then | |
232 print(""); | |
233 print(" You have some obsolete options you can remove from the global section:"); | |
234 print(" "..tostring(obsolete_global_options)) | |
235 ok = false; | |
236 end | |
224 local deprecated_global_options = set.intersection(global_options, deprecated); | 237 local deprecated_global_options = set.intersection(global_options, deprecated); |
225 if not deprecated_global_options:empty() then | 238 if not deprecated_global_options:empty() then |
226 print(""); | 239 print(""); |
227 print(" You have some deprecated options in the global section:"); | 240 print(" You have some deprecated options in the global section:"); |
228 print(" "..tostring(deprecated_global_options)) | 241 for option in deprecated_global_options do |
242 print((" '%s' -- instead, %s"):format(option, deprecated_replacements[option])); | |
243 end | |
229 ok = false; | 244 ok = false; |
230 -- FIXME show replacement options where applicable | |
231 end | 245 end |
232 for host, options in it.filter(function (h) return h ~= "*" end, pairs(configmanager.getconfig())) do | 246 for host, options in it.filter(function (h) return h ~= "*" end, pairs(configmanager.getconfig())) do |
233 local host_options = set.new(it.to_array(it.keys(options))); | 247 local host_options = set.new(it.to_array(it.keys(options))); |
234 local misplaced_options = set.intersection(host_options, known_global_options); | 248 local misplaced_options = set.intersection(host_options, known_global_options); |
235 for name in pairs(options) do | 249 for name in pairs(options) do |