# HG changeset patch # User Waqas Hussain # Date 1266552502 -18000 # Node ID 51cd803e86be5efcb71ad7575c69bec9c95650f6 # Parent 5fc00a3e47b543ec3ac1c138a89d8dbd320dba72 mod_ipcheck: Initial commit. An implementation of the Server IP Check proto-XEP. diff -r 5fc00a3e47b5 -r 51cd803e86be mod_ipcheck/mod_ipcheck.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_ipcheck/mod_ipcheck.lua Fri Feb 19 09:08:22 2010 +0500 @@ -0,0 +1,22 @@ + +-- mod_ipcheck.lua +-- Implementation of XEP-xxxx: Server IP Check + +local st = require "util.stanza"; + +module:add_feature("urn:xmpp:sic:0"); + +module:hook("iq/bare/urn:xmpp:sic:0:ip", function(event) + local origin, stanza = event.origin, event.stanza; + if not stanza.attr.to and stanza.attr.type == "get" then + if stanza.attr.to then + origin.send(st.error_reply(stanza, "auth", "not-authorized", "You can only ask about your own IP address")); + elseif origin.ip then + origin.send(st.reply(stanza):tag("ip", {xmlns='urn:xmpp:sic:0'}):text(origin.ip)); + else + -- IP addresses should normally be available, but in case they are not + origin.send(st.error_reply(stanza, "cancel", "item-not-found", "IP address for this session is not available")); + end + return true; + end +end);