prosody

changeset 2364
b79e5ba69704
parent 2362
7f5dbf982d14
child 2365
0bd8408a491c
equal deleted inserted replaced
2363:a1e987f499a8 2364:b79e5ba69704
191 end 191 end
192 192
193 local cl = require "net.connlisteners"; 193 local cl = require "net.connlisteners";
194 function prosody.net_activate_ports(option, listener, default, conntype) 194 function prosody.net_activate_ports(option, listener, default, conntype)
195 conntype = conntype or (global_ssl_ctx and "tls") or "tcp"; 195 conntype = conntype or (global_ssl_ctx and "tls") or "tcp";
196 option = option and option.."_ports" or "ports"; 196 local ports_option = option and option.."_ports" or "ports";
197 if not cl.get(listener) then return; end 197 if not cl.get(listener) then return; end
198 local ports = config.get("*", "core", option) or default; 198 local ports = config.get("*", "core", ports_option) or default;
199 if type(ports) == "number" then ports = {ports} end; 199 if type(ports) == "number" then ports = {ports} end;
200 200
201 if type(ports) ~= "table" then 201 if type(ports) ~= "table" then
202 log("error", "core."..option.." is not a table"); 202 log("error", "core."..ports_option.." is not a table");
203 else 203 else
204 for _, port in ipairs(ports) do 204 for _, port in ipairs(ports) do
205 if type(port) ~= "number" then 205 if type(port) ~= "number" then
206 log("error", "Non-numeric "..option.."_ports: "..tostring(port)); 206 log("error", "Non-numeric "..ports_option..": "..tostring(port));
207 else 207 else
208 cl.start(listener, { 208 cl.start(listener, {
209 ssl = conntype ~= "tcp" and global_ssl_ctx, 209 ssl = conntype ~= "tcp" and global_ssl_ctx,
210 port = port, 210 port = port,
211 interface = config.get("*", "core", option.."_interface") 211 interface = config.get("*", "core", option.."_interface")

mercurial