mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
*** empty log message ***
SVN Revision: 49
This commit is contained in:
parent
66792183d0
commit
2aa3c1c720
@ -18,7 +18,10 @@
|
||||
<H3 ALIGN=center>Alexey Shchepin<BR><A HREF="mailto:alexey@sevcom.net"><TT>mailto:alexey@sevcom.net</TT></A><BR><A HREF="xmpp:aleksey@jabber.ru"><TT>xmpp:aleksey@jabber.ru</TT></A></H3>
|
||||
|
||||
<H3 ALIGN=center>January 23, 2003</H3> <DIV ALIGN=center><IMG SRC="logo.png">
|
||||
</DIV>
|
||||
|
||||
</DIV><BR>
|
||||
<BR>
|
||||
|
||||
|
||||
<BR>
|
||||
<BR>
|
||||
@ -90,9 +93,7 @@ values.<BR>
|
||||
serves. E. g. to use <TT>jabber.org</TT> domain add following line in config:
|
||||
<PRE>
|
||||
{host, "jabber.org"}.
|
||||
</PRE>This option is mandatory.<BR>
|
||||
<BR>
|
||||
<!--TOC subsubsection Listened Sockets-->
|
||||
</PRE><!--TOC subsubsection Listened Sockets-->
|
||||
|
||||
<H4>3.1.2 Listened Sockets</H4><!--SEC END -->
|
||||
|
||||
@ -143,28 +144,30 @@ section <A HREF="#sec:modules">5</A> for detailed information on each modul
|
||||
Example:
|
||||
<PRE>
|
||||
{modules, [
|
||||
{mod_register, [one_queue]},
|
||||
{mod_roster, [one_queue]},
|
||||
{mod_configure, [one_queue]},
|
||||
{mod_disco, [one_queue]},
|
||||
{mod_stats, [one_queue]},
|
||||
{mod_vcard, [one_queue]},
|
||||
{mod_register, []},
|
||||
{mod_roster, []},
|
||||
{mod_configure, []},
|
||||
{mod_disco, []},
|
||||
{mod_stats, []},
|
||||
{mod_vcard, []},
|
||||
{mod_offline, []},
|
||||
{mod_echo, []},
|
||||
{mod_private, [one_queue]},
|
||||
{mod_time, [one_queue]},
|
||||
{mod_version, [one_queue]}
|
||||
{mod_echo, [{host, "echo.e.localhost"}]},
|
||||
{mod_private, []},
|
||||
{mod_time, [{pdisc, no_queue}]},
|
||||
{mod_version, []}
|
||||
]}.
|
||||
</PRE><!--TOC subsection Online Configuration-->
|
||||
|
||||
<H3>3.2 Online Configuration</H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:onlineconfig"></A>To use facility of online reconfiguration of <TT>ejabberd</TT> needed to have
|
||||
<TT>mod_configure</TT> loaded (section <A HREF="#sec:modconfigure">5.3</A>). Also highly
|
||||
recommended to load <TT>mod_disco</TT> (section <A HREF="#sec:moddisco">5.4</A>), because
|
||||
<TT>mod_configure</TT> loaded (see section <A HREF="#sec:modconfigure">5.4</A>). Also highly
|
||||
recommended to load <TT>mod_disco</TT> (see section <A HREF="#sec:moddisco">5.5</A>), because
|
||||
<TT>mod_configure</TT> highly integrates with it. Also recommended to use
|
||||
disco-capable client.<BR>
|
||||
<BR>
|
||||
TBD<BR>
|
||||
<BR>
|
||||
<!--TOC section Distribution-->
|
||||
|
||||
<H2>4 Distribution</H2><!--SEC END -->
|
||||
@ -173,49 +176,85 @@ disco-capable client.<BR>
|
||||
|
||||
<H2>5 Built-in Modules</H2><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modules"></A><!--TOC subsection <TT>mod_register</TT>-->
|
||||
<A NAME="sec:modules"></A><!--TOC subsection Common Options-->
|
||||
|
||||
<H3>5.1 <TT>mod_register</TT></H3><!--SEC END -->
|
||||
<H3>5.1 Common Options</H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modcommonopts"></A>Following options used by many modules, so they described in separate section.<BR>
|
||||
<BR>
|
||||
<!--TOC subsubsection Option <TT>iqdisc</TT>-->
|
||||
|
||||
<H4>5.1.1 Option <TT>iqdisc</TT></H4><!--SEC END -->
|
||||
Many modules define handlers for processing IQ queries of different namespaces
|
||||
to this server or to user (e. g. to <TT>myjabber.org</TT> or to
|
||||
<TT>user@myjabber.org</TT>). This option defines processing discipline of this
|
||||
queries. Possible values are:
|
||||
<DL COMPACT=compact>
|
||||
<DT>
|
||||
<TT>no_queue</TT><DD> All queries of namespace with this processing
|
||||
discipline processed immediately. This also means that no other packets can
|
||||
be processed until finished this. Hence this discipline is not recommended
|
||||
if processing of query can take relative many time.
|
||||
|
||||
<DT><TT>one_queue</TT><DD> In this case created separate queue for processing
|
||||
IQ queries of namespace with this discipline, and processing of this queue
|
||||
done in parallel with processing of other packets. This discipline is most
|
||||
recommended.
|
||||
|
||||
<DT><TT>parallel</TT><DD> In this case for all packets of namespace with this
|
||||
discipline spawned separate Erlang process, so all this packets processed in
|
||||
parallel. Although spawning of Erlang process have relative low cost, this
|
||||
can broke server normal work, because Erlang have limit of 32000 processes.
|
||||
</DL>Example:
|
||||
<PRE>
|
||||
{modules, [
|
||||
...
|
||||
{mod_time, [{pdisc, no_queue}]},
|
||||
...
|
||||
]}.
|
||||
</PRE><!--TOC subsection <TT>mod_register</TT>-->
|
||||
|
||||
<H3>5.2 <TT>mod_register</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modregister"></A><!--TOC subsection <TT>mod_roster</TT>-->
|
||||
|
||||
<H3>5.2 <TT>mod_roster</TT></H3><!--SEC END -->
|
||||
<H3>5.3 <TT>mod_roster</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modroster"></A><!--TOC subsection <TT>mod_configure</TT>-->
|
||||
|
||||
<H3>5.3 <TT>mod_configure</TT></H3><!--SEC END -->
|
||||
<H3>5.4 <TT>mod_configure</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modconfigure"></A><!--TOC subsection <TT>mod_disco</TT>-->
|
||||
|
||||
<H3>5.4 <TT>mod_disco</TT></H3><!--SEC END -->
|
||||
<H3>5.5 <TT>mod_disco</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:moddisco"></A><!--TOC subsection <TT>mod_stats</TT>-->
|
||||
|
||||
<H3>5.5 <TT>mod_stats</TT></H3><!--SEC END -->
|
||||
<H3>5.6 <TT>mod_stats</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modstats"></A><!--TOC subsection <TT>mod_vcard</TT>-->
|
||||
|
||||
<H3>5.6 <TT>mod_vcard</TT></H3><!--SEC END -->
|
||||
<H3>5.7 <TT>mod_vcard</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modvcard"></A><!--TOC subsection <TT>mod_offline</TT>-->
|
||||
|
||||
<H3>5.7 <TT>mod_offline</TT></H3><!--SEC END -->
|
||||
<H3>5.8 <TT>mod_offline</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modoffline"></A><!--TOC subsection <TT>mod_echo</TT>-->
|
||||
|
||||
<H3>5.8 <TT>mod_echo</TT></H3><!--SEC END -->
|
||||
<H3>5.9 <TT>mod_echo</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modecho"></A><!--TOC subsection <TT>mod_private</TT>-->
|
||||
|
||||
<H3>5.9 <TT>mod_private</TT></H3><!--SEC END -->
|
||||
<H3>5.10 <TT>mod_private</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modprivate"></A><!--TOC subsection <TT>mod_time</TT>-->
|
||||
|
||||
<H3>5.10 <TT>mod_time</TT></H3><!--SEC END -->
|
||||
<H3>5.11 <TT>mod_time</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modtime"></A><!--TOC subsection <TT>mod_version</TT>-->
|
||||
|
||||
<H3>5.11 <TT>mod_version</TT></H3><!--SEC END -->
|
||||
<H3>5.12 <TT>mod_version</TT></H3><!--SEC END -->
|
||||
|
||||
<A NAME="sec:modversion"></A><!--HTMLFOOT-->
|
||||
<!--ENDHTML-->
|
||||
|
@ -1,10 +1,13 @@
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
%\usepackage{graphics}
|
||||
\usepackage{graphics}
|
||||
\usepackage{hevea}
|
||||
\usepackage{verbatim}
|
||||
|
||||
|
||||
\newcommand{\imgscale}{0.7}
|
||||
|
||||
|
||||
\newcommand{\ejabberd}{\texttt{ejabberd}}
|
||||
\newcommand{\Jabber}{Jabber}
|
||||
|
||||
@ -32,11 +35,12 @@
|
||||
\begin{titlepage}
|
||||
\maketitle{}
|
||||
|
||||
|
||||
|
||||
%\includegraphics{logo.png}
|
||||
{\centering
|
||||
\imgsrc{logo.png}{}
|
||||
\begin{latexonly}
|
||||
\scalebox{\imgscale}{\includegraphics{logo.png}}
|
||||
\end{latexonly}
|
||||
\par
|
||||
}
|
||||
\end{titlepage}
|
||||
%\newpage
|
||||
@ -119,7 +123,7 @@ serves. E.\,g. to use \texttt{jabber.org} domain add following line in config:
|
||||
{host, "jabber.org"}.
|
||||
\end{verbatim}
|
||||
|
||||
This option is mandatory.
|
||||
%This option is mandatory.
|
||||
|
||||
|
||||
|
||||
@ -172,17 +176,17 @@ section~\ref{sec:modules} for detailed information on each module.
|
||||
Example:
|
||||
\begin{verbatim}
|
||||
{modules, [
|
||||
{mod_register, [one_queue]},
|
||||
{mod_roster, [one_queue]},
|
||||
{mod_configure, [one_queue]},
|
||||
{mod_disco, [one_queue]},
|
||||
{mod_stats, [one_queue]},
|
||||
{mod_vcard, [one_queue]},
|
||||
{mod_register, []},
|
||||
{mod_roster, []},
|
||||
{mod_configure, []},
|
||||
{mod_disco, []},
|
||||
{mod_stats, []},
|
||||
{mod_vcard, []},
|
||||
{mod_offline, []},
|
||||
{mod_echo, []},
|
||||
{mod_private, [one_queue]},
|
||||
{mod_time, [one_queue]},
|
||||
{mod_version, [one_queue]}
|
||||
{mod_echo, [{host, "echo.e.localhost"}]},
|
||||
{mod_private, []},
|
||||
{mod_time, [{iqdisc, no_queue}]},
|
||||
{mod_version, []}
|
||||
]}.
|
||||
\end{verbatim}
|
||||
|
||||
@ -210,6 +214,41 @@ TBD
|
||||
|
||||
|
||||
|
||||
\subsection{Common Options}
|
||||
\label{sec:modcommonopts}
|
||||
|
||||
Following options used by many modules, so they described in separate section.
|
||||
|
||||
|
||||
\subsubsection{Option \texttt{iqdisc}}
|
||||
|
||||
Many modules define handlers for processing IQ queries of different namespaces
|
||||
to this server or to user (e.\,g. to \texttt{myjabber.org} or to
|
||||
\texttt{user@myjabber.org}). This option defines processing discipline of this
|
||||
queries. Possible values are:
|
||||
\begin{description}
|
||||
\item[\texttt{no\_queue}] All queries of namespace with this processing
|
||||
discipline processed immediately. This also means that no other packets can
|
||||
be processed until finished this. Hence this discipline is not recommended
|
||||
if processing of query can take relative many time.
|
||||
\item[\texttt{one\_queue}] In this case created separate queue for processing
|
||||
IQ queries of namespace with this discipline, and processing of this queue
|
||||
done in parallel with processing of other packets. This discipline is most
|
||||
recommended.
|
||||
\item[\texttt{parallel}] In this case for all packets of namespace with this
|
||||
discipline spawned separate Erlang process, so all this packets processed in
|
||||
parallel. Although spawning of Erlang process have relative low cost, this
|
||||
can broke server normal work, because Erlang have limit of 32000 processes.
|
||||
\end{description}
|
||||
|
||||
Example:
|
||||
\begin{verbatim}
|
||||
{modules, [
|
||||
...
|
||||
{mod_time, [{iqdisc, no_queue}]},
|
||||
...
|
||||
]}.
|
||||
\end{verbatim}
|
||||
|
||||
\subsection{\modregister{}}
|
||||
\label{sec:modregister}
|
||||
|
@ -8,7 +8,8 @@ LIBDIRS = -L/usr/lib/erlang/lib/erl_interface-3.3.0/lib
|
||||
ERLSHLIBS = expat_erl.so
|
||||
|
||||
all: $(ERLSHLIBS)
|
||||
erl -make
|
||||
erl -s make all report -noinput -s erlang halt
|
||||
etags *.erl
|
||||
|
||||
$(ERLSHLIBS): %.so: %.c
|
||||
gcc -Wall $(INCLUDES) $(LIBDIRS) \
|
||||
@ -18,3 +19,6 @@ $(ERLSHLIBS): %.so: %.c
|
||||
-lei \
|
||||
-o $@ -fpic -shared \
|
||||
|
||||
clean:
|
||||
rm -f *.beam
|
||||
|
||||
|
@ -22,17 +22,17 @@
|
||||
]}.
|
||||
|
||||
{modules, [
|
||||
{mod_register, [one_queue]},
|
||||
{mod_roster, [one_queue]},
|
||||
{mod_configure, [one_queue]},
|
||||
{mod_disco, [one_queue]},
|
||||
{mod_stats, [one_queue]},
|
||||
{mod_vcard, [one_queue]},
|
||||
{mod_register, []},
|
||||
{mod_roster, []},
|
||||
{mod_configure, []},
|
||||
{mod_disco, []},
|
||||
{mod_stats, []},
|
||||
{mod_vcard, []},
|
||||
{mod_offline, []},
|
||||
{mod_echo, []},
|
||||
{mod_private, [one_queue]},
|
||||
{mod_time, [one_queue]},
|
||||
{mod_version, [one_queue]}
|
||||
{mod_echo, [{host, "echo.e.localhost"}]},
|
||||
{mod_private, []},
|
||||
{mod_time, [{iqdisc, no_queue}]},
|
||||
{mod_version, []}
|
||||
]}.
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ load_modules() ->
|
||||
ok;
|
||||
Modules ->
|
||||
lists:foreach(fun({Module, Args}) ->
|
||||
apply(Module, start, Args)
|
||||
gen_mod:start_module(Module, Args)
|
||||
end, Modules)
|
||||
end.
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
-endif.
|
||||
|
||||
-define(ERROR_MSG(Format, Args),
|
||||
error_logger:format("D(~p:~p:~p) : "++Format++"~n",
|
||||
error_logger:format("E(~p:~p:~p): "++Format++"~n",
|
||||
[self(),?MODULE,?LINE]++Args)).
|
||||
|
||||
|
||||
|
@ -26,7 +26,12 @@
|
||||
is_user_exists/1]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]).
|
||||
-export([init/1,
|
||||
handle_call/3,
|
||||
handle_cast/2,
|
||||
code_change/3,
|
||||
handle_info/2,
|
||||
terminate/2]).
|
||||
|
||||
-record(state, {}).
|
||||
|
||||
@ -78,6 +83,10 @@ handle_call(Request, From, State) ->
|
||||
handle_cast(Msg, State) ->
|
||||
{noreply, State}.
|
||||
|
||||
|
||||
code_change(OldVsn, State, Extra) ->
|
||||
{ok, State}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_info/2
|
||||
%% Returns: {noreply, State} |
|
||||
|
@ -20,6 +20,9 @@
|
||||
% handle_sync_event/4, handle_info/3, terminate/3]).
|
||||
%
|
||||
-export([init/1, wait_for_stream/2, wait_for_auth/2, session_established/2,
|
||||
handle_event/3,
|
||||
handle_sync_event/4,
|
||||
code_change/4,
|
||||
handle_info/3,
|
||||
terminate/3]).
|
||||
|
||||
@ -88,8 +91,6 @@ init([Socket]) ->
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
state_name(Event, StateData) ->
|
||||
{next_state, state_name, StateData}.
|
||||
|
||||
wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
|
||||
% TODO
|
||||
@ -212,9 +213,9 @@ session_established(closed, StateData) ->
|
||||
%% {stop, Reason, NewStateData} |
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
state_name(Event, From, StateData) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, state_name, StateData}.
|
||||
%state_name(Event, From, StateData) ->
|
||||
% Reply = ok,
|
||||
% {reply, Reply, state_name, StateData}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_event/3
|
||||
@ -238,6 +239,9 @@ handle_sync_event(Event, From, StateName, StateData) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, StateName, StateData}.
|
||||
|
||||
code_change(OldVsn, StateName, StateData, Extra) ->
|
||||
{ok, StateName, StateData}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_info/3
|
||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
||||
|
@ -38,6 +38,7 @@ load_file(File) ->
|
||||
{ok, Terms} ->
|
||||
lists:foreach(fun process_term/1, Terms);
|
||||
{error, Reason} ->
|
||||
?ERROR_MSG("~p", [Reason]),
|
||||
exit(file:format_error(Reason))
|
||||
end.
|
||||
|
||||
|
@ -21,6 +21,9 @@
|
||||
wait_for_key/2,
|
||||
wait_for_verification/2,
|
||||
stream_established/2,
|
||||
handle_event/3,
|
||||
handle_sync_event/4,
|
||||
code_change/4,
|
||||
handle_info/3,
|
||||
terminate/3]).
|
||||
|
||||
@ -89,8 +92,6 @@ init([Socket]) ->
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
state_name(Event, StateData) ->
|
||||
{next_state, state_name, StateData}.
|
||||
|
||||
wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
|
||||
% TODO
|
||||
@ -270,9 +271,9 @@ stream_established(closed, StateData) ->
|
||||
%% {stop, Reason, NewStateData} |
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
state_name(Event, From, StateData) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, state_name, StateData}.
|
||||
%state_name(Event, From, StateData) ->
|
||||
% Reply = ok,
|
||||
% {reply, Reply, state_name, StateData}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_event/3
|
||||
@ -296,6 +297,9 @@ handle_sync_event(Event, From, StateName, StateData) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, StateName, StateData}.
|
||||
|
||||
code_change(OldVsn, StateName, StateData, Extra) ->
|
||||
{ok, StateName, StateData}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_info/3
|
||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
||||
|
@ -21,8 +21,11 @@
|
||||
wait_for_stream/2,
|
||||
wait_for_validation/2,
|
||||
stream_established/2,
|
||||
handle_event/3,
|
||||
handle_sync_event/4,
|
||||
handle_info/3,
|
||||
terminate/3]).
|
||||
terminate/3,
|
||||
code_change/4]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
@ -268,9 +271,9 @@ stream_established(closed, StateData) ->
|
||||
%% {stop, Reason, NewStateData} |
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
state_name(Event, From, StateData) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, state_name, StateData}.
|
||||
%state_name(Event, From, StateData) ->
|
||||
% Reply = ok,
|
||||
% {reply, Reply, state_name, StateData}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_event/3
|
||||
@ -294,6 +297,9 @@ handle_sync_event(Event, From, StateName, StateData) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, StateName, StateData}.
|
||||
|
||||
code_change(OldVsn, StateName, StateData, Extra) ->
|
||||
{ok, StateName, StateData}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_info/3
|
||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
||||
@ -400,20 +406,20 @@ bounce_messages(Reason) ->
|
||||
ok
|
||||
end.
|
||||
|
||||
is_key_packet({xmlelement, Name, Attrs, Els}) when Name == "db:result" ->
|
||||
{key,
|
||||
xml:get_attr_s("to", Attrs),
|
||||
xml:get_attr_s("from", Attrs),
|
||||
xml:get_attr_s("id", Attrs),
|
||||
xml:get_cdata(Els)};
|
||||
is_key_packet({xmlelement, Name, Attrs, Els}) when Name == "db:verify" ->
|
||||
{verify,
|
||||
xml:get_attr_s("to", Attrs),
|
||||
xml:get_attr_s("from", Attrs),
|
||||
xml:get_attr_s("id", Attrs),
|
||||
xml:get_cdata(Els)};
|
||||
is_key_packet(_) ->
|
||||
false.
|
||||
%is_key_packet({xmlelement, Name, Attrs, Els}) when Name == "db:result" ->
|
||||
% {key,
|
||||
% xml:get_attr_s("to", Attrs),
|
||||
% xml:get_attr_s("from", Attrs),
|
||||
% xml:get_attr_s("id", Attrs),
|
||||
% xml:get_cdata(Els)};
|
||||
%is_key_packet({xmlelement, Name, Attrs, Els}) when Name == "db:verify" ->
|
||||
% {verify,
|
||||
% xml:get_attr_s("to", Attrs),
|
||||
% xml:get_attr_s("from", Attrs),
|
||||
% xml:get_attr_s("id", Attrs),
|
||||
% xml:get_cdata(Els)};
|
||||
%is_key_packet(_) ->
|
||||
% false.
|
||||
|
||||
is_verify_res({xmlelement, Name, Attrs, Els}) when Name == "db:result" ->
|
||||
{result,
|
||||
|
58
src/gen_mod.erl
Normal file
58
src/gen_mod.erl
Normal file
@ -0,0 +1,58 @@
|
||||
%%%----------------------------------------------------------------------
|
||||
%%% File : gen_mod.erl
|
||||
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Purpose :
|
||||
%%% Created : 24 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Id : $Id$
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-module(gen_mod).
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-export([start_module/2,
|
||||
stop_module/1,
|
||||
get_opt/2,
|
||||
get_opt/3]).
|
||||
|
||||
-export([behaviour_info/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
|
||||
behaviour_info(callbacks) ->
|
||||
[{start, 1},
|
||||
{stop, 0}];
|
||||
behaviour_info(Other) ->
|
||||
undefined.
|
||||
|
||||
|
||||
start_module(Module, Opts) ->
|
||||
case catch Module:start(Opts) of
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("~p", [Reason]);
|
||||
_ ->
|
||||
ok
|
||||
end.
|
||||
|
||||
stop_module(Module) ->
|
||||
Module:stop().
|
||||
|
||||
|
||||
get_opt(Opt, Opts) ->
|
||||
case lists:keysearch(Opt, 1, Opts) of
|
||||
false ->
|
||||
% TODO: replace with more appropriate function
|
||||
[] = {undefined_option, Opt};
|
||||
{value, {_, Val}} ->
|
||||
Val
|
||||
end.
|
||||
|
||||
get_opt(Opt, Opts, Default) ->
|
||||
case lists:keysearch(Opt, 1, Opts) of
|
||||
false ->
|
||||
Default;
|
||||
{value, {_, Val}} ->
|
||||
Val
|
||||
end.
|
||||
|
36
src/jlib.erl
36
src/jlib.erl
@ -19,6 +19,7 @@
|
||||
remove_attr/2,
|
||||
string_to_jid/1,
|
||||
jid_to_string/1,
|
||||
is_nodename/1,
|
||||
tolower/1,
|
||||
jid_tolower/1,
|
||||
jid_remove_resource/1,
|
||||
@ -133,6 +134,17 @@ string_to_jid1([$/ | J], "") ->
|
||||
error;
|
||||
string_to_jid1([$/ | J], N) ->
|
||||
string_to_jid3(J, "", lists:reverse(N), "");
|
||||
string_to_jid1([C | J], N)
|
||||
when (C =< 32) or
|
||||
(C == $") or
|
||||
(C == $&) or
|
||||
(C == $') or
|
||||
(C == $:) or
|
||||
(C == $<) or
|
||||
(C == $>) or
|
||||
(C == 127)
|
||||
->
|
||||
error;
|
||||
string_to_jid1([C | J], N) ->
|
||||
string_to_jid1(J, [C | N]);
|
||||
string_to_jid1([], "") ->
|
||||
@ -173,6 +185,30 @@ jid_to_string({Node, Server, Resource}) ->
|
||||
S3.
|
||||
|
||||
|
||||
is_nodename([]) ->
|
||||
false;
|
||||
is_nodename(J) ->
|
||||
is_nodename1(J).
|
||||
|
||||
is_nodename1([C | J])
|
||||
when (C =< 32) or
|
||||
(C == $") or
|
||||
(C == $&) or
|
||||
(C == $') or
|
||||
(C == $:) or
|
||||
(C == $<) or
|
||||
(C == $>) or
|
||||
(C == $@) or
|
||||
(C == $/) or
|
||||
(C == 127)
|
||||
->
|
||||
false;
|
||||
is_nodename1([C | J]) ->
|
||||
is_nodename1(J);
|
||||
is_nodename1([]) ->
|
||||
true.
|
||||
|
||||
|
||||
|
||||
% TODO: UNICODE support
|
||||
tolower_c(C) when C >= $A, C =< $Z ->
|
||||
|
@ -10,6 +10,8 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
process_local_iq/3,
|
||||
process_sm_iq/3]).
|
||||
@ -18,11 +20,12 @@
|
||||
-include("namespaces.hrl").
|
||||
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_XDATA,
|
||||
?MODULE, process_local_iq, Type),
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_XDATA,
|
||||
?MODULE, process_sm_iq, Type),
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
ok.
|
||||
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
process_local_iq_items/3,
|
||||
process_local_iq_info/3,
|
||||
@ -24,23 +26,16 @@
|
||||
{iq, ID, result, XMLNS, [{xmlelement, "query",
|
||||
[{"xmlns", ?NS_DISCO_INFO}], []}]}).
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_DISCO_ITEMS,
|
||||
?MODULE, process_local_iq_items, Type),
|
||||
?MODULE, process_local_iq_items, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_DISCO_INFO,
|
||||
?MODULE, process_local_iq_info, Type),
|
||||
?MODULE, process_local_iq_info, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_DISCO_ITEMS,
|
||||
?MODULE, process_sm_iq_items, Type),
|
||||
?MODULE, process_sm_iq_items, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_DISCO_INFO,
|
||||
?MODULE, process_sm_iq_info, Type),
|
||||
%ejabberd_local:register_iq_handler(?NS_DISCO_ITEMS,
|
||||
% ?MODULE, process_local_iq_items),
|
||||
%ejabberd_local:register_iq_handler(?NS_DISCO_INFO,
|
||||
% ?MODULE, process_local_iq_info),
|
||||
%ejabberd_sm:register_iq_handler(?NS_DISCO_ITEMS,
|
||||
% ?MODULE, process_sm_iq_items),
|
||||
%ejabberd_sm:register_iq_handler(?NS_DISCO_INFO,
|
||||
% ?MODULE, process_sm_iq_info),
|
||||
?MODULE, process_sm_iq_info, IQDisc),
|
||||
register_feature("iq"),
|
||||
register_feature("presence"),
|
||||
register_feature("presence-invisible"),
|
||||
|
@ -10,18 +10,22 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-export([start/0, init/0]).
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1, init/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("namespaces.hrl").
|
||||
|
||||
|
||||
|
||||
start() ->
|
||||
spawn(?MODULE, init, []).
|
||||
start(Opts) ->
|
||||
%Host = gen_mod:get_opt(host, Opts),
|
||||
Host = gen_mod:get_opt(host, Opts, "echo." ++ ?MYNAME),
|
||||
spawn(?MODULE, init, [Host]).
|
||||
|
||||
init() ->
|
||||
ejabberd_router:register_local_route("echo." ++ ?MYNAME),
|
||||
init(Host) ->
|
||||
ejabberd_router:register_local_route(Host),
|
||||
loop().
|
||||
|
||||
loop() ->
|
||||
|
@ -9,7 +9,9 @@
|
||||
-module(mod_offline).
|
||||
-author('alexey@sevcom.net').
|
||||
|
||||
-export([start/0,
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
store_packet/3,
|
||||
resend_offline_messages/1]).
|
||||
|
||||
@ -18,7 +20,7 @@
|
||||
-record(offline_msg, {user, timestamp, from, to, packet}).
|
||||
|
||||
|
||||
start() ->
|
||||
start(_) ->
|
||||
mnesia:create_table(offline_msg,
|
||||
[{disc_only_copies, [node()]},
|
||||
{type, bag},
|
||||
|
@ -10,6 +10,8 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
process_local_iq/3]).
|
||||
|
||||
@ -18,12 +20,13 @@
|
||||
|
||||
-record(private_storage, {userns, xml}).
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
mnesia:create_table(private_storage,
|
||||
[{disc_only_copies, [node()]},
|
||||
{attributes, record_info(fields, private_storage)}]),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_PRIVATE,
|
||||
?MODULE, process_local_iq, Type).
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
|
||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||
|
@ -10,14 +10,17 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1, init/0, process_iq/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("namespaces.hrl").
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_REGISTER,
|
||||
?MODULE, process_iq, Type),
|
||||
?MODULE, process_iq, IQDisc),
|
||||
ok.
|
||||
|
||||
init() ->
|
||||
@ -71,8 +74,8 @@ process_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||
|
||||
|
||||
try_register(User, Password) ->
|
||||
case jlib:string_to_jid(User ++ "@" ++ "x") of
|
||||
error ->
|
||||
case jlib:is_nodename(User) of
|
||||
false ->
|
||||
{error, "406", "Not Acceptable"};
|
||||
_ ->
|
||||
case ejabberd_auth:try_register(User, Password) of
|
||||
|
@ -10,7 +10,7 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-export([]).
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
process_iq/3,
|
||||
@ -33,12 +33,13 @@
|
||||
xattrs = [],
|
||||
xs = []}).
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
mnesia:create_table(roster,[{disc_copies, [node()]},
|
||||
{attributes, record_info(fields, roster)}]),
|
||||
mnesia:add_table_index(roster, user),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_ROSTER,
|
||||
?MODULE, process_local_iq, Type).
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
process_local_iq(From, To, {iq, _, Type, _, _} = IQ) ->
|
||||
case Type of
|
||||
|
@ -10,14 +10,17 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
process_local_iq/3]).
|
||||
|
||||
-include("namespaces.hrl").
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_STATS,
|
||||
?MODULE, process_local_iq, Type).
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
|
||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||
|
@ -10,6 +10,8 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
process_local_iq/3]).
|
||||
|
||||
@ -17,9 +19,10 @@
|
||||
-include("namespaces.hrl").
|
||||
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_TIME,
|
||||
?MODULE, process_local_iq, Type).
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
|
||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||
|
@ -10,7 +10,9 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-export([start/1, init/0,
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1, init/1,
|
||||
process_local_iq/3,
|
||||
process_sm_iq/3,
|
||||
reindex_vcards/0]).
|
||||
@ -35,7 +37,7 @@
|
||||
-record(vcard, {user, vcard}).
|
||||
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
mnesia:create_table(vcard, [{disc_only_copies, [node()]},
|
||||
{attributes, record_info(fields, vcard)}]),
|
||||
mnesia:create_table(vcard_search,
|
||||
@ -53,15 +55,17 @@ start(Type) ->
|
||||
mnesia:add_table_index(vcard_search, lorgname),
|
||||
mnesia:add_table_index(vcard_search, lorgunit),
|
||||
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_VCARD,
|
||||
?MODULE, process_local_iq, Type),
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_VCARD,
|
||||
?MODULE, process_sm_iq, Type),
|
||||
spawn(?MODULE, init, []).
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
Host = gen_mod:get_opt(host, Opts, "vjud." ++ ?MYNAME),
|
||||
spawn(?MODULE, init, [Host]).
|
||||
|
||||
|
||||
init() ->
|
||||
ejabberd_router:register_local_route("vjud." ++ ?MYNAME),
|
||||
init(Host) ->
|
||||
ejabberd_router:register_local_route(Host),
|
||||
loop().
|
||||
|
||||
loop() ->
|
||||
|
@ -10,6 +10,8 @@
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/1,
|
||||
process_local_iq/3]).
|
||||
|
||||
@ -18,9 +20,10 @@
|
||||
|
||||
|
||||
|
||||
start(Type) ->
|
||||
start(Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_VERSION,
|
||||
?MODULE, process_local_iq, Type).
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user