Mercurial > prosody-modules
comparison mod_vjud/mod_vjud.lua @ 882:4939788a47ea
mod_vjud: Disallow searching from remote hosts by default in search-all-users mode
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 16 Dec 2012 12:51:34 +0100 |
parents | 4b06d6c79b15 |
children | b1a92a87309c |
comparison
equal
deleted
inserted
replaced
881:4b06d6c79b15 | 882:4939788a47ea |
---|---|
29 <email>{email}</email> | 29 <email>{email}</email> |
30 </item> | 30 </item> |
31 ]]; | 31 ]]; |
32 | 32 |
33 local search_mode = module:get_option_string("vjud_mode", "opt-in"); | 33 local search_mode = module:get_option_string("vjud_mode", "opt-in"); |
34 local allow_remote = module:get_option_boolean("allow_remote_searches", search_mode ~= "all"); | |
34 local base_host = module:get_option_string("vjud_search_domain", | 35 local base_host = module:get_option_string("vjud_search_domain", |
35 module:get_host_type() == "component" | 36 module:get_host_type() == "component" |
36 and module.host:gsub("^[^.]+%.","") | 37 and module.host:gsub("^[^.]+%.","") |
37 or module.host); | 38 or module.host); |
38 | 39 |
65 | 66 |
66 local users; -- The user iterator | 67 local users; -- The user iterator |
67 | 68 |
68 module:hook("iq/host/jabber:iq:search:query", function(event) | 69 module:hook("iq/host/jabber:iq:search:query", function(event) |
69 local origin, stanza = event.origin, event.stanza; | 70 local origin, stanza = event.origin, event.stanza; |
71 | |
72 if not (allow_remote or origin.type == "c2s") then | |
73 origin.send(st.error_reply(stanza, "cancel", "not-allowed")) | |
74 return true; | |
75 end | |
70 | 76 |
71 if stanza.attr.type == "get" then | 77 if stanza.attr.type == "get" then |
72 origin.send(st.reply(stanza):add_child(get_reply)); | 78 origin.send(st.reply(stanza):add_child(get_reply)); |
73 else -- type == "set" | 79 else -- type == "set" |
74 local query = stanza.tags[1]; | 80 local query = stanza.tags[1]; |