Software /
code /
prosody
Comparison
core/portmanager.lua @ 6054:7a5ddbaf758d
Merge 0.9->0.10
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 02 Apr 2014 17:41:38 +0100 |
parent | 6041:a97591d2e1ad |
parent | 5776:bd0ff8ae98a8 |
child | 6295:cb12ff49503d |
comparison
equal
deleted
inserted
replaced
6053:2f93a04564b2 | 6054:7a5ddbaf758d |
---|---|
87 function activate(service_name) | 87 function activate(service_name) |
88 local service_info = services[service_name][1]; | 88 local service_info = services[service_name][1]; |
89 if not service_info then | 89 if not service_info then |
90 return nil, "Unknown service: "..service_name; | 90 return nil, "Unknown service: "..service_name; |
91 end | 91 end |
92 | 92 |
93 local listener = service_info.listener; | 93 local listener = service_info.listener; |
94 | 94 |
95 local config_prefix = (service_info.config_prefix or service_name).."_"; | 95 local config_prefix = (service_info.config_prefix or service_name).."_"; |
96 if config_prefix == "_" then | 96 if config_prefix == "_" then |
97 config_prefix = ""; | 97 config_prefix = ""; |
103 or config.get("*", "interfaces") | 103 or config.get("*", "interfaces") |
104 or config.get("*", "interface") -- COMPAT w/pre-0.9 | 104 or config.get("*", "interface") -- COMPAT w/pre-0.9 |
105 or listener.default_interface -- COMPAT w/pre0.9 | 105 or listener.default_interface -- COMPAT w/pre0.9 |
106 or default_interfaces | 106 or default_interfaces |
107 bind_interfaces = set.new(type(bind_interfaces)~="table" and {bind_interfaces} or bind_interfaces); | 107 bind_interfaces = set.new(type(bind_interfaces)~="table" and {bind_interfaces} or bind_interfaces); |
108 | 108 |
109 local bind_ports = config.get("*", config_prefix.."ports") | 109 local bind_ports = config.get("*", config_prefix.."ports") |
110 or service_info.default_ports | 110 or service_info.default_ports |
111 or {service_info.default_port | 111 or {service_info.default_port |
112 or listener.default_port -- COMPAT w/pre-0.9 | 112 or listener.default_port -- COMPAT w/pre-0.9 |
113 } | 113 } |
114 bind_ports = set.new(type(bind_ports) ~= "table" and { bind_ports } or bind_ports ); | 114 bind_ports = set.new(type(bind_ports) ~= "table" and { bind_ports } or bind_ports ); |
115 | 115 |
116 local mode, ssl = listener.default_mode or default_mode; | 116 local mode, ssl = listener.default_mode or default_mode; |
117 local hooked_ports = {}; | 117 local hooked_ports = {}; |
118 | 118 |
119 for interface in bind_interfaces do | 119 for interface in bind_interfaces do |
120 for port in bind_ports do | 120 for port in bind_ports do |
121 local port_number = tonumber(port); | 121 local port_number = tonumber(port); |
122 if not port_number then | 122 if not port_number then |
123 log("error", "Invalid port number specified for service '%s': %s", service_info.name, tostring(port)); | 123 log("error", "Invalid port number specified for service '%s': %s", service_info.name, tostring(port)); |
188 local ok, err = activate(service_name); | 188 local ok, err = activate(service_name); |
189 if not ok then | 189 if not ok then |
190 log("error", "Failed to activate service '%s': %s", service_name, err or "unknown error"); | 190 log("error", "Failed to activate service '%s': %s", service_name, err or "unknown error"); |
191 end | 191 end |
192 end | 192 end |
193 | 193 |
194 fire_event("service-added", { name = service_name, service = service_info }); | 194 fire_event("service-added", { name = service_name, service = service_info }); |
195 return true; | 195 return true; |
196 end | 196 end |
197 | 197 |
198 function unregister_service(service_name, service_info) | 198 function unregister_service(service_name, service_info) |