Changeset

12974:ba409c67353b

net: Prefix module imports with prosody namespace
author Kim Alvefur <zash@zash.se>
date Fri, 17 Mar 2023 16:23:12 +0100
parents 12973:cc215923297f
children 12975:d10957394a3c
files net/adns.lua net/connect.lua net/cqueues.lua net/dns.lua net/http.lua net/http/errors.lua net/http/files.lua net/http/parser.lua net/http/server.lua net/httpserver.lua net/resolvers/basic.lua net/resolvers/service.lua net/server.lua net/server_epoll.lua net/server_event.lua net/server_select.lua net/stun.lua net/unbound.lua net/websocket.lua net/websocket/frames.lua
diffstat 20 files changed, 108 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/net/adns.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/adns.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -6,11 +6,11 @@
 -- COPYING file in the source package for more information.
 --
 
-local server = require "net.server";
-local new_resolver = require "net.dns".resolver;
-local promise = require "util.promise";
+local server = require "prosody.net.server";
+local new_resolver = require "prosody.net.dns".resolver;
+local promise = require "prosody.util.promise";
 
-local log = require "util.logger".init("adns");
+local log = require "prosody.util.logger".init("adns");
 
 log("debug", "Using legacy DNS API (missing lua-unbound?)"); -- TODO write docs about luaunbound
 -- TODO Raise log level once packages are available
--- a/net/connect.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/connect.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -1,7 +1,7 @@
-local server = require "net.server";
-local log = require "util.logger".init("net.connect");
-local new_id = require "util.id".short;
-local timer = require "util.timer";
+local server = require "prosody.net.server";
+local log = require "prosody.util.logger".init("net.connect");
+local new_id = require "prosody.util.id".short;
+local timer = require "prosody.util.timer";
 
 -- FIXME RFC 6724
 -- FIXME Error propagation from resolvers doesn't work
--- a/net/cqueues.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/cqueues.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -7,9 +7,9 @@
 -- This module allows you to use cqueues with a net.server mainloop
 --
 
-local server = require "net.server";
+local server = require "prosody.net.server";
 local cqueues = require "cqueues";
-local timer = require "util.timer";
+local timer = require "prosody.util.timer";
 assert(cqueues.VERSION >= 20150113, "cqueues newer than 20150113 required")
 
 -- Create a single top level cqueue
--- a/net/dns.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/dns.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -13,13 +13,13 @@
 
 
 local socket = require "socket";
-local have_timer, timer = pcall(require, "util.timer");
-local new_ip = require "util.ip".new_ip;
-local have_util_net, util_net = pcall(require, "util.net");
+local have_timer, timer = pcall(require, "prosody.util.timer");
+local new_ip = require "prosody.util.ip".new_ip;
+local have_util_net, util_net = pcall(require, "prosody.util.net");
 
-local log = require "util.logger".init("dns");
+local log = require "prosody.util.logger".init("dns");
 
-local _, windows = pcall(require, "util.windows");
+local _, windows = pcall(require, "prosody.util.windows");
 local is_windows = (_ and windows) or os.getenv("WINDIR");
 
 local coroutine, io, math, string, table =
--- a/net/http.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/http.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -6,17 +6,17 @@
 -- COPYING file in the source package for more information.
 --
 
-local b64 = require "util.encodings".base64.encode;
+local b64 = require "prosody.util.encodings".base64.encode;
 local url = require "socket.url"
-local httpstream_new = require "net.http.parser".new;
-local util_http = require "util.http";
-local events = require "util.events";
-local verify_identity = require"util.x509".verify_identity;
-local promise = require "util.promise";
-local http_errors = require "net.http.errors";
+local httpstream_new = require "prosody.net.http.parser".new;
+local util_http = require "prosody.util.http";
+local events = require "prosody.util.events";
+local verify_identity = require"prosody.util.x509".verify_identity;
+local promise = require "prosody.util.promise";
+local http_errors = require "prosody.net.http.errors";
 
-local basic_resolver = require "net.resolvers.basic";
-local connect = require "net.connect".connect;
+local basic_resolver = require "prosody.net.resolvers.basic";
+local connect = require "prosody.net.connect".connect;
 
 local ssl_available = pcall(require, "ssl");
 
@@ -25,10 +25,10 @@
 local tonumber, tostring, traceback =
       tonumber, tostring, debug.traceback;
 local os_time = os.time;
-local xpcall = require "util.xpcall".xpcall;
+local xpcall = require "prosody.util.xpcall".xpcall;
 local error = error
 
-local log = require "util.logger".init("http");
+local log = require "prosody.util.logger".init("http");
 
 local _ENV = nil;
 -- luacheck: std none
