Software /
code /
prosody
Comparison
core/configmanager.lua @ 6326:a3b9496673ee
Merge 0.9->0.10
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 31 Jul 2014 07:11:54 +0100 |
parent | 6167:5af7fe1014db |
parent | 6323:5926f01e5cd2 |
child | 6712:29d5875ae38d |
comparison
equal
deleted
inserted
replaced
6320:17344d25a0f6 | 6326:a3b9496673ee |
---|---|
16 local envload = require"util.envload".envload; | 16 local envload = require"util.envload".envload; |
17 local deps = require"util.dependencies"; | 17 local deps = require"util.dependencies"; |
18 local resolve_relative_path = require"util.paths".resolve_relative_path; | 18 local resolve_relative_path = require"util.paths".resolve_relative_path; |
19 local glob_to_pattern = require"util.paths".glob_to_pattern; | 19 local glob_to_pattern = require"util.paths".glob_to_pattern; |
20 local path_sep = package.config:sub(1,1); | 20 local path_sep = package.config:sub(1,1); |
21 | |
22 local have_encodings, encodings = pcall(require, "util.encodings"); | |
23 local nameprep = have_encodings and encodings.stringprep.nameprep or function (host) return host:lower(); end | |
21 | 24 |
22 module "configmanager" | 25 module "configmanager" |
23 | 26 |
24 _M.resolve_relative_path = resolve_relative_path; -- COMPAT | 27 _M.resolve_relative_path = resolve_relative_path; -- COMPAT |
25 | 28 |
137 end | 140 end |
138 }); | 141 }); |
139 | 142 |
140 rawset(env, "__currenthost", "*") -- Default is global | 143 rawset(env, "__currenthost", "*") -- Default is global |
141 function env.VirtualHost(name) | 144 function env.VirtualHost(name) |
145 name = nameprep(name); | |
142 if rawget(config, name) and rawget(config[name], "component_module") then | 146 if rawget(config, name) and rawget(config[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", | 147 error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s", |
144 name, config[name].component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); | 148 name, config[name].component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); |
145 end | 149 end |
146 rawset(env, "__currenthost", name); | 150 rawset(env, "__currenthost", name); |
154 end; | 158 end; |
155 end | 159 end |
156 env.Host, env.host = env.VirtualHost, env.VirtualHost; | 160 env.Host, env.host = env.VirtualHost, env.VirtualHost; |
157 | 161 |
158 function env.Component(name) | 162 function env.Component(name) |
163 name = nameprep(name); | |
159 if rawget(config, name) and rawget(config[name], "defined") and not rawget(config[name], "component_module") then | 164 if rawget(config, name) and rawget(config[name], "defined") and not rawget(config[name], "component_module") then |
160 error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s", | 165 error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s", |
161 name, name, name), 0); | 166 name, name, name), 0); |
162 end | 167 end |
163 set(config, name, "component_module", "component"); | 168 set(config, name, "component_module", "component"); |