Comparison

core/stanza_router.lua @ 1367:e4d660e58dfc

stanza_router: A little refactoring
author Waqas Hussain <waqas20@gmail.com>
date Sat, 20 Jun 2009 17:51:00 +0500
parent 1358:71fbf8a52dcf
child 1368:0cb70958b8fb
comparison
equal deleted inserted replaced
1366:54b5121b6c83 1367:e4d660e58dfc
46 origin.send(st.error_reply(stanza, "modify", "bad-request")); 46 origin.send(st.error_reply(stanza, "modify", "bad-request"));
47 return; 47 return;
48 end 48 end
49 end 49 end
50 50
51 if origin.type == "c2s" and not origin.full_jid
52 and not(stanza.name == "iq" and stanza.attr.type == "set" and stanza.tags[1] and stanza.tags[1].name == "bind"
53 and stanza.tags[1].attr.xmlns == "urn:ietf:params:xml:ns:xmpp-bind") then
54 -- authenticated client isn't bound and current stanza is not a bind request
55 origin.send(st.error_reply(stanza, "auth", "not-authorized")); -- FIXME maybe allow stanzas to account or server
56 end
57
58 -- TODO also, stanzas should be returned to their original state before the function ends
59 if origin.type == "c2s" then 51 if origin.type == "c2s" then
52 if not origin.full_jid
53 and not(stanza.name == "iq" and stanza.attr.type == "set" and stanza.tags[1] and stanza.tags[1].name == "bind"
54 and stanza.tags[1].attr.xmlns == "urn:ietf:params:xml:ns:xmpp-bind") then
55 -- authenticated client isn't bound and current stanza is not a bind request
56 origin.send(st.error_reply(stanza, "auth", "not-authorized")); -- FIXME maybe allow stanzas to account or server
57 end
58
59 -- TODO also, stanzas should be returned to their original state before the function ends
60 stanza.attr.from = origin.full_jid; 60 stanza.attr.from = origin.full_jid;
61 end 61 end
62 local to, xmlns = stanza.attr.to, stanza.attr.xmlns; 62 local to, xmlns = stanza.attr.to, stanza.attr.xmlns;
63 local from = stanza.attr.from; 63 local from = stanza.attr.from;
64 local node, host, resource; 64 local node, host, resource;