mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
* src/aclocal.m4: Fixed headers detecting in AM_WITH_OPENSSL
(thanks to Leif Johansson) * src/ejabberd_auth.erl: Added support for ldap_rootdn and ldap_password options (thanks to Stefan de Konink) * src/mod_vcard_ldap.erl: Likewise * src/ejabberd_router.erl: Now possible to route packet via function call instead of message sending * src/ejabberd_sm.erl: Added function route/3, use it in route table * src/ejabberd_local.erl: Likewise * src/ejabberd_s2s.erl: Likewise * (all): Fixed spelling of word "authentication" * src/*/Makefile.in: Replaced erlc with @ERLC@ SVN Revision: 285
This commit is contained in:
parent
7d683b194f
commit
2f7f3d9b00
27
ChangeLog
27
ChangeLog
@ -1,5 +1,32 @@
|
|||||||
|
2004-11-05 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/aclocal.m4: Fixed headers detecting in AM_WITH_OPENSSL
|
||||||
|
(thanks to Leif Johansson)
|
||||||
|
|
||||||
|
* src/ejabberd_auth.erl: Added support for ldap_rootdn and
|
||||||
|
ldap_password options (thanks to Stefan de Konink)
|
||||||
|
* src/mod_vcard_ldap.erl: Likewise
|
||||||
|
|
||||||
|
* src/ejabberd_router.erl: Now possible to route packet via
|
||||||
|
function call instead of message sending
|
||||||
|
* src/ejabberd_sm.erl: Added function route/3, use it in route
|
||||||
|
table
|
||||||
|
* src/ejabberd_local.erl: Likewise
|
||||||
|
* src/ejabberd_s2s.erl: Likewise
|
||||||
|
|
||||||
|
2004-10-23 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* (all): Fixed spelling of word "authentication"
|
||||||
|
|
||||||
|
* src/*/Makefile.in: Replaced erlc with @ERLC@
|
||||||
|
|
||||||
2004-10-15 Alexey Shchepin <alexey@sevcom.net>
|
2004-10-15 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/ejabberd_s2s.erl: Added remove_connection/1
|
||||||
|
* src/ejabberd_s2s_out.erl: Use ejabberd_s2s:remove_connection/1
|
||||||
|
|
||||||
|
* src/ejabberd_s2s_in.erl: Minor cleanup
|
||||||
|
|
||||||
* examples/transport-configs/: Transport config examples (thanks
|
* examples/transport-configs/: Transport config examples (thanks
|
||||||
to Sander Devrieze)
|
to Sander Devrieze)
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ The main features of \ejabberd{} are:
|
|||||||
\item Built-in web-based administration interface
|
\item Built-in web-based administration interface
|
||||||
\item Built-in \tjepref{0025}{HTTP Polling} service
|
\item Built-in \tjepref{0025}{HTTP Polling} service
|
||||||
\item SSL support
|
\item SSL support
|
||||||
\item Support for LDAP authentification
|
\item Support for LDAP authentication
|
||||||
\item Ability to interface with external components (JIT, MSN-t, Yahoo-t, etc.)
|
\item Ability to interface with external components (JIT, MSN-t, Yahoo-t, etc.)
|
||||||
\item Migration from jabberd14 is possible
|
\item Migration from jabberd14 is possible
|
||||||
\item Mostly XMPP-compliant
|
\item Mostly XMPP-compliant
|
||||||
@ -128,7 +128,7 @@ The main features of \ejabberd{} are:
|
|||||||
The misfeatures of \ejabberd{} are:
|
The misfeatures of \ejabberd{} are:
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item No support for virtual domains
|
\item No support for virtual domains
|
||||||
\item No support for authentification and STARTTLS in S2S connections
|
\item No support for authentication and STARTTLS in S2S connections
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
|
|
||||||
@ -655,7 +655,7 @@ with such config:
|
|||||||
}.
|
}.
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
you should enter URL \verb|http://example.org:5280/admin/|. After
|
you should enter URL \verb|http://example.org:5280/admin/|. After
|
||||||
authentification you should see something like in figure~\ref{fig:webadmmain}.
|
authentication you should see something like in figure~\ref{fig:webadmmain}.
|
||||||
\begin{figure}[htbp]
|
\begin{figure}[htbp]
|
||||||
\centering
|
\centering
|
||||||
\insimg{webadmmain.png}
|
\insimg{webadmmain.png}
|
||||||
|
8
src/aclocal.m4
vendored
8
src/aclocal.m4
vendored
@ -205,12 +205,16 @@ if test x"$tls" != x; then
|
|||||||
SSL_LIBS="-L$ssl_prefix/lib -lcrypto"
|
SSL_LIBS="-L$ssl_prefix/lib -lcrypto"
|
||||||
AC_CHECK_LIB(ssl, SSL_new, [ have_openssl=yes ], [ have_openssl=no ], [ $SSL_LIBS $SSL_CFLAGS ])
|
AC_CHECK_LIB(ssl, SSL_new, [ have_openssl=yes ], [ have_openssl=no ], [ $SSL_LIBS $SSL_CFLAGS ])
|
||||||
if test x"$have_openssl" = xyes; then
|
if test x"$have_openssl" = xyes; then
|
||||||
AC_CHECK_HEADERS($ssl_prefix/include/openssl/ssl.h, have_openssl_h=yes)
|
save_CPPFLAGS=$CPPFLAGS
|
||||||
|
CPPFLAGS="-I$ssl_prefix/lib $CPPFLAGS"
|
||||||
|
AC_CHECK_HEADERS(openssl/ssl.h, have_openssl_h=yes)
|
||||||
|
CPPFLAGS=$save_CPPFLAGS
|
||||||
if test x"$have_openssl_h" = xyes; then
|
if test x"$have_openssl_h" = xyes; then
|
||||||
have_openssl=yes
|
have_openssl=yes
|
||||||
printf "openssl found in $ssl_prefix\n";
|
printf "openssl found in $ssl_prefix\n";
|
||||||
SSL_LIBS="-L$ssl_prefix/lib -lssl -lcrypto"
|
SSL_LIBS="-L$ssl_prefix/lib -lssl -lcrypto"
|
||||||
SSL_CFLAGS="-I$ssl_prefix/include/openssl -DHAVE_SSL"
|
CPPFLAGS="-I$ssl_prefix/lib $CPPFLAGS"
|
||||||
|
SSL_CFLAGS="-DHAVE_SSL"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -79,8 +79,10 @@ init([]) ->
|
|||||||
ok;
|
ok;
|
||||||
ldap ->
|
ldap ->
|
||||||
LDAPServers = ejabberd_config:get_local_option(ldap_servers),
|
LDAPServers = ejabberd_config:get_local_option(ldap_servers),
|
||||||
eldap:start_link("ejabberd", LDAPServers, 389, "", ""),
|
RootDN = ejabberd_config:get_local_option(ldap_rootdn),
|
||||||
eldap:start_link("ejabberd_bind", LDAPServers, 389, "", "")
|
Password = ejabberd_config:get_local_option(ldap_password),
|
||||||
|
eldap:start_link("ejabberd", LDAPServers, 389, RootDN, Password),
|
||||||
|
eldap:start_link("ejabberd_bind", LDAPServers, 389, RootDN, Password)
|
||||||
end,
|
end,
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
U, P, StateData#state.streamid, D) of
|
U, P, StateData#state.streamid, D) of
|
||||||
true ->
|
true ->
|
||||||
?INFO_MSG(
|
?INFO_MSG(
|
||||||
"(~w) Accepted legacy authentification for ~s",
|
"(~w) Accepted legacy authentication for ~s",
|
||||||
[StateData#state.socket,
|
[StateData#state.socket,
|
||||||
jlib:jid_to_string(JID)]),
|
jlib:jid_to_string(JID)]),
|
||||||
ejabberd_sm:open_session(U, R),
|
ejabberd_sm:open_session(U, R),
|
||||||
@ -319,7 +319,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
privacy_list = PrivList}};
|
privacy_list = PrivList}};
|
||||||
_ ->
|
_ ->
|
||||||
?INFO_MSG(
|
?INFO_MSG(
|
||||||
"(~w) Failed legacy authentification for ~s",
|
"(~w) Failed legacy authentication for ~s",
|
||||||
[StateData#state.socket,
|
[StateData#state.socket,
|
||||||
jlib:jid_to_string(JID)]),
|
jlib:jid_to_string(JID)]),
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(
|
||||||
@ -331,7 +331,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
if
|
if
|
||||||
JID == error ->
|
JID == error ->
|
||||||
?INFO_MSG(
|
?INFO_MSG(
|
||||||
"(~w) Forbidden legacy authentification for "
|
"(~w) Forbidden legacy authentication for "
|
||||||
"username '~s' with resource '~s'",
|
"username '~s' with resource '~s'",
|
||||||
[StateData#state.socket, U, R]),
|
[StateData#state.socket, U, R]),
|
||||||
Err = jlib:make_error_reply(El, ?ERR_JID_MALFORMED),
|
Err = jlib:make_error_reply(El, ?ERR_JID_MALFORMED),
|
||||||
@ -339,7 +339,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
{next_state, wait_for_auth, StateData};
|
{next_state, wait_for_auth, StateData};
|
||||||
true ->
|
true ->
|
||||||
?INFO_MSG(
|
?INFO_MSG(
|
||||||
"(~w) Forbidden legacy authentification for ~s",
|
"(~w) Forbidden legacy authentication for ~s",
|
||||||
[StateData#state.socket,
|
[StateData#state.socket,
|
||||||
jlib:jid_to_string(JID)]),
|
jlib:jid_to_string(JID)]),
|
||||||
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
|
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
|
||||||
@ -393,7 +393,7 @@ wait_for_feature_request({xmlstreamelement, El}, StateData) ->
|
|||||||
{xmlelement, "success",
|
{xmlelement, "success",
|
||||||
[{"xmlns", ?NS_SASL}], []}),
|
[{"xmlns", ?NS_SASL}], []}),
|
||||||
U = xml:get_attr_s(username, Props),
|
U = xml:get_attr_s(username, Props),
|
||||||
?INFO_MSG("(~w) Accepted authentification for ~s",
|
?INFO_MSG("(~w) Accepted authentication for ~s",
|
||||||
[StateData#state.socket, U]),
|
[StateData#state.socket, U]),
|
||||||
{next_state, wait_for_stream,
|
{next_state, wait_for_stream,
|
||||||
StateData#state{authentificated = true,
|
StateData#state{authentificated = true,
|
||||||
@ -469,7 +469,7 @@ wait_for_sasl_response({xmlstreamelement, El}, StateData) ->
|
|||||||
{xmlelement, "success",
|
{xmlelement, "success",
|
||||||
[{"xmlns", ?NS_SASL}], []}),
|
[{"xmlns", ?NS_SASL}], []}),
|
||||||
U = xml:get_attr_s(username, Props),
|
U = xml:get_attr_s(username, Props),
|
||||||
?INFO_MSG("(~w) Accepted authentification for ~s",
|
?INFO_MSG("(~w) Accepted authentication for ~s",
|
||||||
[StateData#state.socket, U]),
|
[StateData#state.socket, U]),
|
||||||
{next_state, wait_for_stream,
|
{next_state, wait_for_stream,
|
||||||
StateData#state{authentificated = true,
|
StateData#state{authentificated = true,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% File : ejabberd_local.erl
|
%%% File : ejabberd_local.erl
|
||||||
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
||||||
%%% Purpose :
|
%%% Purpose : Route local packets
|
||||||
%%% Created : 30 Nov 2002 by Alexey Shchepin <alexey@sevcom.net>
|
%%% Created : 30 Nov 2002 by Alexey Shchepin <alexey@sevcom.net>
|
||||||
%%% Id : $Id$
|
%%% Id : $Id$
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
-export([start_link/0, init/0]).
|
-export([start_link/0, init/0]).
|
||||||
|
|
||||||
-export([register_iq_handler/3,
|
-export([route/3,
|
||||||
|
register_iq_handler/3,
|
||||||
register_iq_handler/4,
|
register_iq_handler/4,
|
||||||
unregister_iq_handler/1,
|
unregister_iq_handler/1,
|
||||||
refresh_iq_handlers/0,
|
refresh_iq_handlers/0,
|
||||||
@ -22,7 +23,7 @@
|
|||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
|
|
||||||
-record(state, {mydomain, iqtable}).
|
-define(IQTABLE, local_iqtable).
|
||||||
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
register(ejabberd_local,
|
register(ejabberd_local,
|
||||||
@ -30,43 +31,41 @@ start_link() ->
|
|||||||
{ok, Pid}.
|
{ok, Pid}.
|
||||||
|
|
||||||
init() ->
|
init() ->
|
||||||
MyDomain = ?MYNAME,
|
ejabberd_router:register_route(?MYNAME, {apply, ?MODULE, route}),
|
||||||
ejabberd_router:register_route(MyDomain),
|
catch ets:new(?IQTABLE, [named_table, public]),
|
||||||
catch ets:new(local_iqtable, [named_table, public]),
|
|
||||||
ejabberd_hooks:add(local_send_to_resource_hook,
|
ejabberd_hooks:add(local_send_to_resource_hook,
|
||||||
?MODULE, bounce_resource_packet, 100),
|
?MODULE, bounce_resource_packet, 100),
|
||||||
loop(#state{mydomain = MyDomain,
|
loop().
|
||||||
iqtable = local_iqtable}).
|
|
||||||
|
|
||||||
loop(State) ->
|
loop() ->
|
||||||
receive
|
receive
|
||||||
{route, From, To, Packet} ->
|
{route, From, To, Packet} ->
|
||||||
case catch do_route(State, From, To, Packet) of
|
case catch do_route(From, To, Packet) of
|
||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
?ERROR_MSG("~p~nwhen processing: ~p",
|
?ERROR_MSG("~p~nwhen processing: ~p",
|
||||||
[Reason, {From, To, Packet}]);
|
[Reason, {From, To, Packet}]);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
loop(State);
|
loop();
|
||||||
{register_iq_handler, XMLNS, Module, Function} ->
|
{register_iq_handler, XMLNS, Module, Function} ->
|
||||||
ets:insert(State#state.iqtable, {XMLNS, Module, Function}),
|
ets:insert(?IQTABLE, {XMLNS, Module, Function}),
|
||||||
catch mod_disco:register_feature(XMLNS),
|
catch mod_disco:register_feature(XMLNS),
|
||||||
loop(State);
|
loop();
|
||||||
{register_iq_handler, XMLNS, Module, Function, Opts} ->
|
{register_iq_handler, XMLNS, Module, Function, Opts} ->
|
||||||
ets:insert(State#state.iqtable, {XMLNS, Module, Function, Opts}),
|
ets:insert(?IQTABLE, {XMLNS, Module, Function, Opts}),
|
||||||
catch mod_disco:register_feature(XMLNS),
|
catch mod_disco:register_feature(XMLNS),
|
||||||
loop(State);
|
loop();
|
||||||
{unregister_iq_handler, XMLNS} ->
|
{unregister_iq_handler, XMLNS} ->
|
||||||
case ets:lookup(State#state.iqtable, XMLNS) of
|
case ets:lookup(?IQTABLE, XMLNS) of
|
||||||
[{_, Module, Function, Opts}] ->
|
[{_, Module, Function, Opts}] ->
|
||||||
gen_iq_handler:stop_iq_handler(Module, Function, Opts);
|
gen_iq_handler:stop_iq_handler(Module, Function, Opts);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ets:delete(State#state.iqtable, XMLNS),
|
ets:delete(?IQTABLE, XMLNS),
|
||||||
catch mod_disco:unregister_feature(XMLNS),
|
catch mod_disco:unregister_feature(XMLNS),
|
||||||
loop(State);
|
loop();
|
||||||
refresh_iq_handlers ->
|
refresh_iq_handlers ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(T) ->
|
fun(T) ->
|
||||||
@ -78,22 +77,24 @@ loop(State) ->
|
|||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end
|
end
|
||||||
end, ets:tab2list(State#state.iqtable)),
|
end, ets:tab2list(?IQTABLE)),
|
||||||
loop(State);
|
loop();
|
||||||
_ ->
|
_ ->
|
||||||
loop(State)
|
loop()
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
do_route(State, From, To, Packet) ->
|
do_route(From, To, Packet) ->
|
||||||
?DEBUG("local route~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
?DEBUG("local route~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
||||||
[From, To, Packet, 8]),
|
[From, To, Packet, 8]),
|
||||||
case To of
|
if
|
||||||
#jid{luser = "", lresource = ""} ->
|
To#jid.luser /= "" ->
|
||||||
|
ejabberd_sm:route(From, To, Packet);
|
||||||
|
To#jid.lresource == "" ->
|
||||||
{xmlelement, Name, Attrs, _Els} = Packet,
|
{xmlelement, Name, Attrs, _Els} = Packet,
|
||||||
case Name of
|
case Name of
|
||||||
"iq" ->
|
"iq" ->
|
||||||
process_iq(State, From, To, Packet);
|
process_iq(From, To, Packet);
|
||||||
"message" ->
|
"message" ->
|
||||||
ok;
|
ok;
|
||||||
"presence" ->
|
"presence" ->
|
||||||
@ -101,7 +102,7 @@ do_route(State, From, To, Packet) ->
|
|||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
#jid{luser = "", lresource = Res} ->
|
true ->
|
||||||
{xmlelement, Name, Attrs, _Els} = Packet,
|
{xmlelement, Name, Attrs, _Els} = Packet,
|
||||||
case xml:get_attr_s("type", Attrs) of
|
case xml:get_attr_s("type", Attrs) of
|
||||||
"error" -> ok;
|
"error" -> ok;
|
||||||
@ -109,16 +110,14 @@ do_route(State, From, To, Packet) ->
|
|||||||
_ ->
|
_ ->
|
||||||
ejabberd_hooks:run(local_send_to_resource_hook,
|
ejabberd_hooks:run(local_send_to_resource_hook,
|
||||||
[From, To, Packet])
|
[From, To, Packet])
|
||||||
end;
|
end
|
||||||
_ ->
|
end.
|
||||||
ejabberd_sm ! {route, From, To, Packet}
|
|
||||||
end.
|
|
||||||
|
|
||||||
process_iq(State, From, To, Packet) ->
|
process_iq(From, To, Packet) ->
|
||||||
IQ = jlib:iq_query_info(Packet),
|
IQ = jlib:iq_query_info(Packet),
|
||||||
case IQ of
|
case IQ of
|
||||||
#iq{xmlns = XMLNS} ->
|
#iq{xmlns = XMLNS} ->
|
||||||
case ets:lookup(State#state.iqtable, XMLNS) of
|
case ets:lookup(?IQTABLE, XMLNS) of
|
||||||
[{_, Module, Function}] ->
|
[{_, Module, Function}] ->
|
||||||
ResIQ = Module:Function(From, To, IQ),
|
ResIQ = Module:Function(From, To, IQ),
|
||||||
if
|
if
|
||||||
@ -144,6 +143,15 @@ process_iq(State, From, To, Packet) ->
|
|||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
route(From, To, Packet) ->
|
||||||
|
case catch do_route(From, To, Packet) of
|
||||||
|
{'EXIT', Reason} ->
|
||||||
|
?ERROR_MSG("~p~nwhen processing: ~p",
|
||||||
|
[Reason, {From, To, Packet}]);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
register_iq_handler(XMLNS, Module, Fun) ->
|
register_iq_handler(XMLNS, Module, Fun) ->
|
||||||
ejabberd_local ! {register_iq_handler, XMLNS, Module, Fun}.
|
ejabberd_local ! {register_iq_handler, XMLNS, Module, Fun}.
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
-export([route/3,
|
-export([route/3,
|
||||||
register_route/1,
|
register_route/1,
|
||||||
|
register_route/2,
|
||||||
unregister_route/1,
|
unregister_route/1,
|
||||||
dirty_get_all_routes/0,
|
dirty_get_all_routes/0,
|
||||||
dirty_get_all_domains/0
|
dirty_get_all_domains/0
|
||||||
@ -22,15 +23,10 @@
|
|||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
|
|
||||||
-record(route, {domain, pid}).
|
-record(route, {domain, pid, local_hint}).
|
||||||
|
|
||||||
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
Pid = proc_lib:spawn_link(ejabberd_router, init, []),
|
|
||||||
register(ejabberd_router, Pid),
|
|
||||||
{ok, Pid}.
|
|
||||||
|
|
||||||
init() ->
|
|
||||||
update_tables(),
|
update_tables(),
|
||||||
mnesia:create_table(route,
|
mnesia:create_table(route,
|
||||||
[{ram_copies, [node()]},
|
[{ram_copies, [node()]},
|
||||||
@ -38,6 +34,11 @@ init() ->
|
|||||||
{attributes,
|
{attributes,
|
||||||
record_info(fields, route)}]),
|
record_info(fields, route)}]),
|
||||||
mnesia:add_table_copy(route, node(), ram_copies),
|
mnesia:add_table_copy(route, node(), ram_copies),
|
||||||
|
Pid = proc_lib:spawn_link(ejabberd_router, init, []),
|
||||||
|
register(ejabberd_router, Pid),
|
||||||
|
{ok, Pid}.
|
||||||
|
|
||||||
|
init() ->
|
||||||
mnesia:subscribe({table, route, simple}),
|
mnesia:subscribe({table, route, simple}),
|
||||||
loop().
|
loop().
|
||||||
|
|
||||||
@ -52,20 +53,6 @@ loop() ->
|
|||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
loop();
|
loop();
|
||||||
{register_route, Domain, Pid} ->
|
|
||||||
F = fun() ->
|
|
||||||
mnesia:write(#route{domain = Domain,
|
|
||||||
pid = Pid})
|
|
||||||
end,
|
|
||||||
mnesia:transaction(F),
|
|
||||||
loop();
|
|
||||||
{unregister_route, Domain, Pid} ->
|
|
||||||
F = fun() ->
|
|
||||||
mnesia:delete_object(#route{domain = Domain,
|
|
||||||
pid = Pid})
|
|
||||||
end,
|
|
||||||
mnesia:transaction(F),
|
|
||||||
loop();
|
|
||||||
{mnesia_table_event, {write, #route{pid = Pid}, _ActivityId}} ->
|
{mnesia_table_event, {write, #route{pid = Pid}, _ActivityId}} ->
|
||||||
erlang:monitor(process, Pid),
|
erlang:monitor(process, Pid),
|
||||||
loop();
|
loop();
|
||||||
@ -91,31 +78,76 @@ do_route(From, To, Packet) ->
|
|||||||
LDstDomain = To#jid.lserver,
|
LDstDomain = To#jid.lserver,
|
||||||
case mnesia:dirty_read(route, LDstDomain) of
|
case mnesia:dirty_read(route, LDstDomain) of
|
||||||
[] ->
|
[] ->
|
||||||
ejabberd_s2s ! {route, From, To, Packet};
|
ejabberd_s2s:route(From, To, Packet);
|
||||||
[R] ->
|
[R] ->
|
||||||
Pid = R#route.pid,
|
Pid = R#route.pid,
|
||||||
?DEBUG("routed to process ~p~n", [Pid]),
|
if
|
||||||
Pid ! {route, From, To, Packet};
|
node(Pid) == node() ->
|
||||||
|
case R#route.local_hint of
|
||||||
|
{apply, Module, Function} ->
|
||||||
|
Module:Function(From, To, Packet);
|
||||||
|
_ ->
|
||||||
|
Pid ! {route, From, To, Packet}
|
||||||
|
end;
|
||||||
|
true ->
|
||||||
|
Pid ! {route, From, To, Packet}
|
||||||
|
end;
|
||||||
Rs ->
|
Rs ->
|
||||||
Rs1 = case [R || R <- Rs, node(R#route.pid) == node()] of
|
case [R || R <- Rs, node(R#route.pid) == node()] of
|
||||||
[] -> Rs;
|
[] ->
|
||||||
LRs -> LRs
|
R = lists:nth(erlang:phash(now(), length(Rs)), Rs),
|
||||||
end,
|
Pid = R#route.pid,
|
||||||
R = lists:nth(erlang:phash(now(), length(Rs1)), Rs1),
|
Pid ! {route, From, To, Packet};
|
||||||
Pid = R#route.pid,
|
LRs ->
|
||||||
?DEBUG("routed to process ~p~n", [Pid]),
|
LRs,
|
||||||
Pid ! {route, From, To, Packet}
|
R = lists:nth(erlang:phash(now(), length(LRs)), LRs),
|
||||||
|
Pid = R#route.pid,
|
||||||
|
case R#route.local_hint of
|
||||||
|
{apply, Module, Function} ->
|
||||||
|
Module:Function(From, To, Packet);
|
||||||
|
_ ->
|
||||||
|
Pid ! {route, From, To, Packet}
|
||||||
|
end
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
%route(From, To, Packet) ->
|
||||||
|
% ejabberd_router ! {route, From, To, Packet}.
|
||||||
|
|
||||||
route(From, To, Packet) ->
|
route(From, To, Packet) ->
|
||||||
ejabberd_router ! {route, From, To, Packet}.
|
case catch do_route(From, To, Packet) of
|
||||||
|
{'EXIT', Reason} ->
|
||||||
|
?ERROR_MSG("~p~nwhen processing: ~p",
|
||||||
|
[Reason, {From, To, Packet}]);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
register_route(Domain) ->
|
register_route(Domain) ->
|
||||||
ejabberd_router ! {register_route, Domain, self()}.
|
Pid = self(),
|
||||||
|
F = fun() ->
|
||||||
|
mnesia:write(#route{domain = Domain,
|
||||||
|
pid = Pid})
|
||||||
|
end,
|
||||||
|
mnesia:transaction(F).
|
||||||
|
|
||||||
|
register_route(Domain, LocalHint) ->
|
||||||
|
Pid = self(),
|
||||||
|
F = fun() ->
|
||||||
|
mnesia:write(#route{domain = Domain,
|
||||||
|
pid = Pid,
|
||||||
|
local_hint = LocalHint})
|
||||||
|
end,
|
||||||
|
mnesia:transaction(F).
|
||||||
|
|
||||||
unregister_route(Domain) ->
|
unregister_route(Domain) ->
|
||||||
ejabberd_router ! {unregister_route, Domain, self()}.
|
Pid = self(),
|
||||||
|
F = fun() ->
|
||||||
|
mnesia:delete_object(#route{domain = Domain,
|
||||||
|
pid = Pid})
|
||||||
|
end,
|
||||||
|
mnesia:transaction(F).
|
||||||
|
|
||||||
|
|
||||||
dirty_get_all_routes() ->
|
dirty_get_all_routes() ->
|
||||||
@ -131,6 +163,8 @@ update_tables() ->
|
|||||||
[domain, node, pid] ->
|
[domain, node, pid] ->
|
||||||
mnesia:delete_table(route);
|
mnesia:delete_table(route);
|
||||||
[domain, pid] ->
|
[domain, pid] ->
|
||||||
|
mnesia:delete_table(route);
|
||||||
|
[domain, pid, local_hint] ->
|
||||||
ok;
|
ok;
|
||||||
{'EXIT', _} ->
|
{'EXIT', _} ->
|
||||||
ok
|
ok
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
-vsn('$Revision$ ').
|
-vsn('$Revision$ ').
|
||||||
|
|
||||||
-export([start_link/0, init/0,
|
-export([start_link/0, init/0,
|
||||||
|
route/3,
|
||||||
have_connection/1,
|
have_connection/1,
|
||||||
get_key/1,
|
get_key/1,
|
||||||
try_register/1,
|
try_register/1,
|
||||||
|
remove_connection/1,
|
||||||
dirty_get_connections/0]).
|
dirty_get_connections/0]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -29,17 +31,14 @@ start_link() ->
|
|||||||
|
|
||||||
init() ->
|
init() ->
|
||||||
update_tables(),
|
update_tables(),
|
||||||
mnesia:create_table(s2s,[{ram_copies, [node()]},
|
mnesia:create_table(s2s, [{ram_copies, [node()]},
|
||||||
{attributes, record_info(fields, s2s)}]),
|
{attributes, record_info(fields, s2s)}]),
|
||||||
mnesia:add_table_copy(s2s, node(), ram_copies),
|
mnesia:add_table_copy(s2s, node(), ram_copies),
|
||||||
mnesia:subscribe(system),
|
mnesia:subscribe(system),
|
||||||
loop().
|
loop().
|
||||||
|
|
||||||
loop() ->
|
loop() ->
|
||||||
receive
|
receive
|
||||||
{closed_conection, FromTo} ->
|
|
||||||
remove_connection(FromTo),
|
|
||||||
loop();
|
|
||||||
{mnesia_system_event, {mnesia_down, Node}} ->
|
{mnesia_system_event, {mnesia_down, Node}} ->
|
||||||
clean_table_from_bad_node(Node),
|
clean_table_from_bad_node(Node),
|
||||||
loop();
|
loop();
|
||||||
@ -57,6 +56,15 @@ loop() ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
route(From, To, Packet) ->
|
||||||
|
case catch do_route(From, To, Packet) of
|
||||||
|
{'EXIT', Reason} ->
|
||||||
|
?ERROR_MSG("~p~nwhen processing: ~p",
|
||||||
|
[Reason, {From, To, Packet}]);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
remove_connection(FromTo) ->
|
remove_connection(FromTo) ->
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
|
@ -311,14 +311,6 @@ handle_info(_, StateName, StateData) ->
|
|||||||
%% Returns: any
|
%% Returns: any
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
terminate(Reason, _StateName, StateData) ->
|
terminate(Reason, _StateName, StateData) ->
|
||||||
% case StateData#state.user of
|
|
||||||
% "" ->
|
|
||||||
% ok;
|
|
||||||
% _ ->
|
|
||||||
% %ejabberd_sm:close_session(StateData#state.user,
|
|
||||||
% % StateData#state.resource)
|
|
||||||
% end,
|
|
||||||
%ejabberd_s2s ! {closed_conection, StateData#state.server},
|
|
||||||
?INFO_MSG("terminated: ~p", [Reason]),
|
?INFO_MSG("terminated: ~p", [Reason]),
|
||||||
gen_tcp:close(StateData#state.socket),
|
gen_tcp:close(StateData#state.socket),
|
||||||
ok.
|
ok.
|
||||||
|
@ -397,8 +397,8 @@ terminate(Reason, StateName, StateData) ->
|
|||||||
false ->
|
false ->
|
||||||
ok;
|
ok;
|
||||||
Key ->
|
Key ->
|
||||||
ejabberd_s2s ! {closed_conection, {StateData#state.myname,
|
ejabberd_s2s:remove_connection({StateData#state.myname,
|
||||||
StateData#state.server}}
|
StateData#state.server})
|
||||||
end,
|
end,
|
||||||
case StateData#state.socket of
|
case StateData#state.socket of
|
||||||
undefined ->
|
undefined ->
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
-author('alexey@sevcom.net').
|
-author('alexey@sevcom.net').
|
||||||
-vsn('$Revision$ ').
|
-vsn('$Revision$ ').
|
||||||
|
|
||||||
-export([start_link/0, init/0, open_session/2, close_session/2,
|
-export([start_link/0, init/0,
|
||||||
|
route/3,
|
||||||
|
open_session/2, close_session/2,
|
||||||
bounce_offline_message/3,
|
bounce_offline_message/3,
|
||||||
get_user_resources/1,
|
get_user_resources/1,
|
||||||
set_presence/3,
|
set_presence/3,
|
||||||
@ -89,11 +91,20 @@ loop() ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
route(From, To, Packet) ->
|
||||||
|
case catch do_route(From, To, Packet) of
|
||||||
|
{'EXIT', Reason} ->
|
||||||
|
?ERROR_MSG("~p~nwhen processing: ~p",
|
||||||
|
[Reason, {From, To, Packet}]);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
open_session(User, Resource) ->
|
open_session(User, Resource) ->
|
||||||
ejabberd_sm ! {open_session, User, Resource, self()}.
|
register_connection(User, Resource, self()).
|
||||||
|
|
||||||
close_session(User, Resource) ->
|
close_session(User, Resource) ->
|
||||||
ejabberd_sm ! {close_session, User, Resource}.
|
remove_connection(User, Resource).
|
||||||
|
|
||||||
|
|
||||||
register_connection(User, Resource, Pid) ->
|
register_connection(User, Resource, Pid) ->
|
||||||
|
@ -17,10 +17,10 @@ OBJS = \
|
|||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
|
|
||||||
ELDAPv3.erl: ELDAPv3.asn
|
ELDAPv3.erl: ELDAPv3.asn
|
||||||
erlc -bber_bin -W $(EFLAGS) $<
|
@ERLC@ -bber_bin -W $(EFLAGS) $<
|
||||||
|
|
||||||
$(OUTDIR)/%.beam: %.erl ELDAPv3.erl
|
$(OUTDIR)/%.beam: %.erl ELDAPv3.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
@ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -20,7 +20,7 @@ OBJS = \
|
|||||||
all: $(OBJS) $(ERLSHLIBS)
|
all: $(OBJS) $(ERLSHLIBS)
|
||||||
|
|
||||||
$(OUTDIR)/%.beam: %.erl
|
$(OUTDIR)/%.beam: %.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
@ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
|
||||||
|
|
||||||
#all: $(ERLSHLIBS)
|
#all: $(ERLSHLIBS)
|
||||||
# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt
|
# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt
|
||||||
|
@ -17,7 +17,7 @@ OBJS = \
|
|||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
|
|
||||||
$(OUTDIR)/%.beam: %.erl
|
$(OUTDIR)/%.beam: %.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
@ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
|
@ -16,7 +16,7 @@ OBJS = \
|
|||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
|
|
||||||
$(OUTDIR)/%.beam: %.erl
|
$(OUTDIR)/%.beam: %.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
@ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
|
@ -29,7 +29,9 @@ start(Opts) ->
|
|||||||
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_VCARD,
|
gen_iq_handler:add_iq_handler(ejabberd_sm, ?NS_VCARD,
|
||||||
?MODULE, process_sm_iq, IQDisc),
|
?MODULE, process_sm_iq, IQDisc),
|
||||||
LDAPServers = ejabberd_config:get_local_option(ldap_servers),
|
LDAPServers = ejabberd_config:get_local_option(ldap_servers),
|
||||||
eldap:start_link("mod_vcard_ldap", LDAPServers, 389, "", ""),
|
RootDN = ejabberd_config:get_local_option(ldap_rootdn),
|
||||||
|
Password = ejabberd_config:get_local_option(ldap_password),
|
||||||
|
eldap:start_link("mod_vcard_ldap", LDAPServers, 389, RootDN, Password),
|
||||||
Host = gen_mod:get_opt(host, Opts, "vjud." ++ ?MYNAME),
|
Host = gen_mod:get_opt(host, Opts, "vjud." ++ ?MYNAME),
|
||||||
Search = gen_mod:get_opt(search, Opts, true),
|
Search = gen_mod:get_opt(search, Opts, true),
|
||||||
register(ejabberd_mod_vcard_ldap, spawn(?MODULE, init, [Host, Search])).
|
register(ejabberd_mod_vcard_ldap, spawn(?MODULE, init, [Host, Search])).
|
||||||
|
@ -18,7 +18,7 @@ OBJS = \
|
|||||||
all: $(OBJS) $(ERLSHLIBS)
|
all: $(OBJS) $(ERLSHLIBS)
|
||||||
|
|
||||||
$(OUTDIR)/%.beam: %.erl
|
$(OUTDIR)/%.beam: %.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
@ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
|
||||||
|
|
||||||
#all: $(ERLSHLIBS)
|
#all: $(ERLSHLIBS)
|
||||||
# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt
|
# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt
|
||||||
|
@ -18,7 +18,7 @@ OBJS = \
|
|||||||
all: $(OBJS) $(ERLSHLIBS)
|
all: $(OBJS) $(ERLSHLIBS)
|
||||||
|
|
||||||
$(OUTDIR)/%.beam: %.erl
|
$(OUTDIR)/%.beam: %.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
@ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
|
||||||
|
|
||||||
#all: $(ERLSHLIBS)
|
#all: $(ERLSHLIBS)
|
||||||
# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt
|
# erl -s make all report "{outdir, \"..\"}" -noinput -s erlang halt
|
||||||
|
@ -20,7 +20,7 @@ OBJS = \
|
|||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
|
|
||||||
$(OUTDIR)/%.beam: %.erl
|
$(OUTDIR)/%.beam: %.erl
|
||||||
erlc -W $(EFLAGS) -o $(OUTDIR) $<
|
@ERLC@ -W $(EFLAGS) -o $(OUTDIR) $<
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
Loading…
Reference in New Issue
Block a user