Comparison

core/stanza_router.lua @ 1008:da7691ebec9c

core/eventmanager2 - new event manager
author Waqas Hussain <waqas20@gmail.com>
date Wed, 15 Apr 2009 02:10:05 +0500
parent 967:b021403c5d80
child 1011:beb039827c9f
comparison
equal deleted inserted replaced
997:c81b6141d693 1008:da7691ebec9c
38 local ipairs = ipairs; 38 local ipairs = ipairs;
39 39
40 local jid_split = require "util.jid".split; 40 local jid_split = require "util.jid".split;
41 local jid_prepped_split = require "util.jid".prepped_split; 41 local jid_prepped_split = require "util.jid".prepped_split;
42 local print = print; 42 local print = print;
43 local fire_event = require "core.eventmanager2".fire_event;
43 local function checked_error_reply(origin, stanza) 44 local function checked_error_reply(origin, stanza)
44 if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then 45 if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
45 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? 46 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
46 end 47 end
47 end 48 end
98 return; -- FIXME what should we do here? 99 return; -- FIXME what should we do here?
99 end]] -- FIXME 100 end]] -- FIXME
100 101
101 -- FIXME do stanzas not of jabber:client get handled by components? 102 -- FIXME do stanzas not of jabber:client get handled by components?
102 if (origin.type == "s2sin" or origin.type == "c2s" or origin.type == "component") and (not xmlns or xmlns == "jabber:server" or xmlns == "jabber:client") then 103 if (origin.type == "s2sin" or origin.type == "c2s" or origin.type == "component") and (not xmlns or xmlns == "jabber:server" or xmlns == "jabber:client") then
104 local event_data = {origin=origin, stanza=stanza};
105 fire_event(tostring(host or origin.host).."/"..stanza.name, event_data);
103 if origin.type == "s2sin" and not origin.dummy then 106 if origin.type == "s2sin" and not origin.dummy then
104 local host_status = origin.hosts[from_host]; 107 local host_status = origin.hosts[from_host];
105 if not host_status or not host_status.authed then -- remote server trying to impersonate some other server? 108 if not host_status or not host_status.authed then -- remote server trying to impersonate some other server?
106 log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from_host, origin.from_host); 109 log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from_host, origin.from_host);
107 return; -- FIXME what should we do here? does this work with subdomains? 110 return; -- FIXME what should we do here? does this work with subdomains?