--- a/net/http/errors.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/http/errors.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -2,8 +2,8 @@
 -- and a function to return a util.error object given callback 'code' and 'body'
 -- parameters.
 
-local codes = require "net.http.codes";
-local util_error = require "util.error";
+local codes = require "prosody.net.http.codes";
+local util_error = require "prosody.util.error";
 
 local error_templates = {
 	-- This code is used by us to report a client-side or connection error.
--- a/net/http/files.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/http/files.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -6,10 +6,10 @@
 -- COPYING file in the source package for more information.
 --
 
-local server = require"net.http.server";
+local server = require"prosody.net.http.server";
 local lfs = require "lfs";
-local new_cache = require "util.cache".new;
-local log = require "util.logger".init("net.http.files");
+local new_cache = require "prosody.util.cache".new;
+local log = require "prosody.util.logger".init("net.http.files");
 
 local os_date = os.date;
 local open = io.open;
@@ -23,7 +23,7 @@
 	forbidden_chars_pattern = "[/%z\001-\031\127\"*:<>?|]"
 end
 
-local urldecode = require "util.http".urldecode;
+local urldecode = require "prosody.util.http".urldecode;
 local function sanitize_path(path) --> util.paths or util.http?
 	if not path then return end
 	local out = {};
--- a/net/http/parser.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/http/parser.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -1,8 +1,8 @@
 local tonumber = tonumber;
 local assert = assert;
 local url_parse = require "socket.url".parse;
-local urldecode = require "util.http".urldecode;
-local dbuffer = require "util.dbuffer";
+local urldecode = require "prosody.util.http".urldecode;
+local dbuffer = require "prosody.util.dbuffer";
 
 local function preprocess_path(path)
 	path = urldecode((path:gsub("//+", "/")));
--- a/net/http/server.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/http/server.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -1,19 +1,19 @@
 
 local t_insert, t_concat = table.insert, table.concat;
-local parser_new = require "net.http.parser".new;
-local events = require "util.events".new();
-local addserver = require "net.server".addserver;
-local log = require "util.logger".init("http.server");
+local parser_new = require "prosody.net.http.parser".new;
+local events = require "prosody.util.events".new();
+local addserver = require "prosody.net.server".addserver;
+local log = require "prosody.util.logger".init("http.server");
 local os_date = os.date;
 local pairs = pairs;
 local s_upper = string.upper;
 local setmetatable = setmetatable;
-local cache = require "util.cache";
-local codes = require "net.http.codes";
-local promise = require "util.promise";
-local errors = require "util.error";
+local cache = require "prosody.util.cache";
+local codes = require "prosody.net.http.codes";
+local promise = require "prosody.util.promise";
+local errors = require "prosody.util.error";
 local blocksize = 2^16;
-local async = require "util.async";
+local async = require "prosody.util.async";
 
 local _M = {};
 
--- a/net/httpserver.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/httpserver.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -1,5 +1,5 @@
 -- COMPAT w/pre-0.9
-local log = require "util.logger".init("net.httpserver");
+local log = require "prosody.util.logger".init("net.httpserver");
 local traceback = debug.traceback;
 
 local _ENV = nil;
--- a/net/resolvers/basic.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/resolvers/basic.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -1,9 +1,9 @@
-local adns = require "net.adns";
-local inet_pton = require "util.net".pton;
-local inet_ntop = require "util.net".ntop;
-local idna_to_ascii = require "util.encodings".idna.to_ascii;
-local promise = require "util.promise";
-local t_move = require "util.table".move;
+local adns = require "prosody.net.adns";
+local inet_pton = require "prosody.util.net".pton;
+local inet_ntop = require "prosody.util.net".ntop;
+local idna_to_ascii = require "prosody.util.encodings".idna.to_ascii;
+local promise = require "prosody.util.promise";
+local t_move = require "prosody.util.table".move;
 
 local methods = {};
 local resolver_mt = { __index = methods };
--- a/net/resolvers/service.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/resolvers/service.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -1,7 +1,7 @@
-local adns = require "net.adns";
-local basic = require "net.resolvers.basic";
-local inet_pton = require "util.net".pton;
-local idna_to_ascii = require "util.encodings".idna.to_ascii;
+local adns = require "prosody.net.adns";
+local basic = require "prosody.net.resolvers.basic";
+local inet_pton = require "prosody.util.net".pton;
+local idna_to_ascii = require "prosody.util.encodings".idna.to_ascii;
 
 local methods = {};
 local resolver_mt = { __index = methods };
--- a/net/server.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/server.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -12,13 +12,13 @@
 	error(debug.traceback("Loading outside Prosody or Prosody not yet initialized"), 0);
 end
 
-local log = require "util.logger".init("net.server");
+local log = require "prosody.util.logger".init("net.server");
 
 local default_backend = "epoll";
 
-local server_type = require "core.configmanager".get("*", "network_backend") or default_backend;
+local server_type = require "prosody.core.configmanager".get("*", "network_backend") or default_backend;
 
-if require "core.configmanager".get("*", "use_libevent") then
+if require "prosody.core.configmanager".get("*", "use_libevent") then
 	server_type = "event";
 end
 
@@ -32,7 +32,7 @@
 local server;
 local set_config;
 if server_type == "event" then
-	server = require "net.server_event";
+	server = require "prosody.net.server_event";
 
 	local defaults = {};
 	for k,v in pairs(server.cfg) do
@@ -61,7 +61,7 @@
 elseif server_type == "select" then
 	-- TODO Remove completely.
 	log("warn", "select is deprecated, the new default is epoll. For more info see https://prosody.im/doc/network_backend");
-	server = require "net.server_select";
+	server = require "prosody.net.server_select";
 
 	local defaults = {};
 	for k,v in pairs(server.getsettings()) do
@@ -75,7 +75,7 @@
 		server.changesettings(select_settings);
 	end
 else
-	server = require("net.server_"..server_type);
+	server = require("prosody.net.server_"..server_type);
 	set_config = server.set_config;
 	if not server.get_backend then
 		function server.get_backend()
@@ -85,7 +85,7 @@
 end
 
 -- If server.hook_signal exists, replace signal.signal()
-local has_signal, signal = pcall(require, "util.signal");
+local has_signal, signal = pcall(require, "prosody.util.signal");
 if has_signal then
 	if server.hook_signal then
 		function signal.signal(signal_id, handler)
@@ -109,7 +109,7 @@
 end
 
 if prosody and set_config then
-	local config_get = require "core.configmanager".get;
+	local config_get = require "prosody.core.configmanager".get;
 	local function load_config()
 		local settings = config_get("*", "network_settings") or {};
 		return set_config(settings);
@@ -125,6 +125,6 @@
 	return tls_builder(prosody.paths.config or "")
 end
 
--- require "net.server" shall now forever return this,
+-- require "prosody.net.server" shall now forever return this,
 -- ie. server_select or server_event as chosen above.
 return server;
--- a/net/server_epoll.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/server_epoll.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -15,22 +15,22 @@
 local pairs = pairs;
 local ipairs = ipairs;
 local traceback = debug.traceback;
-local logger = require "util.logger";
+local logger = require "prosody.util.logger";
 local log = logger.init("server_epoll");
 local socket = require "socket";
-local realtime = require "util.time".now;
-local monotonic = require "util.time".monotonic;
-local indexedbheap = require "util.indexedbheap";
-local createtable = require "util.table".create;
-local inet = require "util.net";
+local realtime = require "prosody.util.time".now;
+local monotonic = require "prosody.util.time".monotonic;
+local indexedbheap = require "prosody.util.indexedbheap";
+local createtable = require "prosody.util.table".create;
+local inet = require "prosody.util.net";
 local inet_pton = inet.pton;
 local _SOCKETINVALID = socket._SOCKETINVALID or -1;
-local new_id = require "util.id".short;
-local xpcall = require "util.xpcall".xpcall;
-local sslconfig = require "util.sslconfig";
-local tls_impl = require "net.tls_luasec";
+local new_id = require "prosody.util.id".short;
+local xpcall = require "prosody.util.xpcall".xpcall;
+local sslconfig = require "prosody.util.sslconfig";
+local tls_impl = require "prosody.net.tls_luasec";
 
-local poller = require "util.poll"
+local poller = require "prosody.util.poll"
 local EEXIST = poller.EEXIST;
 local ENOENT = poller.ENOENT;
 
--- a/net/server_event.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/server_event.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -50,14 +50,14 @@
 local has_luasec = pcall ( require , "ssl" )
 local socket = require "socket"
 local levent = require "luaevent.core"
-local inet = require "util.net";
+local inet = require "prosody.util.net";
 local inet_pton = inet.pton;
-local sslconfig = require "util.sslconfig";
-local tls_impl = require "net.tls_luasec";
+local sslconfig = require "prosody.util.sslconfig";
+local tls_impl = require "prosody.net.tls_luasec";
 
 local socket_gettime = socket.gettime
 
-local log = require ("util.logger").init("socket")
+local log = require ("prosody.util.logger").init("socket")
 
 local function debug(...)
 	return log("debug", ("%s "):rep(select('#', ...)), ...)
--- a/net/server_select.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/server_select.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -11,7 +11,7 @@
 	return _G[ what ]
 end
 
-local log, table_concat = require ("util.logger").init("socket"), table.concat;
+local log, table_concat = require ("prosody.util.logger").init("socket"), table.concat;
 local out_put = function (...) return log("debug", table_concat{...}); end
 local out_error = function (...) return log("warn", table_concat{...}); end
 
@@ -49,10 +49,10 @@
 
 local luasocket = use "socket" or require "socket"
 local luasocket_gettime = luasocket.gettime
-local inet = require "util.net";
+local inet = require "prosody.util.net";
 local inet_pton = inet.pton;
-local sslconfig = require "util.sslconfig";
-local has_luasec, tls_impl = pcall(require, "net.tls_luasec");
+local sslconfig = require "prosody.util.sslconfig";
+local has_luasec, tls_impl = pcall(require, "prosody.net.tls_luasec");
 
 --// extern lib methods //--
 
--- a/net/stun.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/stun.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -1,11 +1,11 @@
-local base64 = require "util.encodings".base64;
-local hashes = require "util.hashes";
-local net = require "util.net";
-local random = require "util.random";
-local struct = require "util.struct";
-local bit32 = require"util.bitcompat";
-local sxor = require"util.strbitop".sxor;
-local new_ip = require "util.ip".new_ip;
+local base64 = require "prosody.util.encodings".base64;
+local hashes = require "prosody.util.hashes";
+local net = require "prosody.util.net";
+local random = require "prosody.util.random";
+local struct = require "prosody.util.struct";
+local bit32 = require"prosody.util.bitcompat";
+local sxor = require"prosody.util.strbitop".sxor;
+local new_ip = require "prosody.util.ip".new_ip;
 
 --- Public helpers
 
--- a/net/unbound.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/unbound.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -13,15 +13,15 @@
 local s_upper = string.upper;
 local noop = function() end;
 
-local logger = require "util.logger";
+local logger = require "prosody.util.logger";
 local log = logger.init("unbound");
-local net_server = require "net.server";
+local net_server = require "prosody.net.server";
 local libunbound = require"lunbound";
-local promise = require"util.promise";
-local new_id = require "util.id".short;
+local promise = require"prosody.util.promise";
+local new_id = require "prosody.util.id".short;
 
 local gettime = require"socket".gettime;
-local dns_utils = require"util.dns";
+local dns_utils = require"prosody.util.dns";
 local classes, types, errors = dns_utils.classes, dns_utils.types, dns_utils.errors;
 local parsers = dns_utils.parsers;
 
@@ -44,7 +44,7 @@
 
 local unbound_config;
 if prosody then
-	local config = require"core.configmanager";
+	local config = require"prosody.core.configmanager";
 	unbound_config = add_defaults(config.get("*", "unbound"));
 	prosody.events.add_handler("config-reloaded", function()
 		unbound_config = add_defaults(config.get("*", "unbound"));
--- a/net/websocket.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/websocket.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -8,13 +8,13 @@
 
 local t_concat = table.concat;
 
-local http = require "net.http";
-local frames = require "net.websocket.frames";
-local base64 = require "util.encodings".base64;
-local sha1 = require "util.hashes".sha1;
-local random_bytes = require "util.random".bytes;
-local timer = require "util.timer";
-local log = require "util.logger".init "websocket";
+local http = require "prosody.net.http";
+local frames = require "prosody.net.websocket.frames";
+local base64 = require "prosody.util.encodings".base64;
+local sha1 = require "prosody.util.hashes".sha1;
+local random_bytes = require "prosody.util.random".bytes;
+local timer = require "prosody.util.timer";
+local log = require "prosody.util.logger".init "websocket";
 
 local close_timeout = 3; -- Seconds to wait after sending close frame until closing connection.
 
--- a/net/websocket/frames.lua	Fri Mar 17 17:07:47 2023 +0100
+++ b/net/websocket/frames.lua	Fri Mar 17 16:23:12 2023 +0100
@@ -6,17 +6,17 @@
 -- COPYING file in the source package for more information.
 --
 
-local random_bytes = require "util.random".bytes;
+local random_bytes = require "prosody.util.random".bytes;
 
-local bit = require "util.bitcompat";
+local bit = require "prosody.util.bitcompat";
 local band = bit.band;
 local bor = bit.bor;
-local sbit = require "util.strbitop";
+local sbit = require "prosody.util.strbitop";
 local sxor = sbit.sxor;
 
 local s_char = string.char;
-local s_pack = require"util.struct".pack;
-local s_unpack = require"util.struct".unpack;
+local s_pack = require"prosody.util.struct".pack;
+local s_unpack = require"prosody.util.struct".unpack;
 
 local function pack_uint16be(x)
 	return s_pack(">I2", x);