util: Prefix module imports with prosody namespace

This commit is contained in:
Kim Alvefur 2023-03-17 16:23:16 +01:00
parent 869581384d
commit 43531740f9
68 changed files with 246 additions and 246 deletions

View file

@ -1,15 +1,15 @@
local st = require "util.stanza"; local st = require "prosody.util.stanza";
local new_xmpp_stream = require "util.xmppstream".new; local new_xmpp_stream = require "prosody.util.xmppstream".new;
local sessionlib = require "util.session"; local sessionlib = require "prosody.util.session";
local gettime = require "util.time".now; local gettime = require "prosody.util.time".now;
local runner = require "util.async".runner; local runner = require "prosody.util.async".runner;
local add_task = require "util.timer".add_task; local add_task = require "prosody.util.timer".add_task;
local events = require "util.events"; local events = require "prosody.util.events";
local server = require "net.server"; local server = require "prosody.net.server";
local stream_close_timeout = 5; local stream_close_timeout = 5;
local log = require "util.logger".init("adminstream"); local log = require "prosody.util.logger".init("adminstream");
local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams";

View file

@ -8,7 +8,7 @@
local t_insert, t_sort, t_remove, t_concat local t_insert, t_sort, t_remove, t_concat
= table.insert, table.sort, table.remove, table.concat; = table.insert, table.sort, table.remove, table.concat;
local t_move = require "util.table".move; local t_move = require "prosody.util.table".move;
local setmetatable = setmetatable; local setmetatable = setmetatable;
local getmetatable = getmetatable; local getmetatable = getmetatable;

View file

@ -1,7 +1,7 @@
local logger = require "util.logger"; local logger = require "prosody.util.logger";
local log = logger.init("util.async"); local log = logger.init("util.async");
local new_id = require "util.id".short; local new_id = require "prosody.util.id".short;
local xpcall = require "util.xpcall".xpcall; local xpcall = require "prosody.util.xpcall".xpcall;
local function checkthread() local function checkthread()
local thread, main = coroutine.running(); local thread, main = coroutine.running();

View file

@ -9,7 +9,7 @@ end
do do
-- Lua 5.3 and 5.4 would be able to use native infix operators -- Lua 5.3 and 5.4 would be able to use native infix operators
local ok, bitop = pcall(require, "util.bit53") local ok, bitop = pcall(require, "prosody.util.bit53")
if ok then if ok then
return bitop; return bitop;
end end

View file

@ -6,8 +6,8 @@
-- COPYING file in the source package for more information. -- COPYING file in the source package for more information.
-- --
local base64 = require "util.encodings".base64.encode; local base64 = require "prosody.util.encodings".base64.encode;
local sha1 = require "util.hashes".sha1; local sha1 = require "prosody.util.hashes".sha1;
local t_insert, t_sort, t_concat = table.insert, table.sort, table.concat; local t_insert, t_sort, t_concat = table.insert, table.sort, table.concat;
local ipairs = ipairs; local ipairs = ipairs;

View file

@ -12,9 +12,9 @@ local type, next = type, next;
local tonumber = tonumber; local tonumber = tonumber;
local tostring = tostring; local tostring = tostring;
local t_concat = table.concat; local t_concat = table.concat;
local st = require "util.stanza"; local st = require "prosody.util.stanza";
local jid_prep = require "util.jid".prep; local jid_prep = require "prosody.util.jid".prep;
local datetime = require "util.datetime"; local datetime = require "prosody.util.datetime";
local _ENV = nil; local _ENV = nil;
-- luacheck: std none -- luacheck: std none

View file

@ -12,7 +12,7 @@ local setmetatable = setmetatable;
local ipairs = ipairs; local ipairs = ipairs;
local char = string.char; local char = string.char;
local pcall = pcall; local pcall = pcall;
local log = require "util.logger".init("datamanager"); local log = require "prosody.util.logger".init("datamanager");
local io_open = io.open; local io_open = io.open;
local os_remove = os.remove; local os_remove = os.remove;
local os_rename = os.rename; local os_rename = os.rename;
@ -21,8 +21,8 @@ local next = next;
local type = type; local type = type;
local t_insert = table.insert; local t_insert = table.insert;
local t_concat = table.concat; local t_concat = table.concat;
local envloadfile = require"util.envload".envloadfile; local envloadfile = require"prosody.util.envload".envloadfile;
local serialize = require "util.serialization".serialize; local serialize = require "prosody.util.serialization".serialize;
local lfs = require "lfs"; local lfs = require "lfs";
-- Extract directory separator from package.config (an undocumented string that comes with lua) -- Extract directory separator from package.config (an undocumented string that comes with lua)
local path_separator = assert ( package.config:match ( "^([^\n]+)" ) , "package.config not in standard form" ) local path_separator = assert ( package.config:match ( "^([^\n]+)" ) , "package.config not in standard form" )
@ -33,7 +33,7 @@ local raw_mkdir = lfs.mkdir;
local atomic_append; local atomic_append;
local ENOENT = 2; local ENOENT = 2;
pcall(function() pcall(function()
local pposix = require "util.pposix"; local pposix = require "prosody.util.pposix";
raw_mkdir = pposix.mkdir or raw_mkdir; -- Doesn't trample on umask raw_mkdir = pposix.mkdir or raw_mkdir; -- Doesn't trample on umask
atomic_append = pposix.atomic_append; atomic_append = pposix.atomic_append;
ENOENT = pposix.ENOENT or ENOENT; ENOENT = pposix.ENOENT or ENOENT;

View file

@ -1,11 +1,11 @@
-- This file is generated from teal-src/util/datamapper.lua -- This file is generated from teal-src/util/datamapper.lua
if not math.type then if not math.type then
require("util.mathcompat") require("prosody.util.mathcompat")
end end
local st = require("util.stanza"); local st = require("prosody.util.stanza");
local pointer = require("util.jsonpointer"); local pointer = require("prosody.util.jsonpointer");
local schema_t = {} local schema_t = {}

View file

@ -1,4 +1,4 @@
local queue = require "util.queue"; local queue = require "prosody.util.queue";
local s_byte, s_sub = string.byte, string.sub; local s_byte, s_sub = string.byte, string.sub;
local dbuffer_methods = {}; local dbuffer_methods = {};

View file

@ -12,7 +12,7 @@ local censored_names = {
}; };
local optimal_line_length = 65; local optimal_line_length = 65;
local termcolours = require "util.termcolours"; local termcolours = require "prosody.util.termcolours";
local getstring = termcolours.getstring; local getstring = termcolours.getstring;
local styles; local styles;
do do

View file

@ -7,7 +7,7 @@
-- --
local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end
local platform_table = require "util.human.io".table({ { width = 15, align = "right" }, { width = "100%" } }); local platform_table = require "prosody.util.human.io".table({ { width = 15, align = "right" }, { width = "100%" } });
-- Required to be able to find packages installed with luarocks -- Required to be able to find packages installed with luarocks
if not softreq "luarocks.loader" then -- LuaRocks 2.x if not softreq "luarocks.loader" then -- LuaRocks 2.x
@ -88,7 +88,7 @@ local function check_dependencies()
}, nil, err); }, nil, err);
end end
local bit, err = softreq"util.bitcompat"; local bit, err = softreq"prosody.util.bitcompat";
if not bit then if not bit then
missingdep("lua-bitops", { missingdep("lua-bitops", {
@ -106,16 +106,16 @@ local function check_dependencies()
{ "Source", "https://www.zash.se/luaunbound.html" }; { "Source", "https://www.zash.se/luaunbound.html" };
}, "Old DNS resolver library will be used", err); }, "Old DNS resolver library will be used", err);
else else
package.preload["net.adns"] = function () package.preload["prosody.net.adns"] = function ()
local ub = require "net.unbound"; local ub = require "prosody.net.unbound";
return ub; return ub;
end end
end end
local encodings, err = softreq "util.encodings" local encodings, err = softreq "prosody.util.encodings"
if not encodings then if not encodings then
if err:match("module '[^']*' not found") then if err:match("module '[^']*' not found") then
missingdep("util.encodings", { missingdep("prosody.util.encodings", {
{ "Windows", "Make sure you have encodings.dll from the Prosody distribution in util/" }; { "Windows", "Make sure you have encodings.dll from the Prosody distribution in util/" };
{ "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so" }; { "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so" };
}); });
@ -130,10 +130,10 @@ local function check_dependencies()
fatal = true; fatal = true;
end end
local hashes, err = softreq "util.hashes" local hashes, err = softreq "prosody.util.hashes"
if not hashes then if not hashes then
if err:match("module '[^']*' not found") then if err:match("module '[^']*' not found") then
missingdep("util.hashes", { missingdep("prosody.util.hashes", {
{ "Windows", "Make sure you have hashes.dll from the Prosody distribution in util/" }; { "Windows", "Make sure you have hashes.dll from the Prosody distribution in util/" };
{ "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so" }; { "GNU/Linux", "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so" };
}); });

