net.dns: Support for resolving AAAA records
[prosody.git] / net / connlisteners.lua
index e0076ddb881db8d9d10741800068c70c99b8aef1..7da25c62df3e4d52c7824d71432c516ff16650e1 100644 (file)
@@ -1,6 +1,6 @@
 -- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
 -- 
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
@@ -13,8 +13,10 @@ local server = require "net.server";
 local log = require "util.logger".init("connlisteners");
 local tostring = tostring;
 
-local dofile, pcall, error = 
-       dofile, pcall, error
+local dofile, xpcall, error =
+      dofile, xpcall, error
+
+local debug_traceback = debug.traceback;
 
 module "connlisteners"
 
@@ -37,7 +39,7 @@ end
 function get(name)
        local h = listeners[name];
        if not h then
-               local ok, ret = pcall(dofile, listeners_dir..name:gsub("[^%w%-]", "_").."_listener.lua");
+               local ok, ret = xpcall(function() dofile(listeners_dir..name:gsub("[^%w%-]", "_").."_listener.lua") end, debug_traceback);
                if not ok then
                        log("error", "Error while loading listener '%s': %s", tostring(name), tostring(ret));
                        return nil, ret;
@@ -59,6 +61,10 @@ function start(name, udata)
        local ssl = (udata and udata.ssl) or nil;
        local autossl = udata and udata.type == "ssl";
        
+       if autossl and not ssl then
+               return nil, "no ssl context";
+       end
+       
        return server.addserver(interface, port, h, mode, autossl and ssl or nil);
 end