- hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} };
- log("info", "Activated host: %s", host);
- eventmanager.fire_event("host-activated", host, host_config);
+ if rawget(hosts, host) then return nil, "The host "..host.." is already activated"; end
+ host_config = host_config or configmanager.getconfig()[host];
+ if not host_config then return nil, "Couldn't find the host "..tostring(host).." defined in the current config"; end
+ local host_session = {
+ host = host;
+ s2sout = {};
+ events = events_new();
+ dialback_secret = configmanager.get(host, "dialback_secret") or uuid_gen();
+ send = host_send;
+ modules = {};
+ };
+ if not host_config.component_module then -- host
+ host_session.type = "local";
+ host_session.sessions = {};
+ else -- component
+ host_session.type = "component";
+ end
+ hosts[host] = host_session;
+ if not host:match("[@/]") then
+ disco_items:set(host:match("%.(.*)") or "*", host, host_config.name or true);
+ end
+ for option_name in pairs(host_config) do
+ if option_name:match("_ports$") or option_name:match("_interface$") then
+ log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in the server-wide section instead", host, option_name);
+ end
+ end
+
+ log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host);
+ prosody_events.fire_event("host-activated", host);
+ return true;