View file

@ -12,9 +12,9 @@ local s_byte = string.byte;
local s_format = string.format; local s_format = string.format;
local s_sub = string.sub; local s_sub = string.sub;
local iana_data = require "util.dnsregistry"; local iana_data = require "prosody.util.dnsregistry";
local tohex = require "util.hex".encode; local tohex = require "prosody.util.hex".encode;
local inet_ntop = require "util.net".ntop; local inet_ntop = require "prosody.util.net".ntop;
-- Simplified versions of Waqas DNS parsers -- Simplified versions of Waqas DNS parsers
-- Only the per RR parsers are needed and only feed a single RR -- Only the per RR parsers are needed and only feed a single RR

View file

@ -1,4 +1,4 @@
local id = require "util.id"; local id = require "prosody.util.id";
local util_debug; -- only imported on-demand local util_debug; -- only imported on-demand
@ -19,7 +19,7 @@ local function configure(opt)
if opt.auto_inject_traceback ~= nil then if opt.auto_inject_traceback ~= nil then
auto_inject_traceback = opt.auto_inject_traceback; auto_inject_traceback = opt.auto_inject_traceback;
if auto_inject_traceback then if auto_inject_traceback then
util_debug = require "util.debug"; util_debug = require "prosody.util.debug";
end end
end end
end end

View file

@ -8,9 +8,9 @@
local tostring = tostring; local tostring = tostring;
local unpack = table.unpack; local unpack = table.unpack;
local pack = table.pack; local pack = table.pack;
local valid_utf8 = require "util.encodings".utf8.valid; local valid_utf8 = require "prosody.util.encodings".utf8.valid;
local type = type; local type = type;
local dump = require "util.serialization".new("debug"); local dump = require "prosody.util.serialization".new("debug");
local num_type = math.type; local num_type = math.type;
-- In Lua 5.3+ these formats throw an error if given a float -- In Lua 5.3+ these formats throw an error if given a float

View file

