aboutsummaryrefslogtreecommitdiffstats
path: root/core/portmanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-07-28 01:14:31 +0100
committerMatthew Wild <mwild1@gmail.com>2012-07-28 01:14:31 +0100
commitfbe75768718891167313bc0cbcffcd3a46042d31 (patch)
tree2732225257e7b8ade28695dad7c0df3f7cea00b1 /core/portmanager.lua
parent8395775fc1bd1e72a8c83927003d2af1ed5f304a (diff)
parentf926338983c2f1dd0276d41e3c3d8e28cbef3d02 (diff)
downloadprosody-fbe75768718891167313bc0cbcffcd3a46042d31.tar.gz
prosody-fbe75768718891167313bc0cbcffcd3a46042d31.zip
Merge with Florob
Diffstat (limited to 'core/portmanager.lua')
-rw-r--r--core/portmanager.lua35
1 files changed, 17 insertions, 18 deletions
diff --git a/core/portmanager.lua b/core/portmanager.lua
index b563fb10..3fcc8173 100644
--- a/core/portmanager.lua
+++ b/core/portmanager.lua
@@ -52,13 +52,6 @@ local function error_to_friendly_message(service_name, port, err)
end
elseif err:match("permission") then
friendly_message = "Prosody does not have sufficient privileges to use this port";
- elseif err == "no ssl context" then
- if not config.get("*", "core", "ssl") then
- friendly_message = "there is no 'ssl' config under Host \"*\" which is "
- .."require for legacy SSL ports";
- else
- friendly_message = "initializing SSL support failed, see previous log entries";
- end
end
return friendly_message;
end
@@ -110,22 +103,28 @@ function activate(service_name)
if #active_services:search(nil, interface, port) > 0 then
log("error", "Multiple services configured to listen on the same port ([%s]:%d): %s, %s", interface, port, active_services:search(nil, interface, port)[1][1].service.name or "<unnamed>", service_name or "<unnamed>");
else
+ local err;
-- Create SSL context for this service/port
if service_info.encryption == "ssl" then
local ssl_config = config.get("*", config_prefix.."ssl");
- ssl = certmanager.create_context(service_info.name.." port "..port, "server", ssl_config and (ssl_config[port]
+ ssl, err = certmanager.create_context(service_info.name.." port "..port, "server", ssl_config and (ssl_config[port]
or (ssl_config.certificate and ssl_config)));
+ if not ssl then
+ log("error", "Error binding encrypted port for %s: %s", service_info.name, error_to_friendly_message(service_name, port, err) or "unknown error");
+ end
end
- -- Start listening on interface+port
- local handler, err = server.addserver(interface, port, listener, mode, ssl);
- if not handler then
- log("error", "Failed to open server port %d on %s, %s", port, interface, error_to_friendly_message(service_name, port, err));
- else
- log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port);
- active_services:add(service_name, interface, port, {
- server = handler;
- service = service_info;
- });
+ if not err then
+ -- Start listening on interface+port
+ local handler, err = server.addserver(interface, port, listener, mode, ssl);
+ if not handler then
+ log("error", "Failed to open server port %d on %s, %s", port, interface, error_to_friendly_message(service_name, port, err));
+ else
+ log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port);
+ active_services:add(service_name, interface, port, {
+ server = handler;
+ service = service_info;
+ });
+ end
end
end
end