- hosts[host] = {type = "local", connected = true, sessions = {},
- host = host, s2sout = {}, events = events_new(),
- disallow_s2s = configmanager.get(host, "core", "disallow_s2s")
- or (configmanager.get(host, "core", "anonymous_login")
- and (configmanager.get(host, "core", "disallow_s2s") ~= false));
- dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen();
- };
+ if 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, "core", "dialback_secret") or uuid_gen();
+ disallow_s2s = configmanager.get(host, "core", "disallow_s2s");
+ };
+ if not host_config.core.component_module then -- host
+ host_session.type = "local";
+ host_session.sessions = {};
+ if configmanager.get(host, "core", "anonymous_login") then
+ host_session.disallow_s2s = (configmanager.get(host, "core", "disallow_s2s") ~= false);
+ end
+ else -- component
+ host_session.type = "component";
+ end
+ hosts[host] = host_session;
+ if not host:match("[@/]") then
+ disco_items:set(host:match("%.(.*)") or "*", host, true);
+ end