Hi. It's time to ask for help on ejabberd.
The scenario is common in many production environments.
Agents are connectet to a XMPP server (ejabberd) and the need is that they cannot chat each other except with the supervisor.
I tried to find a way to block presence and messages between agents using the mod_filter downloaded from https://www.ejabberd.im/mod_filter but I had some problems.
First, some details
OS: Debian Wheezy
Erlang/OTP 17 [erts-6.2] installed via wheezy backports repo
ejabberd 17.06.beta-20 compiled from source
mod_filter compiled as module for ejabberd
During compilation mod_filter shows the errors:
mod_filter.erl:13: Warning: undefined callback function depends/2 (behaviour 'gen_mod')
mod_filter/src/mod_filter.erl:13: Warning: undefined callback function mod_opt_type/1 (behaviour 'gen_mod')
mod_filter/src/mod_filter.erl:13: Warning: undefined callback function reload/3 (behaviour 'gen_mod')
The module is loaded during ejabberd startup with a warning:
[warning] <0.1039.0>@gen_mod:get_validators:480 module 'mod_filter' doesn't export mod_opt_type/1
but seems to be active:
$./sbin/ejabberdctl modules_installed
mod_filter Filter Module
In my acl part of ejabberd.yml I put the line to activate the module:
modules:
...
mod_filter {}
...
I created the ACL "operatori" (agents logging with login "operatore1", "operatore2", etc) adding the line:
acl:
...
operatori:
user_glob:
- "operatore*"
...
The I created the ACL rule adding the lines:
access_rules:
...
filter:
- deny: operatori
...
When, say, operatore1 sends a message to operatore2 I catch in the log the following lines:
...
2017-06-23 18:03:28.654 [debug] <0.421.0>@ejabberd_router:do_route:337 route:
#message{id = <<"ba11d617-542a-4fb5-a1a5-b02af2a1bdc2">>,type = chat,
lang = <<"en">>,
from = {jid,<<"operatore1">>,<<"localhost">>,
<<"kde-telepathy-557160">>,<<"operatore1">>,
<<"localhost">>,<<"kde-telepathy-557160">>},
to = {jid,<<"operatore2">>,<<"localhost">>,<<>>,<<"operatore2">>,
<<"localhost">>,<<>>},
subject = [],
body = [#text{lang = <<>>,data = <<"ciupa">>}],
thread = undefined,
sub_els = [{xmlel,<<"active">>,
[{<<"xmlns">>,
<<"link to jabber.org/protocol/chatstates">>}],
[]}],
meta = #{ip => {0,0,0,0,0,65535,49320,3930}}}
2017-06-23 18:03:28.655 [error] <0.421.0>@ejabberd_hooks:safe_apply:383 Hook filter_packet crashed when running mod_filter:filter_packet/1:
** Reason = {error,function_clause,[{mod_filter,filter_packet,[{file,"/opt/ejabberd-server/etc/ejabberd-modules/sources/ejabberd-contrib/mod_filter/src/mod_filter.erl"},{line,31}],[{message,<<"ba11d617-542a-4fb5-a1a5-b02af2a1bdc2">>,chat,<<"en">>,{jid,<<"operatore1">>,<<"localhost">>,<<"kde-telepathy-557160">>,<<"operatore1">>,<<"localhost">>,<<"kde-telepathy-557160">>},{jid,<<"operatore2">>,<<"localhost">>,<<>>,<<"operatore2">>,<<"localhost">>,<<>>},[],[{text,<<>>,<<"ciupa">>}],undefined,[{xmlel,<<"active">>,[{<<"xmlns">>,<<"link to jabber.org/protocol/chatstates">>}],[]}],#{ip => {0,0,0,0,0,65535,49320,3930}}}]},{ejabberd_hooks,safe_apply,[{file,"src/ejabberd_hooks.erl"},{line,380}],4},{ejabberd_hooks,run_fold1,[{file,"src/ejabberd_hooks.erl"},{line,364}],4},{ejabberd_router,do_route,[{file,"src/ejabberd_router.erl"},{line,338}],1},{ejabberd_router,route,[{file,"src/ejabberd_router.erl"},{line,87}],1},{ejabberd_c2s,check_privacy_then_route,[{file,"src/ejabberd_c2s.erl"},{line,800}],2},{xmpp_stream_in,process_authenticated_packet,[{file,"src/xmpp_stream_in.erl"},{line,596}],2},{xmpp_stream_in,handle_info,[{file,"src/xmpp_stream_in.erl"},{line,341}],2}]}
** Arguments = [{message,<<"ba11d617-542a-4fb5-a1a5-b02af2a1bdc2">>,chat,<<"en">>,{jid,<<"operatore1">>,<<"localhost">>,<<"kde-telepathy-557160">>,<<"operatore1">>,<<"localhost">>,<<"kde-telepathy-557160">>},{jid,<<"operatore2">>,<<"localhost">>,<<>>,<<"operatore2">>,<<"localhost">>,<<>>},[],[{text,<<>>,<<"ciupa">>}],undefined,[{xmlel,<<"active">>,[{<<"xmlns">>,<<"link to jabber.org/protocol/chatstates">>}],[]}],#{ip => {0,0,0,0,0,65535,49320,3930}}}]
2017-06-23 18:03:28.656 [debug] <0.421.0>@ejabberd_local:do_route:256 local route:
#message{id = <<"ba11d617-542a-4fb5-a1a5-b02af2a1bdc2">>,type = chat,
...
and then the message do the normal routing arriving to operatore2.
The relevant part of the log is:
[error] <0.421.0>@ejabberd_hooks:safe_apply:383 Hook filter_packet crashed when running mod_filter:filter_packet/1
I'm not a programmer, and need some help, please.
I think the scenario is very used, so many people could be interested in solving the issue.
Thanks everybody could help.
g
Try this repository, it may
Try this repository, it may be updated and work with recent ejabberd:https://github.com/JohnBrodie/mod_filter
No one has some clue?
No one has some clue?
Hi @GD, here is the
Hi @GD, here is the discussion of the similar issue:
https://github.com/knobo/mod_filter/issues/2