108 return config.get(host, "core", "anonymous_login"); |
108 return config.get(host, "core", "anonymous_login"); |
109 end); |
109 end); |
110 |
110 |
111 ----------- End of out-of-place code -------------- |
111 ----------- End of out-of-place code -------------- |
112 |
112 |
113 |
|
114 eventmanager.fire_event("server-starting"); |
113 eventmanager.fire_event("server-starting"); |
115 |
114 |
|
115 local global_ssl_ctx = config.get("*", "core", "ssl"); |
|
116 if global_ssl_ctx then |
|
117 local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; }; |
|
118 setmetatable(global_ssl_ctx, { __index = default_ssl_ctx }); |
|
119 end |
116 |
120 |
117 -- start listening on sockets |
121 -- start listening on sockets |
118 function net_activate_ports(option, listener, default, conntype) |
122 function net_activate_ports(option, listener, default, conntype) |
119 local ports = config.get("*", "core", option) or default; |
123 local ports = config.get("*", "core", option) or default; |
120 if type(ports) == "number" then ports = {ports} end; |
124 if type(ports) == "number" then ports = {ports} end; |
145 end |
149 end |
146 |
150 |
147 -- setup error handling |
151 -- setup error handling |
148 setmetatable(_G, { __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end, __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end }); |
152 setmetatable(_G, { __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end, __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end }); |
149 |
153 |
150 local global_ssl_ctx = config.get("*", "core", "ssl"); |
|
151 if global_ssl_ctx then |
|
152 local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; }; |
|
153 setmetatable(global_ssl_ctx, { __index = default_ssl_ctx }); |
|
154 end |
|
155 |
|
156 eventmanager.fire_event("server-started"); |
154 eventmanager.fire_event("server-started"); |
157 |
155 |
158 local quitting; |
156 local quitting; |
159 while not quitting do |
157 while not quitting do |
160 xpcall(server.loop, function (err) |
158 xpcall(server.loop, function (err) |