Comparison

mod_ipcheck/mod_ipcheck.lua @ 1245:a1287d1f8a1f

mod_ipcheck: Workaround for differences between server_select and server_event
author Kim Alvefur <zash@zash.se>
date Wed, 04 Dec 2013 19:26:37 +0100
parent 1244:d1bc9a796daf
child 1945:e5039f14e2a7
comparison
equal deleted inserted replaced
1244:d1bc9a796daf 1245:a1287d1f8a1f
29 if stanza.attr.to then 29 if stanza.attr.to then
30 origin.send(st.error_reply(stanza, "auth", "forbidden", "You can only ask about your own IP address")); 30 origin.send(st.error_reply(stanza, "auth", "forbidden", "You can only ask about your own IP address"));
31 elseif origin.ip then 31 elseif origin.ip then
32 local reply = st.reply(stanza):tag("address", {xmlns='urn:xmpp:sic:0'}) 32 local reply = st.reply(stanza):tag("address", {xmlns='urn:xmpp:sic:0'})
33 :tag("ip"):text(origin.ip):up() 33 :tag("ip"):text(origin.ip):up()
34 if origin.conn and origin.conn.port then 34 if origin.conn and origin.conn.port then -- server_event
35 reply:tag("port"):text(tostring(origin.conn:port())) 35 reply:tag("port"):text(tostring(origin.conn:port()))
36 elseif origin.conn and origin.conn.clientport then -- server_select
37 reply:tag("port"):text(tostring(origin.conn:clientport()))
36 end 38 end
37 origin.send(reply); 39 origin.send(reply);
38 else 40 else
39 -- IP addresses should normally be available, but in case they are not 41 -- IP addresses should normally be available, but in case they are not
40 origin.send(st.error_reply(stanza, "cancel", "service-unavailable", "IP address for this session is not available")); 42 origin.send(st.error_reply(stanza, "cancel", "service-unavailable", "IP address for this session is not available"));