aboutsummaryrefslogtreecommitdiffstats
path: root/net/server.lua
diff options
context:
space:
mode:
Diffstat (limited to 'net/server.lua')
-rw-r--r--net/server.lua44
1 files changed, 28 insertions, 16 deletions
diff --git a/net/server.lua b/net/server.lua
index 0696fd52..942aceb2 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -6,20 +6,23 @@
-- COPYING file in the source package for more information.
--
-if not (prosody and prosody.config_loaded) then
- -- This module only supports loading inside Prosody, outside Prosody
- -- you should directly require net.server_select or server_event, etc.
- error(debug.traceback("Loading outside Prosody or Prosody not yet initialized"), 0);
+local function log(level, format, ...)
+ print("net.server", level, format:format(...));
end
-local log = require "util.logger".init("net.server");
+local default_backend = "select";
+local server_type = default_backend;
-local default_backend = "epoll";
+if (prosody and prosody.config_loaded) then
+ default_backend = "epoll";
+ log = require"prosody.util.logger".init("net.server");
+ server_type = require"prosody.core.configmanager".get("*", "network_backend") or default_backend;
-local server_type = require "core.configmanager".get("*", "network_backend") or default_backend;
-
-if require "core.configmanager".get("*", "use_libevent") then
- server_type = "event";
+ if require"prosody.core.configmanager".get("*", "use_libevent") then
+ server_type = "event";
+ end
+elseif pcall(require, "prosody.util.poll") then
+ server_type = "epoll";
end
if server_type == "event" then
@@ -32,7 +35,7 @@ end
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 +64,7 @@ if server_type == "event" then
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 +78,7 @@ elseif server_type == "select" then
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 +88,7 @@ else
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 +112,7 @@ else
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);
@@ -118,6 +121,15 @@ if prosody and set_config then
prosody.events.add_handler("config-reloaded", load_config);
end
--- require "net.server" shall now forever return this,
+if prosody and server.tls_builder then
+ local tls_builder = server.tls_builder;
+ -- resolving the basedir here avoids util.sslconfig depending on
+ -- prosody.paths.config
+ function server.tls_builder()
+ return tls_builder(prosody.paths.config or "")
+ end
+end
+
+-- require "prosody.net.server" shall now forever return this,
-- ie. server_select or server_event as chosen above.
return server;