Mercurial > prosody-modules
view mod_ipcheck/mod_ipcheck.lua @ 133:8945153321a1
mod_adhoc_cmd_admin: Add "Shut Down Service" command
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Thu, 25 Feb 2010 22:43:54 +0100 |
parents | 46741fc09091 |
children | 744deabdee81 |
line wrap: on
line source
-- mod_ipcheck.lua -- Implementation of XEP-xxxx: Server IP Check <http://xmpp.org/extensions/inbox/sic.html> 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", "forbidden", "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);