Comparison

core/configmanager.lua @ 10374:a83233559253

core.configmanager: Ensure Hosts are given names Prevents traceback from nameprep(nil)
author Kim Alvefur <zash@zash.se>
date Sat, 02 Nov 2019 13:55:38 +0100
parent 10206:46a5f2bf5ee0
child 10375:3d0adbc74c39
comparison
equal deleted inserted replaced
10373:51ea82f55322 10374:a83233559253
136 end 136 end
137 }); 137 });
138 138
139 rawset(env, "__currenthost", "*") -- Default is global 139 rawset(env, "__currenthost", "*") -- Default is global
140 function env.VirtualHost(name) 140 function env.VirtualHost(name)
141 if not name then
142 error("Host must have a name", 2);
143 end
141 name = nameprep(name); 144 name = nameprep(name);
142 if rawget(config_table, name) and rawget(config_table[name], "component_module") then 145 if rawget(config_table, name) and rawget(config_table[name], "component_module") then
143 error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s", 146 error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s",
144 name, config_table[name].component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); 147 name, config_table[name].component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0);
145 end 148 end
154 end; 157 end;
155 end 158 end
156 env.Host, env.host = env.VirtualHost, env.VirtualHost; 159 env.Host, env.host = env.VirtualHost, env.VirtualHost;
157 160
158 function env.Component(name) 161 function env.Component(name)
162 if not name then
163 error("Component must have a name", 2);
164 end
159 name = nameprep(name); 165 name = nameprep(name);
160 if rawget(config_table, name) and rawget(config_table[name], "defined") 166 if rawget(config_table, name) and rawget(config_table[name], "defined")
161 and not rawget(config_table[name], "component_module") then 167 and not rawget(config_table[name], "component_module") then
162 error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s", 168 error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s",
163 name, name, name), 0); 169 name, name, name), 0);