Mercurial > prosody-hg
comparison core/componentmanager.lua @ 3602:a977d8be6277
componentmanager: Removed get_children(host).
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 10 Nov 2010 20:42:59 +0500 |
| parents | 8090880f0e18 |
| children | fdc671381411 |
comparison
equal
deleted
inserted
replaced
| 3601:829e23b374cc | 3602:a977d8be6277 |
|---|---|
| 19 local uuid_gen = require "util.uuid".generate; | 19 local uuid_gen = require "util.uuid".generate; |
| 20 | 20 |
| 21 local pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring; | 21 local pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring; |
| 22 | 22 |
| 23 local components = {}; | 23 local components = {}; |
| 24 | |
| 25 local disco_items = require "util.multitable".new(); | |
| 26 local NULL = {}; | |
| 27 | 24 |
| 28 module "componentmanager" | 25 module "componentmanager" |
| 29 | 26 |
| 30 local function default_component_handler(origin, stanza) | 27 local function default_component_handler(origin, stanza) |
| 31 log("warn", "Stanza being handled by default component; bouncing error for: %s", stanza:top_tag()); | 28 log("warn", "Stanza being handled by default component; bouncing error for: %s", stanza:top_tag()); |
| 56 | 53 |
| 57 if not hosts[host].dialback_secret then | 54 if not hosts[host].dialback_secret then |
| 58 hosts[host].dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); | 55 hosts[host].dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); |
| 59 end | 56 end |
| 60 | 57 |
| 61 -- add to disco_items | |
| 62 if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then | |
| 63 disco_items:set(host:sub(host:find(".", 1, true)+1), host, true); | |
| 64 end | |
| 65 modulemanager.load(host, "dialback"); | 58 modulemanager.load(host, "dialback"); |
| 66 modulemanager.load(host, "tls"); | 59 modulemanager.load(host, "tls"); |
| 67 log("debug", "component added: "..host); | 60 log("debug", "component added: "..host); |
| 68 return hosts[host]; | 61 return hosts[host]; |
| 69 else | 62 else |
| 82 else | 75 else |
| 83 -- Component not in config, or disabled, remove | 76 -- Component not in config, or disabled, remove |
| 84 hosts[host] = nil; -- FIXME do proper unload of all modules and other cleanup before removing | 77 hosts[host] = nil; -- FIXME do proper unload of all modules and other cleanup before removing |
| 85 components[host] = nil; | 78 components[host] = nil; |
| 86 end | 79 end |
| 87 -- remove from disco_items | |
| 88 if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then | |
| 89 disco_items:remove(host:sub(host:find(".", 1, true)+1), host); | |
| 90 end | |
| 91 log("debug", "component removed: "..host); | 80 log("debug", "component removed: "..host); |
| 92 return true; | 81 return true; |
| 93 else | 82 else |
| 94 log("error", "Attempt to remove component for non-existing host: "..host); | 83 log("error", "Attempt to remove component for non-existing host: "..host); |
| 95 end | 84 end |
| 96 end | 85 end |
| 97 | 86 |
| 98 function get_children(host) | |
| 99 return disco_items:get(host) or NULL; | |
| 100 end | |
| 101 | |
| 102 return _M; | 87 return _M; |
