Software /
code /
prosody
Comparison
core/configmanager.lua @ 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 |
parent | 1777:de86734d3f7f |
child | 2862:dae09dd45bed |
comparison
equal
deleted
inserted
replaced
2860:ad534f89c758 | 2861:1402615b66f8 |
---|---|
7 -- | 7 -- |
8 | 8 |
9 | 9 |
10 | 10 |
11 local _G = _G; | 11 local _G = _G; |
12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type = | 12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, format = |
13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type; | 13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, string.format; |
14 | |
15 | |
16 local trb = debug.traceback | |
14 | 17 |
15 local eventmanager = require "core.eventmanager"; | 18 local eventmanager = require "core.eventmanager"; |
16 | 19 |
17 module "configmanager" | 20 module "configmanager" |
18 | 21 |
113 set(env.__currenthost or "*", "core", k, v); | 116 set(env.__currenthost or "*", "core", k, v); |
114 end}); | 117 end}); |
115 | 118 |
116 rawset(env, "__currenthost", "*") -- Default is global | 119 rawset(env, "__currenthost", "*") -- Default is global |
117 function env.Host(name) | 120 function env.Host(name) |
121 if rawget(config, name) and rawget(config[name].core, "component_module") then | |
122 error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s", | |
123 name, config[name].core.component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); | |
124 end | |
118 rawset(env, "__currenthost", name); | 125 rawset(env, "__currenthost", name); |
119 -- Needs at least one setting to logically exist :) | 126 -- Needs at least one setting to logically exist :) |
120 set(name or "*", "core", "defined", true); | 127 set(name or "*", "core", "defined", true); |
121 end | 128 end |
122 env.host = env.Host; | 129 env.host = env.Host; |
123 | 130 |
124 function env.Component(name) | 131 function env.Component(name) |
132 if rawget(config, name) and rawget(config[name].core, "defined") and not rawget(config[name].core, "component_module") then | |
133 error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s", | |
134 name, name, name), 0); | |
135 end | |
125 set(name, "core", "component_module", "component"); | 136 set(name, "core", "component_module", "component"); |
126 -- Don't load the global modules by default | 137 -- Don't load the global modules by default |
127 set(name, "core", "load_global_modules", false); | 138 set(name, "core", "load_global_modules", false); |
128 rawset(env, "__currenthost", name); | 139 rawset(env, "__currenthost", name); |
129 | 140 |