Diff

core/portmanager.lua @ 4615:29a9988c1e1b

portmanager: Allow services to specify their config option prefix
author Matthew Wild <mwild1@gmail.com>
date Thu, 15 Mar 2012 02:56:44 +0000
parent 4612:8bb93860fe46
child 4616:03d9fe1bcdd3
line wrap: on
line diff
--- a/core/portmanager.lua	Thu Mar 15 02:53:05 2012 +0000
+++ b/core/portmanager.lua	Thu Mar 15 02:56:44 2012 +0000
@@ -68,19 +68,23 @@
 	if not service_info then
 		return nil, "Unknown service: "..service_name;
 	end
+	
+	local config_prefix = (service_info.config_prefix or service_name).."_";
+	if config_prefix == "_" then
+		config_prefix = "";
+	end
 
-	local bind_interfaces = set.new(config.get("*", service_name.."_interfaces")
-		or config.get("*", service_name.."_interface") -- COMPAT w/pre-0.9
+	local bind_interfaces = set.new(config.get("*", config_prefix.."interfaces")
+		or config.get("*", config_prefix.."interface") -- COMPAT w/pre-0.9
 		or (service_info.private and default_local_interfaces)
 		or config.get("*", "interfaces")
 		or config.get("*", "interface") -- COMPAT w/pre-0.9
 		or service_info.default_interface -- COMPAT w/pre0.9
 		or default_interfaces);
 	
-	local bind_ports = set.new(config.get("*", service_name.."_ports")
-		or (service_info.multiplex and config.get("*", "ports"))
 		or service_info.default_ports
 		or {service_info.default_port});
+	local bind_ports = set.new(config.get("*", config_prefix.."ports")
 
 	local listener = service_info.listener;
 	local mode = listener.default_mode or "*a";