Software / code / prosody
Comparison
net/connlisteners.lua @ 739:1def06cd9311
Port to new server.lua, quite some changes, but I believe everything to be working
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 17 Jan 2009 04:45:08 +0000 |
| parent | 721:51233a8ae3d4 |
| child | 758:b1885732e979 |
comparison
equal
deleted
inserted
replaced
| 738:cf70342985df | 739:1def06cd9311 |
|---|---|
| 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 | |
| 59 function start(name, udata) | 57 function start(name, udata) |
| 60 local h, err = get(name); | 58 local h, err = get(name); |
| 61 if not h then | 59 if not h then |
| 62 error("No such connection module: "..name.. (err and (" ("..err..")") or ""), 0); | 60 error("No such connection module: "..name.. (err and (" ("..err..")") or ""), 0); |
| 63 end | 61 end |
| 64 | 62 |
| 65 local wrapper_function = wrapper_functions[(udata and udata.type)] or wrapper_functions.tcp; | 63 if udata then |
| 64 if (udata.type == "ssl" or udata.type == "tls") and not udata.ssl then | |
| 65 error("No SSL context supplied for a "..tostring(udata.type):upper().." connection!", 0); | |
| 66 elseif udata.ssl and udata.type == "tcp" then | |
| 67 error("SSL context supplied for a TCP connection!", 0); | |
| 68 end | |
| 69 end | |
| 66 | 70 |
| 67 return server.add(h, | 71 return server.addserver(h, |
| 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), | 72 (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), |
| 69 (udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil, wrapper_function); | 73 (udata and udata.interface) or "*", (udata and udata.mode) or h.default_mode or 1, (udata and udata.ssl) or nil, 99999999, udata and udata.type == "ssl"); |
| 70 end | 74 end |
| 71 | 75 |
| 72 return _M; | 76 return _M; |