Mercurial > prosody-modules
annotate mod_readonly/mod_readonly.lua @ 2491:5fbca7de2088
mod_smacks: Send out more ack requests where needed
Under some circumstances it was possible that more than "max_unacked_stanzas"
where left in the outgoing stanza queue without forcing an ack.
This could happen, when more stanzas entered the queue while the last ack request
was still unanswered.
Now the test "#queue > max_unacked_stanzas" is done upon receiving
an ack as well as when sending out stanzas, which fixes this bug.
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Sun, 12 Feb 2017 19:27:50 +0100 |
parents | 8133dd5f266a |
children | 7776c9dc5f37 |
rev | line source |
---|---|
750
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local stores = module:get_option("readonly_stores", { |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 vcard = { "vcard-temp", "vCard" }; |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 }); |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local namespaces = {}; |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 for name, namespace in pairs(stores) do |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 namespaces[table.concat(namespace, ":")] = name; |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 end |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 function prevent_write(event) |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local stanza = event.stanza; |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 if stanza.attr.type ~= "set" then return; end |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 local xmlns_and_tag = stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name; |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 local store_name = namespaces[xmlns_and_tag]; |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 if store_name then |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 module:log("warn", "Preventing modification of %s store by %s", store_name, stanza.attr.from); |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 event.origin.send(st.error_reply(stanza, "cancel", "not-allowed", store_name.." data is read-only")); |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 return true; -- Block stanza |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 end |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 for namespace in pairs(namespaces) do |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 module:hook("iq/bare/"..namespace, prevent_write, 200); |
8133dd5f266a
mod_readonly: Allow preventing direct modification of certain user data via XMPP
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 end |