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

* src/ejabberd_router.erl: Added route_packet hook

SVN Revision: 380
This commit is contained in:
Alexey Shchepin 2005-07-27 00:54:53 +00:00
parent 02d3151ee7
commit e9e1893b01
2 changed files with 45 additions and 34 deletions

View File

@ -1,3 +1,7 @@
2005-07-27 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_router.erl: Added route_packet hook
2005-07-26 Alexey Shchepin <alexey@sevcom.net> 2005-07-26 Alexey Shchepin <alexey@sevcom.net>
* src/jd2ejd.erl: Updated to work with ODBC * src/jd2ejd.erl: Updated to work with ODBC

View File

@ -80,45 +80,52 @@ loop() ->
loop() loop()
end. end.
do_route(From, To, Packet) -> do_route(OrigFrom, OrigTo, OrigPacket) ->
?DEBUG("route~n\tfrom ~p~n\tto ~p~n\tpacket ~p~n", [From, To, Packet]), ?DEBUG("route~n\tfrom ~p~n\tto ~p~n\tpacket ~p~n",
LDstDomain = To#jid.lserver, [OrigFrom, OrigTo, OrigPacket]),
case mnesia:dirty_read(route, LDstDomain) of LOrigDstDomain = OrigTo#jid.lserver,
[] -> case ejabberd_hooks:run_fold(
ejabberd_s2s:route(From, To, Packet); route_packet, LOrigDstDomain, {OrigFrom, OrigTo, OrigPacket}, []) of
[R] -> {From, To, Packet} ->
Pid = R#route.pid, LDstDomain = To#jid.lserver,
if case mnesia:dirty_read(route, LDstDomain) of
node(Pid) == node() -> [] ->
case R#route.local_hint of ejabberd_s2s:route(From, To, Packet);
{apply, Module, Function} -> [R] ->
Module:Function(From, To, Packet); Pid = R#route.pid,
_ -> if
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} Pid ! {route, From, To, Packet}
end; end;
true -> Rs ->
Pid ! {route, From, To, Packet} case [R || R <- Rs, node(R#route.pid) == node()] of
end; [] ->
Rs -> R = lists:nth(erlang:phash(now(), length(Rs)), Rs),
case [R || R <- Rs, node(R#route.pid) == node()] of Pid = R#route.pid,
[] -> Pid ! {route, From, To, Packet};
R = lists:nth(erlang:phash(now(), length(Rs)), Rs), LRs ->
Pid = R#route.pid, LRs,
Pid ! {route, From, To, Packet}; R = lists:nth(erlang:phash(now(), length(LRs)), LRs),
LRs -> Pid = R#route.pid,
LRs, case R#route.local_hint of
R = lists:nth(erlang:phash(now(), length(LRs)), LRs), {apply, Module, Function} ->
Pid = R#route.pid, Module:Function(From, To, Packet);
case R#route.local_hint of _ ->
{apply, Module, Function} -> Pid ! {route, From, To, Packet}
Module:Function(From, To, Packet); end
_ ->
Pid ! {route, From, To, Packet}
end end
end end;
drop ->
ok
end. end.
%route(From, To, Packet) -> %route(From, To, Packet) ->
% ejabberd_router ! {route, From, To, Packet}. % ejabberd_router ! {route, From, To, Packet}.