Software /
code /
prosody
Changeset
2861:1402615b66f8
configmanager: Error when a component and host clash hostnames
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 14 Feb 2010 18:41:44 +0000 |
parents | 2860:ad534f89c758 |
children | 2862:dae09dd45bed |
files | core/configmanager.lua |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/core/configmanager.lua Sat Feb 13 19:35:12 2010 +0000 +++ b/core/configmanager.lua Sun Feb 14 18:41:44 2010 +0000 @@ -9,8 +9,11 @@ local _G = _G; -local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type = - setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type; +local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, format = + setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, string.format; + + +local trb = debug.traceback local eventmanager = require "core.eventmanager"; @@ -115,6 +118,10 @@ rawset(env, "__currenthost", "*") -- Default is global function env.Host(name) + if rawget(config, name) and rawget(config[name].core, "component_module") then + error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s", + name, config[name].core.component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); + end rawset(env, "__currenthost", name); -- Needs at least one setting to logically exist :) set(name or "*", "core", "defined", true); @@ -122,6 +129,10 @@ env.host = env.Host; function env.Component(name) + if rawget(config, name) and rawget(config[name].core, "defined") and not rawget(config[name].core, "component_module") then + error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s", + name, name, name), 0); + end set(name, "core", "component_module", "component"); -- Don't load the global modules by default set(name, "core", "load_global_modules", false);