Comparison

core/portmanager.lua @ 7947:24170d74b00b

core: Split some very long lines [luacheck]
author Kim Alvefur <zash@zash.se>
date Sat, 04 Mar 2017 17:49:48 +0100
parent 7421:d6f12056afda
child 8555:4f0f5b49bb03
comparison
equal deleted inserted replaced
7945:1f4a0e0b7167 7947:24170d74b00b
101 for port in bind_ports do 101 for port in bind_ports do
102 local port_number = tonumber(port); 102 local port_number = tonumber(port);
103 if not port_number then 103 if not port_number then
104 log("error", "Invalid port number specified for service '%s': %s", service_info.name, tostring(port)); 104 log("error", "Invalid port number specified for service '%s': %s", service_info.name, tostring(port));
105 elseif #active_services:search(nil, interface, port_number) > 0 then 105 elseif #active_services:search(nil, interface, port_number) > 0 then
106 log("error", "Multiple services configured to listen on the same port ([%s]:%d): %s, %s", interface, port, active_services:search(nil, interface, port)[1][1].service.name or "<unnamed>", service_name or "<unnamed>"); 106 log("error", "Multiple services configured to listen on the same port ([%s]:%d): %s, %s", interface, port,
107 active_services:search(nil, interface, port)[1][1].service.name or "<unnamed>", service_name or "<unnamed>");
107 else 108 else
108 local err; 109 local err;
109 -- Create SSL context for this service/port 110 -- Create SSL context for this service/port
110 if service_info.encryption == "ssl" then 111 if service_info.encryption == "ssl" then
111 local global_ssl_config = config.get("*", "ssl") or {}; 112 local global_ssl_config = config.get("*", "ssl") or {};
116 prefix_ssl_config, 117 prefix_ssl_config,
117 service_info.ssl_config or {}, 118 service_info.ssl_config or {},
118 global_ssl_config[interface], 119 global_ssl_config[interface],
119 global_ssl_config[port]); 120 global_ssl_config[port]);
120 if not ssl then 121 if not ssl then
121 log("error", "Error binding encrypted port for %s: %s", service_info.name, error_to_friendly_message(service_name, port_number, err) or "unknown error"); 122 log("error", "Error binding encrypted port for %s: %s", service_info.name,
123 error_to_friendly_message(service_name, port_number, err) or "unknown error");
122 end 124 end
123 end 125 end
124 if not err then 126 if not err then
125 -- Start listening on interface+port 127 -- Start listening on interface+port
126 local handler, err = server.addserver(interface, port_number, listener, mode, ssl); 128 local handler, err = server.addserver(interface, port_number, listener, mode, ssl);
127 if not handler then 129 if not handler then
128 log("error", "Failed to open server port %d on %s, %s", port_number, interface, error_to_friendly_message(service_name, port_number, err)); 130 log("error", "Failed to open server port %d on %s, %s", port_number, interface,
131 error_to_friendly_message(service_name, port_number, err));
129 else 132 else
130 table.insert(hooked_ports, "["..interface.."]:"..port_number); 133 table.insert(hooked_ports, "["..interface.."]:"..port_number);
131 log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port_number); 134 log("debug", "Added listening service %s to [%s]:%d", service_name, interface, port_number);
132 active_services:add(service_name, interface, port_number, { 135 active_services:add(service_name, interface, port_number, {
133 server = handler; 136 server = handler;
136 end 139 end
137 end 140 end
138 end 141 end
139 end 142 end
140 end 143 end
141 log("info", "Activated service '%s' on %s", service_name, #hooked_ports == 0 and "no ports" or table.concat(hooked_ports, ", ")); 144 log("info", "Activated service '%s' on %s", service_name,
145 #hooked_ports == 0 and "no ports" or table.concat(hooked_ports, ", "));
142 return true; 146 return true;
143 end 147 end
144 148
145 local close; -- forward declaration 149 local close; -- forward declaration
146 150