ejabberd - Comments for "&amp;#039;Static&amp;#039; rosters" https://www.ejabberd.im/node/1589 en Legoscia found a bug. Try new version https://www.ejabberd.im/node/1589#comment-20670 <p>Legoscia found a bug. I've updated the code on my initial comment. You can see that at the end there are now several "".</p> Tue, 19 Jun 2007 21:18:25 +0000 mfoss comment 20670 at https://www.ejabberd.im Atoms → strings https://www.ejabberd.im/node/1589#comment-20606 <div class="quote-msg"> <div class="quote-author"><em>badlop</em> wrote:</div> <pre>% <noindex><a href="http://www.xmpp.org/rfcs/rfc3921.html#sub" title="http://www.xmpp.org/rfcs/rfc3921.html#sub" rel="nofollow" >http://www.xmpp.org/rfcs/rfc3921.html#sub</a></noindex> check_rosterchange({xmlelement, "presence", Attrs, _}) -&gt; case xml:get_attr_s("type", Attrs) of subscribe -&gt; true; subscribed -&gt; true; unsubscribe -&gt; true; unsubscribed -&gt; true; _ -&gt; false end.</pre></div> <p>Shouldn't those be strings?</p> Tue, 19 Jun 2007 16:20:41 +0000 legoscia comment 20606 at https://www.ejabberd.im Thanks a lot! https://www.ejabberd.im/node/1589#comment-20470 <p>Hi badlop,</p> <p> many thanks for providing this filter! It works great! </p> <p>There is still a small problem: Though all packets regarding the roster are filtered, it is still possible to add an item to an user's roster (checked via Web-Interface). Any other operation (deletion, modification etc.) is blocked successfully.</p> Tue, 19 Jun 2007 15:29:02 +0000 doozer comment 20470 at https://www.ejabberd.im Try this small mod_filterroster.erl https://www.ejabberd.im/node/1589#comment-19909 <p>Try this small mod_filterroster.erl module. It drops all the XMPP packets that are typically used to modify the roster. Note that it drops packets even from admins, and for all vhosts.</p> <ol> <li>Open a file called mod_filterroster.erl and put the content. </li><li>Compile the .erl into a .beam. You need full Erlang/OTP installation, it doesn't care which operating system:<br /> <pre>$ erlc mod_filterroster.erl ./mod_filterroster.erl:2: Warning: behaviour gen_mod undefined</pre></li><li>Copy the resulting .beam file to the directory where all the other ejabberd .beam files are. </li><li>Configure ejabberd to enable this module. For example on ejabberd.cfg:<br /> <pre>{modules, [ ... {mod_filterroster, []}, ... ]}.</pre></li></ol> <p>Here is the source code:</p> <pre>-module(mod_filterroster). -behaviour(gen_mod). -export([start/2, stop/1, filter/1]). %-include("jlib.hrl"). -define(NS_ROSTER, "jabber:iq:roster"). -record(iq, {id = "", type, xmlns = "", lang = "", sub_el}). start(_Host, _Opts) -&gt; ejabberd_hooks:add(filter_packet, global, ?MODULE, filter, 10). stop(_Host) -&gt; ejabberd_hooks:delete(filter_packet, global, ?MODULE, filter, 10). filter(drop) -&gt; drop; filter({_From, _To, Packet} = Input) -&gt; case check_rosterchange(Packet) of false -&gt; Input; true -&gt; drop end. % <noindex><a href="http://www.xmpp.org/rfcs/rfc3921.html#roster" title="http://www.xmpp.org/rfcs/rfc3921.html#roster" rel="nofollow" >http://www.xmpp.org/rfcs/rfc3921.html#roster</a></noindex> check_rosterchange({xmlelement, "iq", _, _} = Packet) -&gt; IQ = jlib:iq_query_info(Packet), case catch #iq{type = set, xmlns = ?NS_ROSTER} = IQ of {'EXIT', _} -&gt; false; _ -&gt; true end; % <noindex><a href="http://www.xmpp.org/rfcs/rfc3921.html#sub" title="http://www.xmpp.org/rfcs/rfc3921.html#sub" rel="nofollow" >http://www.xmpp.org/rfcs/rfc3921.html#sub</a></noindex> check_rosterchange({xmlelement, "presence", Attrs, _}) -&gt; case xml:get_attr_s("type", Attrs) of "subscribe" -&gt; true; "subscribed" -&gt; true; "unsubscribe" -&gt; true; "unsubscribed" -&gt; true; _ -&gt; false end.</pre> Tue, 19 Jun 2007 08:54:10 +0000 mfoss comment 19909 at https://www.ejabberd.im