diff options
Diffstat (limited to 'util/prosodyctl')
-rw-r--r-- | util/prosodyctl/check.lua | 80 | ||||
-rw-r--r-- | util/prosodyctl/shell.lua | 6 |
2 files changed, 73 insertions, 13 deletions
diff --git a/util/prosodyctl/check.lua b/util/prosodyctl/check.lua index 554a64ef..75ff5da4 100644 --- a/util/prosodyctl/check.lua +++ b/util/prosodyctl/check.lua @@ -11,6 +11,7 @@ local jid_split = require "prosody.util.jid".prepped_split; local modulemanager = require "prosody.core.modulemanager"; local async = require "prosody.util.async"; local httputil = require "prosody.util.http"; +local human_units = require "prosody.util.human.units"; local function api(host) return setmetatable({ name = "prosodyctl.check"; host = host; log = prosody.log }, { __index = moduleapi }) @@ -650,6 +651,15 @@ local function check(arg) break; end end + + for host, host_config in pairs(config) do --luacheck: ignore 213/host + if type(rawget(host_config, "storage")) == "string" and rawget(host_config, "default_storage") then + print(""); + print(" The 'default_storage' option is not needed if 'storage' is set to a string."); + break; + end + end + local require_encryption = set.intersection(all_options, set.new({ "require_encryption", "c2s_require_encryption", "s2s_require_encryption" })):empty(); @@ -724,12 +734,17 @@ local function check(arg) local orphan_components = {}; local referenced_components = set.new(); local enabled_hosts_set = set.new(); + local invalid_disco_items = {}; for host in it.filter("*", pairs(configmanager.getconfig())) do local hostapi = api(host); if hostapi:get_option_boolean("enabled", true) then enabled_hosts_set:add(host); for _, disco_item in ipairs(hostapi:get_option_array("disco_items", {})) do - referenced_components:add(disco_item[1]); + if type(disco_item[1]) == "string" then + referenced_components:add(disco_item[1]); + else + invalid_disco_items[host] = true; + end end end end @@ -743,6 +758,18 @@ local function check(arg) end end end + + if next(invalid_disco_items) ~= nil then + print(""); + print(" Some hosts in your configuration file have an invalid 'disco_items' option."); + print(" This may cause further errors, such as unreferenced components."); + print(""); + for host in it.sorted_pairs(invalid_disco_items) do + print(" - "..host); + end + print(""); + end + if #orphan_components > 0 then table.sort(orphan_components); print(""); @@ -1493,6 +1520,10 @@ local function check(arg) local function print_feature_status(feature, host) if quiet then return; end print("", feature.ok and "OK" or "(!)", feature.name); + if feature.desc then + print("", "", feature.desc); + print(""); + end if not feature.ok then if feature.lacking_modules then table.sort(feature.lacking_modules); @@ -1552,6 +1583,11 @@ local function check(arg) end end end + if feature.meta then + for k, v in it.sorted_pairs(feature.meta) do + print("", "", (" - %s: %s"):format(k, v)); + end + end print(""); end @@ -1590,9 +1626,11 @@ local function check(arg) -- And components linked explicitly for _, disco_item in ipairs(hostapi:get_option_array("disco_items", {})) do local other_host = disco_item[1]; - local component_module = configmanager.get(other_host, "component_module"); - if component_module then - table.insert(host_components[component_module], other_host); + if type(other_host) == "string" then + local component_module = configmanager.get(other_host, "component_module"); + if component_module then + table.insert(host_components[component_module], other_host); + end end end end @@ -1638,29 +1676,33 @@ local function check(arg) current_feature.lacking_components = current_feature.lacking_components or {}; table.insert(current_feature.lacking_components, suggested); end + return found; end local features = { { name = "Basic functionality"; + desc = "Support for secure connections, authentication and messaging"; check = function () check_module("disco"); check_module("roster"); check_module("saslauth"); check_module("tls"); - check_module("pep"); end; }; { - name = "Multi-device sync"; + name = "Multi-device messaging and data synchronization"; + desc = "Multiple clients connected to the same account stay in sync"; check = function () check_module("carbons"); check_module("mam"); check_module("bookmarks"); + check_module("pep"); end; }; { name = "Mobile optimizations"; + desc = "Help mobile clients reduce battery and data usage"; check = function () check_module("smacks"); check_module("csi_simple", "csi_battery_saver"); @@ -1668,6 +1710,7 @@ local function check(arg) }; { name = "Web connections"; + desc = "Allow connections from browser-based web clients"; check = function () check_module("bosh"); check_module("websocket"); @@ -1675,24 +1718,28 @@ local function check(arg) }; { name = "User profiles"; + desc = "Enable users to publish profile information"; check = function () check_module("vcard_legacy", "vcard"); end; }; { name = "Blocking"; + desc = "Block communication with chosen entities"; check = function () check_module("blocklist"); end; }; { name = "Push notifications"; + desc = "Receive notifications on platforms that don't support persistent connections"; check = function () check_module("cloud_notify"); end; }; { - name = "Audio/video calls"; + name = "Audio/video calls and P2P"; + desc = "Assist clients in setting up connections between each other"; check = function () check_module( "turn_external", @@ -1704,12 +1751,25 @@ local function check(arg) }; { name = "File sharing"; - check = function () - check_component("http_file_share", "http_upload", "http_upload_external"); + desc = "Sharing of files to groups and offline users"; + check = function (self) + local service = check_component("http_file_share", "http_upload", "http_upload_external"); + if service then + local size_limit; + if api(service):get_option("component_module") == "http_file_share" then + size_limit = api(service):get_option_number("http_file_share_size_limit", 10*1024*1024); + end + if size_limit then + self.meta = { + ["Size limit"] = human_units.format(size_limit, "b", "b"); + }; + end + end end; }; { name = "Group chats"; + desc = "Create group chats and channels"; check = function () check_component("muc"); end; @@ -1722,7 +1782,7 @@ local function check(arg) for _, feature in ipairs(features) do current_feature = feature; - feature.check(); + feature:check(); feature.ok = ( not feature.lacking_modules and not feature.lacking_components and diff --git a/util/prosodyctl/shell.lua b/util/prosodyctl/shell.lua index d72cf294..31936989 100644 --- a/util/prosodyctl/shell.lua +++ b/util/prosodyctl/shell.lua @@ -29,8 +29,8 @@ local function read_line(prompt_string) end end -local function send_line(client, line) - client.send(st.stanza("repl-input", { width = tostring(term_width()) }):text(line)); +local function send_line(client, line, interactive) + client.send(st.stanza("repl-input", { width = tostring(term_width()), repl = interactive == false and "0" or "1" }):text(line)); end local function repl(client) @@ -91,7 +91,7 @@ local function start(arg) --luacheck: ignore 212/arg end client.events.add_handler("connected", function() - send_line(client, arg[1]); + send_line(client, arg[1], false); return true; end, 1); |