25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/mod_service_log.erl: Support for logging of user packets via

external service (e.g. bandersnatch)
* doc/guide.tex: Updated

SVN Revision: 261
This commit is contained in:
Alexey Shchepin 2004-08-24 20:11:01 +00:00
parent d543a63e9b
commit 6755925676
4 changed files with 124 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2004-08-24 Alexey Shchepin <alexey@sevcom.net>
* src/mod_service_log.erl: Support for logging of user packets via
external service (e.g. bandersnatch)
* doc/guide.tex: Updated
2004-08-23 Alexey Shchepin <alexey@sevcom.net> 2004-08-23 Alexey Shchepin <alexey@sevcom.net>
* src/mod_offline.erl: Added entire table locking on large message * src/mod_offline.erl: Added entire table locking on large message

View File

@ -98,12 +98,13 @@
<LI><A HREF="#htoc42">A.12&nbsp;&nbsp;<TT>mod_pubsub</TT></A> <LI><A HREF="#htoc42">A.12&nbsp;&nbsp;<TT>mod_pubsub</TT></A>
<LI><A HREF="#htoc43">A.13&nbsp;&nbsp;<TT>mod_register</TT></A> <LI><A HREF="#htoc43">A.13&nbsp;&nbsp;<TT>mod_register</TT></A>
<LI><A HREF="#htoc44">A.14&nbsp;&nbsp;<TT>mod_roster</TT></A> <LI><A HREF="#htoc44">A.14&nbsp;&nbsp;<TT>mod_roster</TT></A>
<LI><A HREF="#htoc45">A.15&nbsp;&nbsp;<TT>mod_stats</TT></A> <LI><A HREF="#htoc45">A.15&nbsp;&nbsp;<TT>mod_service_log</TT></A>
<LI><A HREF="#htoc46">A.16&nbsp;&nbsp;<TT>mod_time</TT></A> <LI><A HREF="#htoc46">A.16&nbsp;&nbsp;<TT>mod_stats</TT></A>
<LI><A HREF="#htoc47">A.17&nbsp;&nbsp;<TT>mod_vcard</TT></A> <LI><A HREF="#htoc47">A.17&nbsp;&nbsp;<TT>mod_time</TT></A>
<LI><A HREF="#htoc48">A.18&nbsp;&nbsp;<TT>mod_version</TT></A> <LI><A HREF="#htoc48">A.18&nbsp;&nbsp;<TT>mod_vcard</TT></A>
<LI><A HREF="#htoc49">A.19&nbsp;&nbsp;<TT>mod_version</TT></A>
</UL> </UL>
<LI><A HREF="#htoc49">B&nbsp;&nbsp;I18n/L10n</A> <LI><A HREF="#htoc50">B&nbsp;&nbsp;I18n/L10n</A>
</UL> </UL>
<!--TOC section Introduction--> <!--TOC section Introduction-->
@ -1083,9 +1084,32 @@ Options:
<B><TT>iqdisc</TT></B><DD> <TT>jabber:iq:roster</TT> IQ queries processing <B><TT>iqdisc</TT></B><DD> <TT>jabber:iq:roster</TT> IQ queries processing
discipline (see&nbsp;<A HREF="#sec:modiqdiscoption">A.1.1</A>). discipline (see&nbsp;<A HREF="#sec:modiqdiscoption">A.1.1</A>).
</DL> </DL>
<!--TOC subsection <TT>mod_service_log</TT>-->
<H3><A NAME="htoc45">A.15</A>&nbsp;&nbsp;<TT>mod_service_log</TT></H3><!--SEC END -->
<A NAME="sec:modservicelog"></A>
This module adds support for logging of user packets via any jabber service.
These packets encapsulated in &lt;route/&gt; element and sended to specified
services.<BR>
<BR>
Options:
<DL COMPACT=compact><DT>
<B><TT>loggers</TT></B><DD> Specifies a list of services which will receive users
packets.
</DL>
Example:
<PRE>
{modules,
[
...
{mod_service_log, [{loggers, ["bandersnatch.example.com"]}]},
...
]}.
</PRE>
<!--TOC subsection <TT>mod_stats</TT>--> <!--TOC subsection <TT>mod_stats</TT>-->
<H3><A NAME="htoc45">A.15</A>&nbsp;&nbsp;<TT>mod_stats</TT></H3><!--SEC END --> <H3><A NAME="htoc46">A.16</A>&nbsp;&nbsp;<TT>mod_stats</TT></H3><!--SEC END -->
<A NAME="sec:modstats"></A> <A NAME="sec:modstats"></A>
This module adds support for <A HREF="http://www.jabber.org/jeps/jep-0039.html">JEP-0039</A> (Statistics Gathering).<BR> This module adds support for <A HREF="http://www.jabber.org/jeps/jep-0039.html">JEP-0039</A> (Statistics Gathering).<BR>
@ -1099,7 +1123,7 @@ TBD about access.<BR>
<BR> <BR>
<!--TOC subsection <TT>mod_time</TT>--> <!--TOC subsection <TT>mod_time</TT>-->
<H3><A NAME="htoc46">A.16</A>&nbsp;&nbsp;<TT>mod_time</TT></H3><!--SEC END --> <H3><A NAME="htoc47">A.17</A>&nbsp;&nbsp;<TT>mod_time</TT></H3><!--SEC END -->
<A NAME="sec:modtime"></A> <A NAME="sec:modtime"></A>
This module answers UTC time on <TT>jabber:iq:time</TT> queries.<BR> This module answers UTC time on <TT>jabber:iq:time</TT> queries.<BR>
@ -1111,7 +1135,7 @@ discipline (see&nbsp;<A HREF="#sec:modiqdiscoption">A.1.1</A>).
</DL> </DL>
<!--TOC subsection <TT>mod_vcard</TT>--> <!--TOC subsection <TT>mod_vcard</TT>-->
<H3><A NAME="htoc47">A.17</A>&nbsp;&nbsp;<TT>mod_vcard</TT></H3><!--SEC END --> <H3><A NAME="htoc48">A.18</A>&nbsp;&nbsp;<TT>mod_vcard</TT></H3><!--SEC END -->
<A NAME="sec:modvcard"></A> <A NAME="sec:modvcard"></A>
This module implements simple Jabber User Directory (based on user vCards) This module implements simple Jabber User Directory (based on user vCards)
@ -1139,7 +1163,7 @@ Example:
</PRE> </PRE>
<!--TOC subsection <TT>mod_version</TT>--> <!--TOC subsection <TT>mod_version</TT>-->
<H3><A NAME="htoc48">A.18</A>&nbsp;&nbsp;<TT>mod_version</TT></H3><!--SEC END --> <H3><A NAME="htoc49">A.19</A>&nbsp;&nbsp;<TT>mod_version</TT></H3><!--SEC END -->
<A NAME="sec:modversion"></A> <A NAME="sec:modversion"></A>
This module answers <TT>ejabberd</TT> version on <TT>jabber:iq:version</TT> queries.<BR> This module answers <TT>ejabberd</TT> version on <TT>jabber:iq:version</TT> queries.<BR>
@ -1151,7 +1175,7 @@ discipline (see&nbsp;<A HREF="#sec:modiqdiscoption">A.1.1</A>).
</DL> </DL>
<!--TOC section I18n/L10n--> <!--TOC section I18n/L10n-->
<H2><A NAME="htoc49">B</A>&nbsp;&nbsp;I18n/L10n</H2><!--SEC END --> <H2><A NAME="htoc50">B</A>&nbsp;&nbsp;I18n/L10n</H2><!--SEC END -->
<A NAME="sec:i18nl10n"></A> <A NAME="sec:i18nl10n"></A>
All built-in modules support <TT>xml:lang</TT> attribute inside IQ queries. All built-in modules support <TT>xml:lang</TT> attribute inside IQ queries.

