Software /
code /
prosody
Comparison
net/connlisteners.lua @ 658:1952fdcf1017
Fix specifying ports in config, and SSL support
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 27 Dec 2008 21:20:09 +0000 |
parent | 624:04fe1a00aa16 |
child | 661:59c3f9a49969 |
comparison
equal
deleted
inserted
replaced
657:7f1946174d4b | 658:1952fdcf1017 |
---|---|
18 -- | 18 -- |
19 | 19 |
20 | 20 |
21 | 21 |
22 local listeners_dir = (CFG_SOURCEDIR or ".").."/net/"; | 22 local listeners_dir = (CFG_SOURCEDIR or ".").."/net/"; |
23 local server_add = require "net.server".add; | 23 local server = require "net.server"; |
24 local log = require "util.logger".init("connlisteners"); | 24 local log = require "util.logger".init("connlisteners"); |
25 | 25 |
26 local dofile, pcall, error = | 26 local dofile, pcall, error = |
27 dofile, pcall, error | 27 dofile, pcall, error |
28 | 28 |
52 h = listeners[name]; | 52 h = listeners[name]; |
53 end | 53 end |
54 return h; | 54 return h; |
55 end | 55 end |
56 | 56 |
57 local wrapper_functions = { tcp = server.wraptcpclient, ssl = server.wrapsslclient, tls = server.wraptlsclient } | |
58 | |
57 function start(name, udata) | 59 function start(name, udata) |
58 local h = get(name); | 60 local h = get(name); |
59 if not h then | 61 if not h then |
60 error("No such connection module: "..name, 0); | 62 error("No such connection module: "..name, 0); |
61 end | 63 end |
62 return server_add(h, | 64 |
65 local wrapper_function = wrapper_functions[(udata and udata.type)] or wrapper_functions.tcp; | |
66 | |
67 return server.add(h, | |
63 (udata and udata.port) or h.default_port or error("Can't start listener "..name.." because no port was specified, and it has no default port", 0), | 68 (udata and udata.port) or h.default_port or error("Can't start listener "..name.." because no port was specified, and it has no default port", 0), |
64 (udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil ); | 69 (udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil, wrapper_function); |
65 end | 70 end |
66 | 71 |
67 return _M; | 72 return _M; |