Software /
code /
prosody
Comparison
core/hostmanager.lua @ 4498:9454d237cf7c
hostmanager: Add send() method to hosts
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 16 Dec 2011 16:01:59 +0000 |
parent | 3984:6be419e2f509 |
child | 4502:dd1eaecc11f9 |
comparison
equal
deleted
inserted
replaced
4497:f42a0833c47c | 4498:9454d237cf7c |
---|---|
51 hosts_loaded_once = true; | 51 hosts_loaded_once = true; |
52 end | 52 end |
53 | 53 |
54 prosody_events.add_handler("server-starting", load_enabled_hosts); | 54 prosody_events.add_handler("server-starting", load_enabled_hosts); |
55 | 55 |
56 local function host_send(stanza) | |
57 local name, type = stanza.name, stanza.attr.type; | |
58 if type == "error" or (name == "iq" and type == "result") then | |
59 local dest_host_name = select(2, jid_split(stanza.attr.to)); | |
60 local dest_host = hosts[dest_host_name] or { type = "unknown" }; | |
61 log("warn", "Unhandled response sent to %s host %s: %s", dest_host.type, dest_host_name, tostring(stanza)); | |
62 return; | |
63 end | |
64 core_route_stanza(nil, stanza); | |
65 end | |
66 | |
56 function activate(host, host_config) | 67 function activate(host, host_config) |
57 if hosts[host] then return nil, "The host "..host.." is already activated"; end | 68 if hosts[host] then return nil, "The host "..host.." is already activated"; end |
58 host_config = host_config or configmanager.getconfig()[host]; | 69 host_config = host_config or configmanager.getconfig()[host]; |
59 if not host_config then return nil, "Couldn't find the host "..tostring(host).." defined in the current config"; end | 70 if not host_config then return nil, "Couldn't find the host "..tostring(host).." defined in the current config"; end |
60 local host_session = { | 71 local host_session = { |
61 host = host; | 72 host = host; |
62 s2sout = {}; | 73 s2sout = {}; |
63 events = events_new(); | 74 events = events_new(); |
64 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); | 75 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); |
65 disallow_s2s = configmanager.get(host, "core", "disallow_s2s"); | 76 disallow_s2s = configmanager.get(host, "core", "disallow_s2s"); |
77 send = host_send; | |
66 }; | 78 }; |
67 if not host_config.core.component_module then -- host | 79 if not host_config.core.component_module then -- host |
68 host_session.type = "local"; | 80 host_session.type = "local"; |
69 host_session.sessions = {}; | 81 host_session.sessions = {}; |
70 else -- component | 82 else -- component |