Comparison

mod_ipcheck/mod_ipcheck.lua @ 134:744deabdee81

mod_ipcheck: Fixed: 'service-unavailable' was sent instead of 'forbidden' on unauthorized access.
author Waqas Hussain <waqas20@gmail.com>
date Sat, 06 Mar 2010 06:19:38 +0500
parent 131:46741fc09091
child 135:d3c28c5fdbae
comparison
equal deleted inserted replaced
133:8945153321a1 134:744deabdee81
6 6
7 module:add_feature("urn:xmpp:sic:0"); 7 module:add_feature("urn:xmpp:sic:0");
8 8
9 module:hook("iq/bare/urn:xmpp:sic:0:ip", function(event) 9 module:hook("iq/bare/urn:xmpp:sic:0:ip", function(event)
10 local origin, stanza = event.origin, event.stanza; 10 local origin, stanza = event.origin, event.stanza;
11 if not stanza.attr.to and stanza.attr.type == "get" then 11 if stanza.attr.type == "get" then
12 if stanza.attr.to then 12 if stanza.attr.to then
13 origin.send(st.error_reply(stanza, "auth", "forbidden", "You can only ask about your own IP address")); 13 origin.send(st.error_reply(stanza, "auth", "forbidden", "You can only ask about your own IP address"));
14 elseif origin.ip then 14 elseif origin.ip then
15 origin.send(st.reply(stanza):tag("ip", {xmlns='urn:xmpp:sic:0'}):text(origin.ip)); 15 origin.send(st.reply(stanza):tag("ip", {xmlns='urn:xmpp:sic:0'}):text(origin.ip));
16 else 16 else