Comparison

core/stanza_router.lua @ 438:193f9dd64f17

Bumper commit for the new modulemanager API \o/ Updates all the modules, though some more changes may be in store.
author Matthew Wild <mwild1@gmail.com>
date Thu, 27 Nov 2008 03:12:12 +0000
parent 372:e7c1e30d06d5
child 468:ab49cb6d0e92
comparison
equal deleted inserted replaced
437:c1a720db2157 438:193f9dd64f17
1
2 -- The code in this file should be self-explanatory, though the logic is horrible
3 -- for more info on that, see doc/stanza_routing.txt, which attempts to condense
4 -- the rules from the RFCs (mainly 3921)
5
6 require "core.servermanager"
7 1
8 local log = require "util.logger".init("stanzarouter") 2 local log = require "util.logger".init("stanzarouter")
9 3
10 local st = require "util.stanza"; 4 local st = require "util.stanza";
11 local send_s2s = require "core.s2smanager".send_to_host; 5 local send_s2s = require "core.s2smanager".send_to_host;
80 if not to then 74 if not to then
81 core_handle_stanza(origin, stanza); 75 core_handle_stanza(origin, stanza);
82 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
83 core_handle_stanza(origin, stanza); 77 core_handle_stanza(origin, stanza);
84 elseif stanza.attr.xmlns and stanza.attr.xmlns ~= "jabber:client" and stanza.attr.xmlns ~= "jabber:server" then 78 elseif stanza.attr.xmlns and stanza.attr.xmlns ~= "jabber:client" and stanza.attr.xmlns ~= "jabber:server" then
85 modules_handle_stanza(origin, stanza); 79 modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
86 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
87 component_handle_stanza(origin, stanza); 81 component_handle_stanza(origin, stanza);
88 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
89 component_handle_stanza(origin, stanza); 83 component_handle_stanza(origin, stanza);
90 elseif hosts[host] and hosts[host].type == "component" then -- directed at a component 84 elseif hosts[host] and hosts[host].type == "component" then -- directed at a component
103 97
104 -- This function handles stanzas which are not routed any further, 98 -- This function handles stanzas which are not routed any further,
105 -- that is, they are handled by this server 99 -- that is, they are handled by this server
106 function core_handle_stanza(origin, stanza) 100 function core_handle_stanza(origin, stanza)
107 -- Handlers 101 -- Handlers
108 if modules_handle_stanza(origin, stanza) then return; end 102 if modules_handle_stanza(stanza.attr.to or origin.host, origin, stanza) then return; end
109 if origin.type == "c2s" or origin.type == "c2s_unauthed" then 103 if origin.type == "c2s" or origin.type == "c2s_unauthed" then
110 local session = origin; 104 local session = origin;
111 105
112 if stanza.name == "presence" and origin.roster then 106 if stanza.name == "presence" and origin.roster then
113 if stanza.attr.type == nil or stanza.attr.type == "unavailable" then 107 if stanza.attr.type == nil or stanza.attr.type == "unavailable" then