Comparison

util/prosodyctl/check.lua @ 13771:5f26164c738f

Merge 13.0->trunk
author Matthew Wild <mwild1@gmail.com>
date Thu, 13 Mar 2025 11:41:32 +0000
parent 13768:4365f0f03c33
child 13778:b6d0f1d79b60
comparison
equal deleted inserted replaced
13766:b11242656300 13771:5f26164c738f
9 local socket_url = require "socket.url"; 9 local socket_url = require "socket.url";
10 local jid_split = require "prosody.util.jid".prepped_split; 10 local jid_split = require "prosody.util.jid".prepped_split;
11 local modulemanager = require "prosody.core.modulemanager"; 11 local modulemanager = require "prosody.core.modulemanager";
12 local async = require "prosody.util.async"; 12 local async = require "prosody.util.async";
13 local httputil = require "prosody.util.http"; 13 local httputil = require "prosody.util.http";
14 local human_units = require "prosody.util.human.units";
14 15
15 local function api(host) 16 local function api(host)
16 return setmetatable({ name = "prosodyctl.check"; host = host; log = prosody.log }, { __index = moduleapi }) 17 return setmetatable({ name = "prosodyctl.check"; host = host; log = prosody.log }, { __index = moduleapi })
17 end 18 end
18 19
1491 }; 1492 };
1492 1493
1493 local function print_feature_status(feature, host) 1494 local function print_feature_status(feature, host)
1494 if quiet then return; end 1495 if quiet then return; end
1495 print("", feature.ok and "OK" or "(!)", feature.name); 1496 print("", feature.ok and "OK" or "(!)", feature.name);
1497 if feature.desc then
1498 print("", "", feature.desc);
1499 print("");
1500 end
1496 if not feature.ok then 1501 if not feature.ok then
1497 if feature.lacking_modules then 1502 if feature.lacking_modules then
1498 table.sort(feature.lacking_modules); 1503 table.sort(feature.lacking_modules);
1499 print("", "", "Suggested modules: "); 1504 print("", "", "Suggested modules: ");
1500 for _, module in ipairs(feature.lacking_modules) do 1505 for _, module in ipairs(feature.lacking_modules) do
1548 for _, mod in ipairs(problem.missing_mods) do 1553 for _, mod in ipairs(problem.missing_mods) do
1549 print("", "", "", (" %q; -- Add this!"):format(mod)); 1554 print("", "", "", (" %q; -- Add this!"):format(mod));
1550 end 1555 end
1551 print("", "", "", (" }")); 1556 print("", "", "", (" }"));
1552 end 1557 end
1558 end
1559 end
1560 if feature.meta then
1561 for k, v in it.sorted_pairs(feature.meta) do
1562 print("", "", (" - %s: %s"):format(k, v));
1553 end 1563 end
1554 end 1564 end
1555 print(""); 1565 print("");
1556 end 1566 end
1557 1567
1636 end 1646 end
1637 if not found then 1647 if not found then
1638 current_feature.lacking_components = current_feature.lacking_components or {}; 1648 current_feature.lacking_components = current_feature.lacking_components or {};
1639 table.insert(current_feature.lacking_components, suggested); 1649 table.insert(current_feature.lacking_components, suggested);
1640 end 1650 end
1651 return found;
1641 end 1652 end
1642 1653
1643 local features = { 1654 local features = {
1644 { 1655 {
1645 name = "Basic functionality"; 1656 name = "Basic functionality";
1657 desc = "Support for secure connections, authentication and messaging";
1646 check = function () 1658 check = function ()
1647 check_module("disco"); 1659 check_module("disco");
1648 check_module("roster"); 1660 check_module("roster");
1649 check_module("saslauth"); 1661 check_module("saslauth");
1650 check_module("tls"); 1662 check_module("tls");
1663 end;
1664 };
1665 {
1666 name = "Multi-device messaging and data synchronization";
1667 desc = "Multiple clients connected to the same account stay in sync";
1668 check = function ()
1669 check_module("carbons");
1670 check_module("mam");
1671 check_module("bookmarks");
1651 check_module("pep"); 1672 check_module("pep");
1652 end; 1673 end;
1653 }; 1674 };
1654 { 1675 {
1655 name = "Multi-device sync";
1656 check = function ()
1657 check_module("carbons");
1658 check_module("mam");
1659 check_module("bookmarks");
1660 end;
1661 };
1662 {
1663 name = "Mobile optimizations"; 1676 name = "Mobile optimizations";
1677 desc = "Help mobile clients reduce battery and data usage";
1664 check = function () 1678 check = function ()
1665 check_module("smacks"); 1679 check_module("smacks");
1666 check_module("csi_simple", "csi_battery_saver"); 1680 check_module("csi_simple", "csi_battery_saver");
1667 end; 1681 end;
1668 }; 1682 };
1669 { 1683 {
1670 name = "Web connections"; 1684 name = "Web connections";
1685 desc = "Allow connections from browser-based web clients";
1671 check = function () 1686 check = function ()
1672 check_module("bosh"); 1687 check_module("bosh");
1673 check_module("websocket"); 1688 check_module("websocket");
1674 end; 1689 end;
1675 }; 1690 };
1676 { 1691 {
1677 name = "User profiles"; 1692 name = "User profiles";
1693 desc = "Enable users to publish profile information";
1678 check = function () 1694 check = function ()
1679 check_module("vcard_legacy", "vcard"); 1695 check_module("vcard_legacy", "vcard");
1680 end; 1696 end;
1681 }; 1697 };
1682 { 1698 {
1683 name = "Blocking"; 1699 name = "Blocking";
1700 desc = "Block communication with chosen entities";
1684 check = function () 1701 check = function ()
1685 check_module("blocklist"); 1702 check_module("blocklist");
1686 end; 1703 end;
1687 }; 1704 };
1688 { 1705 {
1689 name = "Push notifications"; 1706 name = "Push notifications";
1707 desc = "Receive notifications on platforms that don't support persistent connections";
1690 check = function () 1708 check = function ()
1691 check_module("cloud_notify"); 1709 check_module("cloud_notify");
1692 end; 1710 end;
1693 }; 1711 };
1694 { 1712 {
1695 name = "Audio/video calls"; 1713 name = "Audio/video calls and P2P";
1714 desc = "Assist clients in setting up connections between each other";
1696 check = function () 1715 check = function ()
1697 check_module( 1716 check_module(
1698 "turn_external", 1717 "turn_external",
1699 "external_services", 1718 "external_services",
1700 "turncredentials", 1719 "turncredentials",
1702 ); 1721 );
1703 end; 1722 end;
1704 }; 1723 };
1705 { 1724 {
1706 name = "File sharing"; 1725 name = "File sharing";
1707 check = function () 1726 desc = "Sharing of files to groups and offline users";
1708 check_component("http_file_share", "http_upload", "http_upload_external"); 1727 check = function (self)
1728 local service = check_component("http_file_share", "http_upload", "http_upload_external");
1729 if service then
1730 local size_limit;
1731 if api(service):get_option("component_module") == "http_file_share" then
1732 size_limit = api(service):get_option_number("http_file_share_size_limit", 10*1024*1024);
1733 end
1734 if size_limit then
1735 self.meta = {
1736 ["Size limit"] = human_units.format(size_limit, "b", "b");
1737 };
1738 end
1739 end
1709 end; 1740 end;
1710 }; 1741 };
1711 { 1742 {
1712 name = "Group chats"; 1743 name = "Group chats";
1744 desc = "Create group chats and channels";
1713 check = function () 1745 check = function ()
1714 check_component("muc"); 1746 check_component("muc");
1715 end; 1747 end;
1716 }; 1748 };
1717 }; 1749 };
1720 print(host); 1752 print(host);
1721 end 1753 end
1722 1754
1723 for _, feature in ipairs(features) do 1755 for _, feature in ipairs(features) do
1724 current_feature = feature; 1756 current_feature = feature;
1725 feature.check(); 1757 feature:check();
1726 feature.ok = ( 1758 feature.ok = (
1727 not feature.lacking_modules and 1759 not feature.lacking_modules and
1728 not feature.lacking_components and 1760 not feature.lacking_components and
1729 not feature.lacking_component_modules 1761 not feature.lacking_component_modules
1730 ); 1762 );