Comparison

net/connlisteners.lua @ 2546:cadfb455a00c

net.connlisteners: Update for new server API, type == 'tls' now means little - all connections support TLS
author Matthew Wild <mwild1@gmail.com>
date Sun, 31 Jan 2010 15:44:05 +0000
parent 2104:466bd2cac62a
child 2547:b2cb0935f158
comparison
equal deleted inserted replaced
2545:99700e601d16 2546:cadfb455a00c
51 local h, err = get(name); 51 local h, err = get(name);
52 if not h then 52 if not h then
53 error("No such connection module: "..name.. (err and (" ("..err..")") or ""), 0); 53 error("No such connection module: "..name.. (err and (" ("..err..")") or ""), 0);
54 end 54 end
55 55
56 if udata then
57 if (udata.type == "ssl" or udata.type == "tls") and not udata.ssl then
58 error("No SSL context supplied for a "..tostring(udata.type):upper().." connection!", 0);
59 elseif udata.ssl and udata.type == "tcp" then
60 error("SSL context supplied for a TCP connection!", 0);
61 end
62 end
63
64 local interface = (udata and udata.interface) or h.default_interface or "*"; 56 local interface = (udata and udata.interface) or h.default_interface or "*";
65 local port = (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); 57 local port = (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);
66 local mode = (udata and udata.mode) or h.default_mode or 1; 58 local mode = (udata and udata.mode) or h.default_mode or 1;
67 local ssl = (udata and udata.ssl) or nil; 59 local ssl = (udata and udata.ssl) or nil;
68 local maxclients = 99999999; 60 local maxclients = 99999999;
69 local autossl = udata and udata.type == "ssl"; 61 local autossl = udata and udata.type == "ssl";
70 62
71 return server.addserver(interface, port, h, mode, ssl, autossl); 63 return server.addserver(interface, port, h, mode, autossl and ssl or nil);
72 end 64 end
73 65
74 return _M; 66 return _M;