@ -1,4 +1,4 @@
local set = require "util.set"; local set = require "prosody.util.set";
local known_options = { local known_options = {
incremental = set.new { "mode", "threshold", "speed", "step_size" }; incremental = set.new { "mode", "threshold", "speed", "step_size" };

View file

@ -1,4 +1,4 @@
local it = require "util.iterators"; local it = require "prosody.util.iterators";
local function generate_ring(nodes, num_replicas, hash) local function generate_ring(nodes, num_replicas, hash)
local new_ring = {}; local new_ring = {};

View file

@ -6,11 +6,11 @@
-- COPYING file in the source package for more information. -- COPYING file in the source package for more information.
-- --
local debug = require "util.debug"; local debug = require "prosody.util.debug";
-- Helper functions for debugging -- Helper functions for debugging
local log = require "util.logger".init("util.debug"); local log = require "prosody.util.logger".init("util.debug");
local function log_events(events, name, logger) local function log_events(events, name, logger)
local f = events.fire_event; local f = events.fire_event;

View file

@ -8,7 +8,7 @@
-- COMPAT: Only for external pre-0.9 modules -- COMPAT: Only for external pre-0.9 modules
local hashes = require "util.hashes" local hashes = require "prosody.util.hashes"
return { return {
md5 = hashes.hmac_md5, md5 = hashes.hmac_md5,

View file

@ -1,5 +1,5 @@
local array = require "util.array"; local array = require "prosody.util.array";
local utf8 = rawget(_G, "utf8") or require"util.encodings".utf8; local utf8 = rawget(_G, "utf8") or require"prosody.util.encodings".utf8;
local len = utf8.len or function(s) local len = utf8.len or function(s)
local _, count = s:gsub("[%z\001-\127\194-\253][\128-\191]*", ""); local _, count = s:gsub("[%z\001-\127\194-\253][\128-\191]*", "");
return count; return count;

View file

@ -8,8 +8,8 @@
-- --
local s_gsub = string.gsub; local s_gsub = string.gsub;
local random_bytes = require "util.random".bytes; local random_bytes = require "prosody.util.random".bytes;
local base64_encode = require "util.encodings".base64.encode; local base64_encode = require "prosody.util.encodings".base64.encode;
local b64url = { ["+"] = "-", ["/"] = "_", ["="] = "" }; local b64url = { ["+"] = "-", ["/"] = "_", ["="] = "" };
local function b64url_random(len) local function b64url_random(len)

View file

@ -5,8 +5,8 @@
-- COPYING file in the source package for more information. -- COPYING file in the source package for more information.
-- --
local net = require "util.net"; local net = require "prosody.util.net";
local hex = require "util.hex"; local hex = require "prosody.util.hex";
local ip_methods = {}; local ip_methods = {};

View file

@ -10,9 +10,9 @@
local select = select; local select = select;
local match, sub = string.match, string.sub; local match, sub = string.match, string.sub;
local nodeprep = require "util.encodings".stringprep.nodeprep; local nodeprep = require "prosody.util.encodings".stringprep.nodeprep;
local nameprep = require "util.encodings".stringprep.nameprep; local nameprep = require "prosody.util.encodings".stringprep.nameprep;
local resourceprep = require "util.encodings".stringprep.resourceprep; local resourceprep = require "prosody.util.encodings".stringprep.resourceprep;
local escapes = { local escapes = {
[" "] = "\\20"; ['"'] = "\\22"; [" "] = "\\20"; ['"'] = "\\22";

View file

@ -10,12 +10,12 @@ local type = type;
local t_insert, t_concat, t_remove = table.insert, table.concat, table.remove; local t_insert, t_concat, t_remove = table.insert, table.concat, table.remove;
local s_char = string.char; local s_char = string.char;
local tostring, tonumber = tostring, tonumber; local tostring, tonumber = tostring, tonumber;
local pairs, ipairs, spairs = pairs, ipairs, require "util.iterators".sorted_pairs; local pairs, ipairs, spairs = pairs, ipairs, require "prosody.util.iterators".sorted_pairs;
local next = next; local next = next;
local getmetatable, setmetatable = getmetatable, setmetatable; local getmetatable, setmetatable = getmetatable, setmetatable;
local print = print; local print = print;
local has_array, array = pcall(require, "util.array"); local has_array, array = pcall(require, "prosody.util.array");
local array_mt = has_array and getmetatable(array()) or {}; local array_mt = has_array and getmetatable(array()) or {};
--module("json") --module("json")

View file

@ -3,10 +3,10 @@
local m_type = function(n) local m_type = function(n)
return type(n) == "number" and n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; return type(n) == "number" and n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float";
end; end;
local json = require("util.json") local json = require("prosody.util.json")
local null = json.null; local null = json.null;
local pointer = require("util.jsonpointer") local pointer = require("prosody.util.jsonpointer")
local json_type_name = json.json_type_name local json_type_name = json.json_type_name

View file

@ -1,10 +1,10 @@
local s_gsub = string.gsub; local s_gsub = string.gsub;
local crypto = require "util.crypto"; local crypto = require "prosody.util.crypto";
local json = require "util.json"; local json = require "prosody.util.json";
local hashes = require "util.hashes"; local hashes = require "prosody.util.hashes";
local base64_encode = require "util.encodings".base64.encode; local base64_encode = require "prosody.util.encodings".base64.encode;
local base64_decode = require "util.encodings".base64.decode; local base64_decode = require "prosody.util.encodings".base64.decode;
local secure_equals = require "util.hashes".equals; local secure_equals = require "prosody.util.hashes".equals;
local b64url_rep = { ["+"] = "-", ["/"] = "_", ["="] = "", ["-"] = "+", ["_"] = "/" }; local b64url_rep = { ["+"] = "-", ["/"] = "_", ["="] = "", ["-"] = "+", ["_"] = "/" };
local function b64url(data) local function b64url(data)

View file

@ -72,7 +72,7 @@ local function add_level_sink(level, sink_function)
end end
local function add_simple_sink(simple_sink_function, levels) local function add_simple_sink(simple_sink_function, levels)
local format = require "util.format".format; local format = require "prosody.util.format".format;
local function sink_function(name, level, msg, ...) local function sink_function(name, level, msg, ...)
return simple_sink_function(name, level, format(msg, ...)); return simple_sink_function(name, level, format(msg, ...));
end end

View file

@ -19,12 +19,12 @@ defined in the I-D linked above.
-- metric constructor interface: -- metric constructor interface:
-- metric_ctor(..., family_name, labels, extra) -- metric_ctor(..., family_name, labels, extra)
local time = require "util.time".now; local time = require "prosody.util.time".now;
local select = select; local select = select;
local array = require "util.array"; local array = require "prosody.util.array";
local log = require "util.logger".init("util.openmetrics"); local log = require "prosody.util.logger".init("util.openmetrics");
local new_multitable = require "util.multitable".new; local new_multitable = require "prosody.util.multitable".new;
local iter_multitable = require "util.multitable".iter; local iter_multitable = require "prosody.util.multitable".iter;
local t_concat, t_insert = table.concat, table.insert; local t_concat, t_insert = table.concat, table.insert;
local t_pack, t_unpack = table.pack, table.unpack; local t_pack, t_unpack = table.pack, table.unpack;

View file

@ -5,7 +5,7 @@ local s_format = string.format;
local oid_xmppaddr = "1.3.6.1.5.5.7.8.5"; -- [XMPP-CORE] local oid_xmppaddr = "1.3.6.1.5.5.7.8.5"; -- [XMPP-CORE]
local oid_dnssrv = "1.3.6.1.5.5.7.8.7"; -- [SRV-ID] local oid_dnssrv = "1.3.6.1.5.5.7.8.7"; -- [SRV-ID]
local idna_to_ascii = require "util.encodings".idna.to_ascii; local idna_to_ascii = require "prosody.util.encodings".idna.to_ascii;
local _M = {}; local _M = {};
local config = {}; local config = {};

View file

@ -1,13 +1,13 @@
local crypto = require "util.crypto"; local crypto = require "prosody.util.crypto";
local json = require "util.json"; local json = require "prosody.util.json";
local hashes = require "util.hashes"; local hashes = require "prosody.util.hashes";
local base64_encode = require "util.encodings".base64.encode; local base64_encode = require "prosody.util.encodings".base64.encode;
local base64_decode = require "util.encodings".base64.decode; local base64_decode = require "prosody.util.encodings".base64.decode;
local secure_equals = require "util.hashes".equals; local secure_equals = require "prosody.util.hashes".equals;
local bit = require "util.bitcompat"; local bit = require "prosody.util.bitcompat";
local hex = require "util.hex"; local hex = require "prosody.util.hex";
local rand = require "util.random"; local rand = require "prosody.util.random";
local s_pack = require "util.struct".pack; local s_pack = require "prosody.util.struct".pack;
local s_gsub = string.gsub; local s_gsub = string.gsub;

View file

@ -17,7 +17,7 @@ for path in (CFG_PLUGINDIR or "./plugins/"):gsub("[/\\]", dir_sep):gmatch("[^"..
end end
local io_open = io.open; local io_open = io.open;
local envload = require "util.envload".envload; local envload = require "prosody.util.envload".envload;
local pluginloader_methods = {}; local pluginloader_methods = {};
local pluginloader_mt = { __index = pluginloader_methods }; local pluginloader_mt = { __index = pluginloader_methods };

View file

@ -1,7 +1,7 @@
local promise_methods = {}; local promise_methods = {};
local promise_mt = { __name = "promise", __index = promise_methods }; local promise_mt = { __name = "promise", __index = promise_methods };
local xpcall = require "util.xpcall".xpcall; local xpcall = require "prosody.util.xpcall".xpcall;
local unpack = table.unpack; local unpack = table.unpack;
function promise_mt:__tostring() function promise_mt:__tostring()

View file

@ -7,14 +7,14 @@
-- --
local config = require "core.configmanager"; local config = require "prosody.core.configmanager";
local encodings = require "util.encodings"; local encodings = require "prosody.util.encodings";
local stringprep = encodings.stringprep; local stringprep = encodings.stringprep;
local storagemanager = require "core.storagemanager"; local storagemanager = require "prosody.core.storagemanager";
local usermanager = require "core.usermanager"; local usermanager = require "prosody.core.usermanager";
local interpolation = require "util.interpolation"; local interpolation = require "prosody.util.interpolation";
local signal = require "util.signal"; local signal = require "prosody.util.signal";
local set = require "util.set"; local set = require "prosody.util.set";
local lfs = require "lfs"; local lfs = require "lfs";
local type = type; local type = type;
@ -42,7 +42,7 @@ local error_messages = setmetatable({
}, { __index = function (_,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end }); }, { __index = function (_,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end });
-- UI helpers -- UI helpers
local show_message = require "util.human.io".printf; local show_message = require "prosody.util.human.io".printf;
local function show_usage(usage, desc) local function show_usage(usage, desc)
print("Usage: ".._G.arg[0].." "..usage); print("Usage: ".._G.arg[0].." "..usage);

View file

@ -1,8 +1,8 @@
local lfs = require "lfs"; local lfs = require "lfs";
local pctl = require "util.prosodyctl"; local pctl = require "prosody.util.prosodyctl";
local hi = require "util.human.io"; local hi = require "prosody.util.human.io";
local configmanager = require "core.configmanager"; local configmanager = require "prosody.core.configmanager";
local openssl; local openssl;
@ -24,7 +24,7 @@ local function use_existing(filename)
end end
end end
local have_pposix, pposix = pcall(require, "util.pposix"); local have_pposix, pposix = pcall(require, "prosody.util.pposix");
local cert_basedir = prosody.paths.data == "." and "./certs" or prosody.paths.data; local cert_basedir = prosody.paths.data == "." and "./certs" or prosody.paths.data;
if have_pposix and pposix.getuid() == 0 then if have_pposix and pposix.getuid() == 0 then
-- FIXME should be enough to check if this directory is writable -- FIXME should be enough to check if this directory is writable
@ -219,7 +219,7 @@ function cert_commands.import(arg)
owner = configmanager.get("*", "prosody_user") or "prosody"; owner = configmanager.get("*", "prosody_user") or "prosody";
group = configmanager.get("*", "prosody_group") or owner; group = configmanager.get("*", "prosody_group") or owner;
end end
local cm = require "core.certmanager"; local cm = require "prosody.core.certmanager";
local files_by_name = {} local files_by_name = {}
for _, dir in ipairs(arg) do for _, dir in ipairs(arg) do
cm.index_certs(dir, files_by_name); cm.index_certs(dir, files_by_name);
@ -271,7 +271,7 @@ end
local function cert(arg) local function cert(arg)
if #arg >= 1 and arg[1] ~= "--help" then if #arg >= 1 and arg[1] ~= "--help" then
openssl = require "util.openssl"; openssl = require "prosody.util.openssl";
lfs = require "lfs"; lfs = require "lfs";
local cert_dir_attrs = lfs.attributes(cert_basedir); local cert_dir_attrs = lfs.attributes(cert_basedir);
if not cert_dir_attrs then if not cert_dir_attrs then
@ -303,7 +303,7 @@ local function cert(arg)
end end
return cert_commands[subcmd](arg); return cert_commands[subcmd](arg);
elseif subcmd == "check" then elseif subcmd == "check" then
return require "util.prosodyctl.check".check({"certs"}); return require "prosody.util.prosodyctl.check".check({"certs"});
end end
end end
pctl.show_usage("cert config|request|generate|key|import", "Helpers for generating X.509 certificates and keys.") pctl.show_usage("cert config|request|generate|key|import", "Helpers for generating X.509 certificates and keys.")

View file

@ -1,19 +1,19 @@
local configmanager = require "core.configmanager"; local configmanager = require "prosody.core.configmanager";
local show_usage = require "util.prosodyctl".show_usage; local show_usage = require "prosody.util.prosodyctl".show_usage;
local show_warning = require "util.prosodyctl".show_warning; local show_warning = require "prosody.util.prosodyctl".show_warning;
local is_prosody_running = require "util.prosodyctl".isrunning; local is_prosody_running = require "prosody.util.prosodyctl".isrunning;
local parse_args = require "util.argparse".parse; local parse_args = require "prosody.util.argparse".parse;
local dependencies = require "util.dependencies"; local dependencies = require "prosody.util.dependencies";
local socket = require "socket"; local socket = require "socket";
local socket_url = require "socket.url"; local socket_url = require "socket.url";
local jid_split = require "util.jid".prepped_split; local jid_split = require "prosody.util.jid".prepped_split;
local modulemanager = require "core.modulemanager"; local modulemanager = require "prosody.core.modulemanager";
local async = require "util.async"; local async = require "prosody.util.async";
local httputil = require "util.http"; local httputil = require "prosody.util.http";
local function check_ojn(check_type, target_host) local function check_ojn(check_type, target_host)
local http = require "net.http"; -- .new({}); local http = require "prosody.net.http"; -- .new({});
local json = require "util.json"; local json = require "prosody.util.json";
local response, err = async.wait_for(http.request( local response, err = async.wait_for(http.request(
("https://observe.jabber.network/api/v1/check/%s"):format(httputil.urlencode(check_type)), ("https://observe.jabber.network/api/v1/check/%s"):format(httputil.urlencode(check_type)),
@ -41,7 +41,7 @@ local function check_ojn(check_type, target_host)
end end
local function check_probe(base_url, probe_module, target) local function check_probe(base_url, probe_module, target)
local http = require "net.http"; -- .new({}); local http = require "prosody.net.http"; -- .new({});
local params = httputil.formencode({ module = probe_module; target = target }) local params = httputil.formencode({ module = probe_module; target = target })
local response, err = async.wait_for(http.request(base_url .. "?" .. params)); local response, err = async.wait_for(http.request(base_url .. "?" .. params));
@ -62,8 +62,8 @@ local function check_probe(base_url, probe_module, target)
end end
local function check_turn_service(turn_service, ping_service) local function check_turn_service(turn_service, ping_service)
local ip = require "util.ip"; local ip = require "prosody.util.ip";
local stun = require "net.stun"; local stun = require "prosody.net.stun";
-- Create UDP socket for communication with the server -- Create UDP socket for communication with the server
local sock = assert(require "socket".udp()); local sock = assert(require "socket".udp());
@ -304,9 +304,9 @@ local function check(arg)
print("Error: Unknown parameter: "..opts_info); print("Error: Unknown parameter: "..opts_info);
return 1; return 1;
end end
local array = require "util.array"; local array = require "prosody.util.array";
local set = require "util.set"; local set = require "prosody.util.set";
local it = require "util.iterators"; local it = require "prosody.util.iterators";
local ok = true; local ok = true;
local function disabled_hosts(host, conf) return host ~= "*" and conf.enabled ~= false; end local function disabled_hosts(host, conf) return host ~= "*" and conf.enabled ~= false; end
local function enabled_hosts() return it.filter(disabled_hosts, pairs(configmanager.getconfig())); end local function enabled_hosts() return it.filter(disabled_hosts, pairs(configmanager.getconfig())); end
@ -706,13 +706,13 @@ local function check(arg)
print("Done.\n"); print("Done.\n");
end end
if not what or what == "dns" then if not what or what == "dns" then
local dns = require "net.dns"; local dns = require "prosody.net.dns";
pcall(function () pcall(function ()
local unbound = require"net.unbound"; local unbound = require"prosody.net.unbound";
dns = unbound.dns; dns = unbound.dns;
end) end)
local idna = require "util.encodings".idna; local idna = require "prosody.util.encodings".idna;
local ip = require "util.ip"; local ip = require "prosody.util.ip";
local c2s_ports = set.new(configmanager.get("*", "c2s_ports") or {5222}); local c2s_ports = set.new(configmanager.get("*", "c2s_ports") or {5222});
local s2s_ports = set.new(configmanager.get("*", "s2s_ports") or {5269}); local s2s_ports = set.new(configmanager.get("*", "s2s_ports") or {5269});
local c2s_tls_ports = set.new(configmanager.get("*", "c2s_direct_tls_ports") or {}); local c2s_tls_ports = set.new(configmanager.get("*", "c2s_direct_tls_ports") or {});
@ -769,7 +769,7 @@ local function check(arg)
end end
end end
local local_addresses = require"util.net".local_addresses() or {}; local local_addresses = require"prosody.util.net".local_addresses() or {};
for addr in it.values(local_addresses) do for addr in it.values(local_addresses) do
if not ip.new_ip(addr).private then if not ip.new_ip(addr).private then
@ -1072,8 +1072,8 @@ local function check(arg)
if not what or what == "certs" then if not what or what == "certs" then
local cert_ok; local cert_ok;
print"Checking certificates..." print"Checking certificates..."
local x509_verify_identity = require"util.x509".verify_identity; local x509_verify_identity = require"prosody.util.x509".verify_identity;
local create_context = require "core.certmanager".create_context; local create_context = require "prosody.core.certmanager".create_context;
local ssl = dependencies.softreq"ssl"; local ssl = dependencies.softreq"ssl";
-- local datetime_parse = require"util.datetime".parse_x509; -- local datetime_parse = require"util.datetime".parse_x509;
local load_cert = ssl and ssl.loadcertificate; local load_cert = ssl and ssl.loadcertificate;

View file

@ -1,15 +1,15 @@
local config = require "core.configmanager"; local config = require "prosody.core.configmanager";
local server = require "net.server"; local server = require "prosody.net.server";
local st = require "util.stanza"; local st = require "prosody.util.stanza";
local path = require "util.paths"; local path = require "prosody.util.paths";
local parse_args = require "util.argparse".parse; local parse_args = require "prosody.util.argparse".parse;
local unpack = table.unpack or _G.unpack; local unpack = table.unpack or _G.unpack;
local tc = require "util.termcolours"; local tc = require "prosody.util.termcolours";
local isatty = require "util.pposix".isatty; local isatty = require "prosody.util.pposix".isatty;
local have_readline, readline = pcall(require, "readline"); local have_readline, readline = pcall(require, "readline");
local adminstream = require "util.adminstream"; local adminstream = require "prosody.util.adminstream";
if have_readline then if have_readline then
readline.set_readline_name("prosody"); readline.set_readline_name("prosody");

View file

@ -1,6 +1,6 @@
local events = require "util.events"; local events = require "prosody.util.events";
local cache = require "util.cache"; local cache = require "prosody.util.cache";
local errors = require "util.error"; local errors = require "prosody.util.error";
local service_mt = {}; local service_mt = {};

View file

@ -9,7 +9,7 @@
-- Small ringbuffer library (i.e. an efficient FIFO queue with a size limit) -- Small ringbuffer library (i.e. an efficient FIFO queue with a size limit)
-- (because unbounded dynamically-growing queues are a bad thing...) -- (because unbounded dynamically-growing queues are a bad thing...)
local have_utable, utable = pcall(require, "util.table"); -- For pre-allocation of table local have_utable, utable = pcall(require, "prosody.util.table"); -- For pre-allocation of table
local function new(size, allow_wrapping) local function new(size, allow_wrapping)
-- Head is next insert, tail is next read -- Head is next insert, tail is next read

View file

@ -6,7 +6,7 @@
-- COPYING file in the source package for more information. -- COPYING file in the source package for more information.
-- --
local ok, crand = pcall(require, "util.crand"); local ok, crand = pcall(require, "prosody.util.crand");
if ok and pcall(crand.bytes, 1) then return crand; end if ok and pcall(crand.bytes, 1) then return crand; end
local urandom, urandom_err = io.open("/dev/urandom", "r"); local urandom, urandom_err = io.open("/dev/urandom", "r");

View file

@ -9,7 +9,7 @@
-- during S2S connections. -- during S2S connections.
-- We can't hand this off to getaddrinfo, since it blocks -- We can't hand this off to getaddrinfo, since it blocks
local ip_commonPrefixLength = require"util.ip".commonPrefixLength local ip_commonPrefixLength = require"prosody.util.ip".commonPrefixLength
local function commonPrefixLength(ipA, ipB) local function commonPrefixLength(ipA, ipB)
local len = ip_commonPrefixLength(ipA, ipB); local len = ip_commonPrefixLength(ipA, ipB);

View file

@ -1,6 +1,6 @@
local array = require "util.array"; local array = require "prosody.util.array";
local it = require "util.iterators"; local it = require "prosody.util.iterators";
local new_short_id = require "util.id".short; local new_short_id = require "prosody.util.id".short;
local role_methods = {}; local role_methods = {};
local role_mt = { local role_mt = {

View file

@ -9,7 +9,7 @@
-- XEP-0313: Message Archive Management for Prosody -- XEP-0313: Message Archive Management for Prosody
-- --
local stanza = require"util.stanza".stanza; local stanza = require"prosody.util.stanza".stanza;
local tonumber = tonumber; local tonumber = tonumber;
local s_format = string.format; local s_format = string.format;
local type = type; local type = type;

View file

@ -133,11 +133,11 @@ function method:process(message)
end end
-- load the mechanisms -- load the mechanisms
require "util.sasl.plain" .init(registerMechanism); require "prosody.util.sasl.plain" .init(registerMechanism);
require "util.sasl.anonymous" .init(registerMechanism); require "prosody.util.sasl.anonymous" .init(registerMechanism);
require "util.sasl.oauthbearer" .init(registerMechanism); require "prosody.util.sasl.oauthbearer" .init(registerMechanism);
require "util.sasl.scram" .init(registerMechanism); require "prosody.util.sasl.scram" .init(registerMechanism);
require "util.sasl.external" .init(registerMechanism); require "prosody.util.sasl.external" .init(registerMechanism);
return { return {
registerMechanism = registerMechanism; registerMechanism = registerMechanism;

View file

@ -12,7 +12,7 @@
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
local generate_random_id = require "util.id".medium; local generate_random_id = require "prosody.util.id".medium;
local _ENV = nil; local _ENV = nil;
-- luacheck: std none -- luacheck: std none

View file

@ -1,4 +1,4 @@
local saslprep = require "util.encodings".stringprep.saslprep; local saslprep = require "prosody.util.encodings".stringprep.saslprep;
local _ENV = nil; local _ENV = nil;
-- luacheck: std none -- luacheck: std none

View file

@ -1,4 +1,4 @@
local json = require "util.json"; local json = require "prosody.util.json";
local _ENV = nil; local _ENV = nil;

View file

@ -12,9 +12,9 @@
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
local s_match = string.match; local s_match = string.match;
local saslprep = require "util.encodings".stringprep.saslprep; local saslprep = require "prosody.util.encodings".stringprep.saslprep;
local nodeprep = require "util.encodings".stringprep.nodeprep; local nodeprep = require "prosody.util.encodings".stringprep.nodeprep;
local log = require "util.logger".init("sasl"); local log = require "prosody.util.logger".init("sasl");
local _ENV = nil; local _ENV = nil;
-- luacheck: std none -- luacheck: std none

View file

@ -13,13 +13,13 @@
local s_match = string.match; local s_match = string.match;
local type = type local type = type
local base64 = require "util.encodings".base64; local base64 = require "prosody.util.encodings".base64;
local hashes = require "util.hashes"; local hashes = require "prosody.util.hashes";
local generate_uuid = require "util.uuid".generate; local generate_uuid = require "prosody.util.uuid".generate;
local saslprep = require "util.encodings".stringprep.saslprep; local saslprep = require "prosody.util.encodings".stringprep.saslprep;
local nodeprep = require "util.encodings".stringprep.nodeprep; local nodeprep = require "prosody.util.encodings".stringprep.nodeprep;
local log = require "util.logger".init("sasl"); local log = require "prosody.util.logger".init("sasl");
local binaryXOR = require "util.strbitop".sxor; local binaryXOR = require "prosody.util.strbitop".sxor;
local _ENV = nil; local _ENV = nil;
-- luacheck: std none -- luacheck: std none

View file

@ -16,13 +16,13 @@ local s_char = string.char;
local s_match = string.match; local s_match = string.match;
local t_concat = table.concat; local t_concat = table.concat;
local to_hex = require "util.hex".to; local to_hex = require "prosody.util.hex".to;
local pcall = pcall; local pcall = pcall;
local envload = require"util.envload".envload; local envload = require"prosody.util.envload".envload;
if not math.type then if not math.type then
require "util.mathcompat" require "prosody.util.mathcompat"
end end
local pos_inf, neg_inf = math.huge, -math.huge; local pos_inf, neg_inf = math.huge, -math.huge;

View file

@ -1,5 +1,5 @@
local initialize_filters = require "util.filters".initialize; local initialize_filters = require "prosody.util.filters".initialize;
local logger = require "util.logger"; local logger = require "prosody.util.logger";
local function new_session(typ) local function new_session(typ)
local session = { local session = {

View file

@ -1,4 +1,4 @@
local queue = require("util.queue"); local queue = require("prosody.util.queue");
local lib = { smqueue = {} } local lib = { smqueue = {} }

View file

@ -4,9 +4,9 @@ local ipairs = ipairs;
local tostring = tostring; local tostring = tostring;
local type = type; local type = type;
local assert, pcall, debug_traceback = assert, pcall, debug.traceback; local assert, pcall, debug_traceback = assert, pcall, debug.traceback;
local xpcall = require "util.xpcall".xpcall; local xpcall = require "prosody.util.xpcall".xpcall;
local t_concat = table.concat; local t_concat = table.concat;
local log = require "util.logger".init("sql"); local log = require "prosody.util.logger".init("sql");
local DBI = require "DBI"; local DBI = require "DBI";
-- This loads all available drivers while globals are unlocked -- This loads all available drivers while globals are unlocked

View file

@ -9,14 +9,14 @@ local type = type
local t_concat = table.concat; local t_concat = table.concat;
local t_insert = table.insert; local t_insert = table.insert;
local s_char = string.char; local s_char = string.char;
local log = require "util.logger".init("sql"); local log = require "prosody.util.logger".init("sql");
local lsqlite3 = require "lsqlite3"; local lsqlite3 = require "lsqlite3";
local build_url = require "socket.url".build; local build_url = require "socket.url".build;
local ROW, DONE = lsqlite3.ROW, lsqlite3.DONE; local ROW, DONE = lsqlite3.ROW, lsqlite3.DONE;
-- from sqlite3.h, no copyright claimed -- from sqlite3.h, no copyright claimed
local sqlite_errors = require"util.error".init("util.sqlite3", { local sqlite_errors = require"prosody.util.error".init("util.sqlite3", {
-- FIXME xmpp error conditions? -- FIXME xmpp error conditions?
[1] = { code = 1; type = "modify"; condition = "ERROR"; text = "Generic error" }; [1] = { code = 1; type = "modify"; condition = "ERROR"; text = "Generic error" };
[2] = { code = 2; type = "cancel"; condition = "INTERNAL"; text = "Internal logic error in SQLite" }; [2] = { code = 2; type = "cancel"; condition = "INTERNAL"; text = "Internal logic error in SQLite" };

View file

@ -8,7 +8,7 @@ local error = error;
local t_concat = table.concat; local t_concat = table.concat;
local t_insert = table.insert; local t_insert = table.insert;
local setmetatable = setmetatable; local setmetatable = setmetatable;
local resolve_path = require"util.paths".resolve_relative_path; local resolve_path = require"prosody.util.paths".resolve_relative_path;
local _ENV = nil; local _ENV = nil;
-- luacheck: std none -- luacheck: std none

View file

@ -21,12 +21,12 @@ local type = type;
local s_gsub = string.gsub; local s_gsub = string.gsub;
local s_sub = string.sub; local s_sub = string.sub;
local s_find = string.find; local s_find = string.find;
local t_move = table.move or require "util.table".move; local t_move = table.move or require "prosody.util.table".move;
local t_create = require"util.table".create; local t_create = require"prosody.util.table".create;
local valid_utf8 = require "util.encodings".utf8.valid; local valid_utf8 = require "prosody.util.encodings".utf8.valid;
local do_pretty_printing, termcolours = pcall(require, "util.termcolours"); local do_pretty_printing, termcolours = pcall(require, "prosody.util.termcolours");
local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"; local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas";
local xmpp_stanzas_attr = { xmlns = xmlns_stanzas }; local xmpp_stanzas_attr = { xmlns = xmlns_stanzas };

View file

@ -2,15 +2,15 @@
-- luacheck: ignore 113/CFG_CONFIGDIR 113/CFG_SOURCEDIR 113/CFG_DATADIR 113/CFG_PLUGINDIR -- luacheck: ignore 113/CFG_CONFIGDIR 113/CFG_SOURCEDIR 113/CFG_DATADIR 113/CFG_PLUGINDIR
local startup = {}; local startup = {};
local prosody = { events = require "util.events".new() }; local prosody = { events = require "prosody.util.events".new() };
local logger = require "util.logger"; local logger = require "prosody.util.logger";
local log = logger.init("startup"); local log = logger.init("startup");
local parse_args = require "util.argparse".parse; local parse_args = require "prosody.util.argparse".parse;
local config = require "core.configmanager"; local config = require "prosody.core.configmanager";
local config_warnings; local config_warnings;
local dependencies = require "util.dependencies"; local dependencies = require "prosody.util.dependencies";
local original_logging_config; local original_logging_config;
@ -132,14 +132,14 @@ end
function startup.load_libraries() function startup.load_libraries()
-- Load socket framework -- Load socket framework
-- luacheck: ignore 111/server 111/socket -- luacheck: ignore 111/server 111/socket
require "util.import" require "prosody.util.import"
socket = require "socket"; socket = require "socket";
server = require "net.server" server = require "prosody.net.server"
end end
function startup.init_logging() function startup.init_logging()
-- Initialize logging -- Initialize logging
local loggingmanager = require "core.loggingmanager" local loggingmanager = require "prosody.core.loggingmanager"
loggingmanager.reload_logging(); loggingmanager.reload_logging();
prosody.events.add_handler("config-reloaded", function () prosody.events.add_handler("config-reloaded", function ()
prosody.events.fire_event("reopen-log-files"); prosody.events.fire_event("reopen-log-files");
@ -280,7 +280,7 @@ function startup.init_global_state()
-- COMPAT Lua < 5.3 -- COMPAT Lua < 5.3
if not math.type then if not math.type then
require "util.mathcompat" require "prosody.util.mathcompat"
end end
end end
@ -303,7 +303,7 @@ function startup.setup_plugin_install_path()
local installer_plugin_path = config.get("*", "installer_plugin_path") or "custom_plugins"; local installer_plugin_path = config.get("*", "installer_plugin_path") or "custom_plugins";
local path_sep = package.config:sub(3,3); local path_sep = package.config:sub(3,3);
installer_plugin_path = config.resolve_relative_path(CFG_DATADIR or "data", installer_plugin_path); installer_plugin_path = config.resolve_relative_path(CFG_DATADIR or "data", installer_plugin_path);
require"util.paths".complement_lua_path(installer_plugin_path); require"prosody.util.paths".complement_lua_path(installer_plugin_path);
-- luacheck: ignore 111 -- luacheck: ignore 111
CFG_PLUGINDIR = installer_plugin_path..path_sep..(CFG_PLUGINDIR or "plugins"); CFG_PLUGINDIR = installer_plugin_path..path_sep..(CFG_PLUGINDIR or "plugins");
prosody.paths.installer = installer_plugin_path; prosody.paths.installer = installer_plugin_path;
@ -365,28 +365,28 @@ end
function startup.load_secondary_libraries() function startup.load_secondary_libraries()
--- Load and initialise core modules --- Load and initialise core modules
require "util.xmppstream" require "prosody.util.xmppstream"
require "core.stanza_router" require "prosody.core.stanza_router"
require "core.statsmanager" require "prosody.core.statsmanager"
require "core.hostmanager" require "prosody.core.hostmanager"
require "core.portmanager" require "prosody.core.portmanager"
require "core.modulemanager" require "prosody.core.modulemanager"
require "core.usermanager" require "prosody.core.usermanager"
require "core.rostermanager" require "prosody.core.rostermanager"
require "core.sessionmanager" require "prosody.core.sessionmanager"
package.loaded['core.componentmanager'] = setmetatable({},{__index=function() package.loaded['core.componentmanager'] = setmetatable({},{__index=function()
-- COMPAT which version? -- COMPAT which version?
log("warn", "componentmanager is deprecated: %s", debug.traceback():match("\n[^\n]*\n[ \t]*([^\n]*)")); log("warn", "componentmanager is deprecated: %s", debug.traceback():match("\n[^\n]*\n[ \t]*([^\n]*)"));
return function() end return function() end
end}); end});
require "util.array" require "prosody.util.array"
require "util.datetime" require "prosody.util.datetime"
require "util.iterators" require "prosody.util.iterators"
require "util.timer" require "prosody.util.timer"
require "util.helpers" require "prosody.util.helpers"
pcall(require, "util.signal") -- Not on Windows pcall(require, "prosody.util.signal") -- Not on Windows
-- Commented to protect us from -- Commented to protect us from
-- the second kind of people -- the second kind of people
@ -395,36 +395,36 @@ function startup.load_secondary_libraries()
if remdebug then remdebug.engine.start() end if remdebug then remdebug.engine.start() end
]] ]]
require "util.stanza" require "prosody.util.stanza"
require "util.jid" require "prosody.util.jid"
end end
function startup.init_http_client() function startup.init_http_client()
local http = require "net.http" local http = require "prosody.net.http"
local config_ssl = config.get("*", "ssl") or {} local config_ssl = config.get("*", "ssl") or {}
local https_client = config.get("*", "client_https_ssl") local https_client = config.get("*", "client_https_ssl")
http.default.options.sslctx = require "core.certmanager".create_context("client_https port 0", "client", http.default.options.sslctx = require "prosody.core.certmanager".create_context("client_https port 0", "client",
{ capath = config_ssl.capath, cafile = config_ssl.cafile, verify = "peer", }, https_client); { capath = config_ssl.capath, cafile = config_ssl.cafile, verify = "peer", }, https_client);
http.default.options.use_dane = config.get("*", "use_dane") http.default.options.use_dane = config.get("*", "use_dane")
end end
function startup.init_promise() function startup.init_promise()
local promise = require "util.promise"; local promise = require "prosody.util.promise";
local timer = require "util.timer"; local timer = require "prosody.util.timer";
promise.set_nexttick(function(f) return timer.add_task(0, f); end); promise.set_nexttick(function(f) return timer.add_task(0, f); end);
end end
function startup.init_async() function startup.init_async()
local async = require "util.async"; local async = require "prosody.util.async";
local timer = require "util.timer"; local timer = require "prosody.util.timer";
async.set_nexttick(function(f) return timer.add_task(0, f); end); async.set_nexttick(function(f) return timer.add_task(0, f); end);
async.set_schedule_function(timer.add_task); async.set_schedule_function(timer.add_task);
end end
function startup.init_data_store() function startup.init_data_store()
require "core.storagemanager"; require "prosody.core.storagemanager";
end end
function startup.prepare_to_start() function startup.prepare_to_start()
@ -465,7 +465,7 @@ function startup.read_version()
prosody.version = "hg:"..prosody.version; prosody.version = "hg:"..prosody.version;
end end
else else
local hg = require"util.mercurial"; local hg = require"prosody.util.mercurial";
local hgid = hg.check_id(CFG_SOURCEDIR or "."); local hgid = hg.check_id(CFG_SOURCEDIR or ".");
if hgid then prosody.version = "hg:" .. hgid; end if hgid then prosody.version = "hg:" .. hgid; end
end end
@ -503,7 +503,7 @@ function startup.switch_user()
-- it is already started as the appropriate user. -- it is already started as the appropriate user.
local want_pposix_version = "0.4.0"; local want_pposix_version = "0.4.0";
local have_pposix, pposix = pcall(require, "util.pposix"); local have_pposix, pposix = pcall(require, "prosody.util.pposix");
if have_pposix and pposix then if have_pposix and pposix then
if pposix._VERSION ~= want_pposix_version then if pposix._VERSION ~= want_pposix_version then
@ -599,7 +599,7 @@ end
function startup.init_gc() function startup.init_gc()
-- Apply garbage collector settings from the config file -- Apply garbage collector settings from the config file
local gc = require "util.gc"; local gc = require "prosody.util.gc";
local gc_settings = config.get("*", "gc") or { mode = default_gc_params.mode }; local gc_settings = config.get("*", "gc") or { mode = default_gc_params.mode };
local ok, err = gc.configure(gc_settings, default_gc_params); local ok, err = gc.configure(gc_settings, default_gc_params);
@ -611,7 +611,7 @@ function startup.init_gc()
end end
function startup.init_errors() function startup.init_errors()
require "util.error".configure(config.get("*", "error_library") or {}); require "prosody.util.error".configure(config.get("*", "error_library") or {});
end end
function startup.make_host(hostname) function startup.make_host(hostname)
@ -620,7 +620,7 @@ function startup.make_host(hostname)
events = prosody.events, events = prosody.events,
modules = {}, modules = {},
sessions = {}, sessions = {},
users = require "core.usermanager".new_null_provider(hostname) users = require "prosody.core.usermanager".new_null_provider(hostname)
}; };
end end

View file

@ -1,6 +1,6 @@
local time = require "util.time".now; local time = require "prosody.util.time".now;
local new_metric_registry = require "util.openmetrics".new_metric_registry; local new_metric_registry = require "prosody.util.openmetrics".new_metric_registry;
local render_histogram_le = require "util.openmetrics".render_histogram_le; local render_histogram_le = require "prosody.util.openmetrics".render_histogram_le;
-- BEGIN of Metric implementations -- BEGIN of Metric implementations

View file

@ -1,10 +1,10 @@
local socket = require "socket"; local socket = require "socket";
local time = require "util.time".now; local time = require "prosody.util.time".now;
local array = require "util.array"; local array = require "prosody.util.array";
local t_concat = table.concat; local t_concat = table.concat;
local new_metric_registry = require "util.openmetrics".new_metric_registry; local new_metric_registry = require "prosody.util.openmetrics".new_metric_registry;
local render_histogram_le = require "util.openmetrics".render_histogram_le; local render_histogram_le = require "prosody.util.openmetrics".render_histogram_le;
-- BEGIN of Metric implementations -- BEGIN of Metric implementations

View file

@ -1,13 +1,13 @@
-- luacheck: ignore 213/i -- luacheck: ignore 213/i
local stanza_mt = require "util.stanza".stanza_mt; local stanza_mt = require "prosody.util.stanza".stanza_mt;
local setmetatable = setmetatable; local setmetatable = setmetatable;
local pairs = pairs; local pairs = pairs;
local ipairs = ipairs; local ipairs = ipairs;
local error = error; local error = error;
local envload = require "util.envload".envload; local envload = require "prosody.util.envload".envload;
local debug = debug; local debug = debug;
local t_remove = table.remove; local t_remove = table.remove;
local parse_xml = require "util.xml".parse; local parse_xml = require "prosody.util.xml".parse;
local _ENV = nil; local _ENV = nil;
-- luacheck: std none -- luacheck: std none

View file

@ -21,7 +21,7 @@ local pairs = pairs;
local windows; local windows;
if os.getenv("WINDIR") then if os.getenv("WINDIR") then
windows = require "util.windows"; windows = require "prosody.util.windows";
end end
local orig_color = windows and windows.get_consolecolor and windows.get_consolecolor(); local orig_color = windows and windows.get_consolecolor and windows.get_consolecolor();

View file

@ -1,5 +1,5 @@
local gettime = require "util.time".now local gettime = require "prosody.util.time".now
local setmetatable = setmetatable; local setmetatable = setmetatable;
local _ENV = nil; local _ENV = nil;

View file

@ -6,14 +6,14 @@
-- COPYING file in the source package for more information. -- COPYING file in the source package for more information.
-- --
local indexedbheap = require "util.indexedbheap"; local indexedbheap = require "prosody.util.indexedbheap";
local log = require "util.logger".init("timer"); local log = require "prosody.util.logger".init("timer");
local server = require "net.server"; local server = require "prosody.net.server";
local get_time = require "util.time".now local get_time = require "prosody.util.time".now
local type = type; local type = type;
local debug_traceback = debug.traceback; local debug_traceback = debug.traceback;
local tostring = tostring; local tostring = tostring;
local xpcall = require "util.xpcall".xpcall; local xpcall = require "prosody.util.xpcall".xpcall;
local math_max = math.max; local math_max = math.max;
local pairs = pairs; local pairs = pairs;

View file

@ -6,9 +6,9 @@
-- COPYING file in the source package for more information. -- COPYING file in the source package for more information.
-- --
local random = require "util.random"; local random = require "prosody.util.random";
local random_bytes = random.bytes; local random_bytes = random.bytes;
local hex = require "util.hex".encode; local hex = require "prosody.util.hex".encode;
local m_ceil = math.ceil; local m_ceil = math.ceil;
local function get_nibbles(n) local function get_nibbles(n)

View file

@ -1,4 +1,4 @@
local timer = require "util.timer"; local timer = require "prosody.util.timer";
local setmetatable = setmetatable; local setmetatable = setmetatable;
local _ENV = nil; local _ENV = nil;

View file

@ -18,12 +18,12 @@
-- [LDAP] - https://www.rfc-editor.org/rfc/rfc4519.html -- [LDAP] - https://www.rfc-editor.org/rfc/rfc4519.html
-- [PKIX] - https://www.rfc-editor.org/rfc/rfc5280.html -- [PKIX] - https://www.rfc-editor.org/rfc/rfc5280.html
local nameprep = require "util.encodings".stringprep.nameprep; local nameprep = require "prosody.util.encodings".stringprep.nameprep;
local idna_to_ascii = require "util.encodings".idna.to_ascii; local idna_to_ascii = require "prosody.util.encodings".idna.to_ascii;
local idna_to_unicode = require "util.encodings".idna.to_unicode; local idna_to_unicode = require "prosody.util.encodings".idna.to_unicode;
local base64 = require "util.encodings".base64; local base64 = require "prosody.util.encodings".base64;
local log = require "util.logger".init("x509"); local log = require "prosody.util.logger".init("x509");
local mt = require "util.multitable"; local mt = require "prosody.util.multitable";
local s_format = string.format; local s_format = string.format;
local ipairs = ipairs; local ipairs = ipairs;

View file

@ -1,5 +1,5 @@
local st = require "util.stanza"; local st = require "prosody.util.stanza";
local lxp = require "lxp"; local lxp = require "lxp";
local t_insert = table.insert; local t_insert = table.insert;
local t_remove = table.remove; local t_remove = table.remove;

View file

@ -7,7 +7,7 @@
-- --
local lxp = require "lxp"; local lxp = require "lxp";
local st = require "util.stanza"; local st = require "prosody.util.stanza";
local stanza_mt = st.stanza_mt; local stanza_mt = st.stanza_mt;
local error = error; local error = error;

View file

@ -1,7 +1,7 @@
local xpcall = xpcall; local xpcall = xpcall;
if select(2, xpcall(function (x) return x end, function () end, "test")) ~= "test" then if select(2, xpcall(function (x) return x end, function () end, "test")) ~= "test" then
xpcall = require"util.compat".xpcall; xpcall = require"prosody.util.compat".xpcall;
end end
return { return {

View file

@ -3,7 +3,7 @@ local s_match = string.match;
local s_sub = string.sub; local s_sub = string.sub;
local t_concat = table.concat; local t_concat = table.concat;
local st = require("util.stanza"); local st = require("prosody.util.stanza");
local function render(template, root, escape, filters) local function render(template, root, escape, filters)
escape = escape or st.xml_escape; escape = escape or st.xml_escape;