diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-02-14 18:41:44 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-02-14 18:41:44 +0000 |
commit | 97a4cee8857283ba33d118afbd232b2b22e71ecb (patch) | |
tree | 8343260814b0bbf7ed060c3a40fad0f5e9f19580 /core | |
parent | b4b0f2215909c19b5cde685b555db2452165ca4f (diff) | |
download | prosody-97a4cee8857283ba33d118afbd232b2b22e71ecb.tar.gz prosody-97a4cee8857283ba33d118afbd232b2b22e71ecb.zip |
configmanager: Error when a component and host clash hostnames
Diffstat (limited to 'core')
-rw-r--r-- | core/configmanager.lua | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua index ada14051..010b3076 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -9,8 +9,11 @@ local _G = _G; -local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table = - setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table; +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"; @@ -124,6 +127,10 @@ do 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); @@ -131,6 +138,10 @@ do 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); |