Software /
code /
prosody
Comparison
core/stanza_router.lua @ 83:79608fc8f98d
Fixed routing for IQs to bare JIDs, and added a simple IQ validity check
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 09 Oct 2008 01:18:48 +0500 |
parent | 78:972e31cc91e8 |
child | 105:b099f0f80775 |
comparison
equal
deleted
inserted
replaced
81:a1f4f3c5ae25 | 83:79608fc8f98d |
---|---|
14 local jid_split = jid.split; | 14 local jid_split = jid.split; |
15 | 15 |
16 function core_process_stanza(origin, stanza) | 16 function core_process_stanza(origin, stanza) |
17 log("debug", "Received: "..tostring(stanza)) | 17 log("debug", "Received: "..tostring(stanza)) |
18 -- TODO verify validity of stanza (as well as JID validity) | 18 -- TODO verify validity of stanza (as well as JID validity) |
19 if stanza.name == "iq" and not(#stanza.tags == 1 and stanza.tags[1].attr.xmlns) then | |
20 error("Invalid IQ"); | |
21 end | |
19 | 22 |
20 if origin.type == "c2s" and not origin.full_jid | 23 if origin.type == "c2s" and not origin.full_jid |
21 and not(stanza.name == "iq" and stanza.tags[1] and stanza.tags[1].name == "bind" | 24 and not(stanza.name == "iq" and stanza.tags[1].name == "bind" |
22 and stanza.tags[1].attr.xmlns == "urn:ietf:params:xml:ns:xmpp-bind") then | 25 and stanza.tags[1].attr.xmlns == "urn:ietf:params:xml:ns:xmpp-bind") then |
23 error("Client MUST bind resource after auth"); | 26 error("Client MUST bind resource after auth"); |
24 end | 27 end |
25 | 28 |
26 | 29 |
27 local to = stanza.attr.to; | 30 local to = stanza.attr.to; |
28 stanza.attr.from = origin.full_jid -- quick fix to prevent impersonation | 31 stanza.attr.from = origin.full_jid -- quick fix to prevent impersonation |
29 | 32 |
30 if not to or (hosts[to] and hosts[to].type == "local") then | 33 if not to or (hosts[to] and hosts[to].type == "local") then |
34 core_handle_stanza(origin, stanza); | |
35 elseif to and stanza.name == "iq" and not select(3, jid_split(to)) then | |
31 core_handle_stanza(origin, stanza); | 36 core_handle_stanza(origin, stanza); |
32 elseif origin.type == "c2s" then | 37 elseif origin.type == "c2s" then |
33 core_route_stanza(origin, stanza); | 38 core_route_stanza(origin, stanza); |
34 end | 39 end |
35 end | 40 end |