Software /
code /
prosody
Comparison
core/stanza_router.lua @ 210:e679487e2fa4
Part 2 of internal components. Should have mentioned that the previous commit was from waqas, this one from me.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 04 Nov 2008 18:17:48 +0000 |
parent | 209:e9de0803676d |
child | 215:ec90acc13ba3 |
comparison
equal
deleted
inserted
replaced
209:e9de0803676d | 210:e679487e2fa4 |
---|---|
73 -- FIXME do stanzas not of jabber:client get handled by components? | 73 -- FIXME do stanzas not of jabber:client get handled by components? |
74 if not to then | 74 if not to then |
75 core_handle_stanza(origin, stanza); | 75 core_handle_stanza(origin, stanza); |
76 elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server | 76 elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server |
77 core_handle_stanza(origin, stanza); | 77 core_handle_stanza(origin, stanza); |
78 elseif stanza.attr.xmlns and stanza.attr.xmlns ~= "jabber:client" and stanza.attr.xmlns ~= "jabber:server" then | |
79 modules_handle_stanza(origin, stanza); | |
78 elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server | 80 elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server |
79 component_handle_stanza(origin, stanza); | 81 component_handle_stanza(origin, stanza); |
80 elseif hosts[to] and hosts[to].type == "component" then -- hack to allow components to handle node@server/resource and server/resource | 82 elseif hosts[to] and hosts[to].type == "component" then -- hack to allow components to handle node@server/resource and server/resource |
81 component_handle_stanza(origin, stanza); | 83 component_handle_stanza(origin, stanza); |
82 elseif hosts[host].type == "component" then -- directed at a component | 84 elseif hosts[host].type == "component" then -- directed at a component |
83 component_handle_stanza(origin, stanza); | 85 component_handle_stanza(origin, stanza); |
84 elseif origin.type == "c2s" and stanza.name == "presence" and stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" then | 86 elseif origin.type == "c2s" and stanza.name == "presence" and stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" then |
85 handle_outbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare); | 87 handle_outbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare); |
86 elseif stanza.name == "iq" and not resource then -- directed at bare JID | 88 elseif stanza.name == "iq" and not resource then -- directed at bare JID |
87 core_handle_stanza(origin, stanza); | 89 core_handle_stanza(origin, stanza); |
88 elseif stanza.attr.xmlns and stanza.attr.xmlns ~= "jabber:client" and stanza.attr.xmlns ~= "jabber:server" then | |
89 modules_handle_stanza(origin, stanza); | |
90 elseif origin.type == "c2s" or origin.type == "s2sin" then | 90 elseif origin.type == "c2s" or origin.type == "s2sin" then |
91 core_route_stanza(origin, stanza); | 91 core_route_stanza(origin, stanza); |
92 else | 92 else |
93 log("warn", "stanza not processed"); | 93 log("warn", "stanza not processed"); |
94 end | 94 end |
368 --stanza.attr.xmlns = "jabber:server"; | 368 --stanza.attr.xmlns = "jabber:server"; |
369 stanza.attr.xmlns = nil; | 369 stanza.attr.xmlns = nil; |
370 log("debug", "sending s2s stanza: %s", tostring(stanza)); | 370 log("debug", "sending s2s stanza: %s", tostring(stanza)); |
371 send_s2s(origin.host, host, stanza); -- TODO handle remote routing errors | 371 send_s2s(origin.host, host, stanza); -- TODO handle remote routing errors |
372 stanza.attr.xmlns = xmlns; -- reset | 372 stanza.attr.xmlns = xmlns; -- reset |
373 elseif origin.type == "component" or origin.type == "local" then | |
374 -- Route via s2s for components and modules | |
375 log("debug", "Routing outgoing stanza for %s to %s", origin.host, host); | |
376 for k,v in pairs(origin) do print("origin:", tostring(k), tostring(v)); end | |
377 print(tostring(host), tostring(from_host)) | |
378 send_s2s(origin.host, host, stanza); | |
373 else | 379 else |
374 log("warn", "received stanza from unhandled connection type: %s", origin.type); | 380 log("warn", "received stanza from unhandled connection type: %s", origin.type); |
375 end | 381 end |
376 stanza.attr.to = to; -- reset | 382 stanza.attr.to = to; -- reset |
377 end | 383 end |
378 | 384 |
379 function handle_stanza_toremote(stanza) | 385 function handle_stanza_toremote(stanza) |
380 log("error", "Stanza bound for remote host, but s2s is not implemented"); | 386 log("error", "Stanza bound for remote host, but s2s is not implemented"); |
381 end | 387 end |
388 | |
389 |