Software /
code /
prosody
Comparison
core/stanza_router.lua @ 1162:bd1f0e6d50a7
Merging SASL buggy client workaround with current tip.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Fri, 15 May 2009 17:33:04 +0200 |
parent | 1157:279f79389189 |
child | 1163:8b4a57765b04 |
comparison
equal
deleted
inserted
replaced
1161:5bc2b7b5b81d | 1162:bd1f0e6d50a7 |
---|---|
52 function core_process_stanza(origin, stanza) | 52 function core_process_stanza(origin, stanza) |
53 (origin.log or log)("debug", "Received[%s]: %s", origin.type, stanza:top_tag()) | 53 (origin.log or log)("debug", "Received[%s]: %s", origin.type, stanza:top_tag()) |
54 | 54 |
55 if not stanza.attr.xmlns then stanza.attr.xmlns = "jabber:client"; end -- FIXME Hack. This should be removed when we fix namespace handling. | 55 if not stanza.attr.xmlns then stanza.attr.xmlns = "jabber:client"; end -- FIXME Hack. This should be removed when we fix namespace handling. |
56 -- TODO verify validity of stanza (as well as JID validity) | 56 -- TODO verify validity of stanza (as well as JID validity) |
57 if stanza.attr.xmlns == "error" and #stanza.tags == 0 then return; end -- TODO invalid stanza, log | 57 if stanza.attr.type == "error" and #stanza.tags == 0 then return; end -- TODO invalid stanza, log |
58 if stanza.name == "iq" then | 58 if stanza.name == "iq" then |
59 if (stanza.attr.type == "set" or stanza.attr.type == "get") and #stanza.tags ~= 1 then | 59 if (stanza.attr.type == "set" or stanza.attr.type == "get") and #stanza.tags ~= 1 then |
60 origin.send(st.error_reply(stanza, "modify", "bad-request")); | 60 origin.send(st.error_reply(stanza, "modify", "bad-request")); |
61 return; | 61 return; |
62 end | 62 end |
104 --[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us? | 104 --[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us? |
105 log("warn", "stanza recieved for a non-local server"); | 105 log("warn", "stanza recieved for a non-local server"); |
106 return; -- FIXME what should we do here? | 106 return; -- FIXME what should we do here? |
107 end]] -- FIXME | 107 end]] -- FIXME |
108 | 108 |
109 -- FIXME do stanzas not of jabber:client get handled by components? | |
110 if (origin.type == "s2sin" or origin.type == "c2s" or origin.type == "component") and (not xmlns or xmlns == "jabber:server" or xmlns == "jabber:client") then | 109 if (origin.type == "s2sin" or origin.type == "c2s" or origin.type == "component") and (not xmlns or xmlns == "jabber:server" or xmlns == "jabber:client") then |
111 local event_data = {origin=origin, stanza=stanza}; | 110 local event_data = {origin=origin, stanza=stanza}; |
112 fire_event(tostring(host or origin.host).."/"..stanza.name, event_data); | 111 if fire_event(tostring(host or origin.host).."/"..stanza.name, event_data) then return; end |
113 if origin.type == "s2sin" and not origin.dummy then | 112 if origin.type == "s2sin" and not origin.dummy then |
114 local host_status = origin.hosts[from_host]; | 113 local host_status = origin.hosts[from_host]; |
115 if not host_status or not host_status.authed then -- remote server trying to impersonate some other server? | 114 if not host_status or not host_status.authed then -- remote server trying to impersonate some other server? |
116 log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from_host, origin.from_host); | 115 log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from_host, origin.from_host); |
117 return; -- FIXME what should we do here? does this work with subdomains? | 116 return; -- FIXME what should we do here? does this work with subdomains? |
118 end | 117 end |
119 end | |
120 if origin.type == "c2s" and stanza.name == "presence" and to ~= nil and not(origin.roster[to_bare] and (origin.roster[to_bare].subscription == "both" or origin.roster[to_bare].subscription == "from")) then -- directed presence | |
121 origin.directed = origin.directed or {}; | |
122 origin.directed[to] = true; | |
123 --t_insert(origin.directed, to); -- FIXME does it make more sense to add to_bare rather than to? | |
124 end | 118 end |
125 if not to then | 119 if not to then |
126 core_handle_stanza(origin, stanza); | 120 core_handle_stanza(origin, stanza); |
127 elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server | 121 elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server |
128 core_handle_stanza(origin, stanza); | 122 core_handle_stanza(origin, stanza); |
132 component_handle_stanza(origin, stanza); | 126 component_handle_stanza(origin, stanza); |
133 elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server | 127 elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server |
134 component_handle_stanza(origin, stanza); | 128 component_handle_stanza(origin, stanza); |
135 elseif hosts[host] and hosts[host].type == "component" then -- directed at a component | 129 elseif hosts[host] and hosts[host].type == "component" then -- directed at a component |
136 component_handle_stanza(origin, stanza); | 130 component_handle_stanza(origin, stanza); |
137 elseif origin.type == "c2s" and stanza.name == "presence" and stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then | |
138 handle_outbound_presence_subscriptions_and_probes(origin, stanza, from_bare, to_bare, core_route_stanza); | |
139 elseif hosts[host] and hosts[host].type == "local" and stanza.name == "iq" and not resource then -- directed at bare JID | 131 elseif hosts[host] and hosts[host].type == "local" and stanza.name == "iq" and not resource then -- directed at bare JID |
140 core_handle_stanza(origin, stanza); | 132 core_handle_stanza(origin, stanza); |
141 else | 133 else |
142 core_route_stanza(origin, stanza); | 134 core_route_stanza(origin, stanza); |
143 end | 135 end |