View File

@ -47,6 +47,7 @@
\newcommand{\modpubsub}{\module{mod\_pubsub}} \newcommand{\modpubsub}{\module{mod\_pubsub}}
\newcommand{\modregister}{\module{mod\_register}} \newcommand{\modregister}{\module{mod\_register}}
\newcommand{\modroster}{\module{mod\_roster}} \newcommand{\modroster}{\module{mod\_roster}}
\newcommand{\modservicelog}{\module{mod\_service\_log}}
\newcommand{\modstats}{\module{mod\_stats}} \newcommand{\modstats}{\module{mod\_stats}}
\newcommand{\modtime}{\module{mod\_time}} \newcommand{\modtime}{\module{mod\_time}}
\newcommand{\modvcard}{\module{mod\_vcard}} \newcommand{\modvcard}{\module{mod\_vcard}}
@ -1068,6 +1069,30 @@ Options:
\end{description} \end{description}
\subsection{\modservicelog{}}
\label{sec:modservicelog}
This module adds support for logging of user packets via any jabber service.
These packets encapsulated in <route/> element and sended to specified
services.
Options:
\begin{description}
\titem{loggers} Specifies a list of services which will receive users
packets.
\end{description}
Example:
\begin{verbatim}
{modules,
[
...
{mod_service_log, [{loggers, ["bandersnatch.example.com"]}]},
...
]}.
\end{verbatim}
\subsection{\modstats{}} \subsection{\modstats{}}
\label{sec:modstats} \label{sec:modstats}

59
src/mod_service_log.erl Normal file
View File

@ -0,0 +1,59 @@
%%%----------------------------------------------------------------------
%%% File : mod_service_log.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose : Manage announce messages
%%% Created : 24 Aug 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(mod_service_log).
-author('alexey@sevcom.net').
-behaviour(gen_mod).
-export([start/1,
stop/0,
log_user_send/3,
log_user_receive/4]).
-include("ejabberd.hrl").
-include("jlib.hrl").
start(_) ->
ejabberd_hooks:add(user_send_packet,
?MODULE, log_user_send, 50),
ejabberd_hooks:add(user_receive_packet,
?MODULE, log_user_receive, 50),
ok.
stop() ->
ejabberd_hooks:delete(user_send_packet,
?MODULE, log_user_send, 50),
ejabberd_hooks:delete(user_receive_packet,
?MODULE, log_user_receive, 50),
ok.
log_user_send(From, To, Packet) ->
log_packet(From, To, Packet).
log_user_receive(_JID, From, To, Packet) ->
log_packet(From, To, Packet).
log_packet(From, To, {xmlelement, Name, Attrs, Els}) ->
Loggers = gen_mod:get_module_opt(?MODULE, loggers, []),
ServerJID = #jid{user = "", server = ?MYNAME, resource = "",
luser = "", lserver = ?MYNAME, lresource = ""},
NewAttrs = jlib:replace_from_to_attrs(jlib:jid_to_string(From),
jlib:jid_to_string(To),
Attrs),
FixedPacket = {xmlelement, Name, NewAttrs, Els},
lists:foreach(
fun(Logger) ->
ejabberd_router:route(
ServerJID,
#jid{user = "", server = Logger, resource = "",
luser = "", lserver = Logger, lresource = ""},
{xmlelement, "route", [], [FixedPacket]})
end, Loggers).