mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Routing is now done with #xmlel. A warning is printed if those modules
have to route an old #xmlelement. SVN Revision: 1406
This commit is contained in:
parent
48cf5cb84a
commit
13b78b1ad2
@ -43,6 +43,11 @@
|
|||||||
src/gen_iq_handler.erl: Do not use the #iq record anymore internally.
|
src/gen_iq_handler.erl: Do not use the #iq record anymore internally.
|
||||||
However it's still created and passed to other modules.
|
However it's still created and passed to other modules.
|
||||||
|
|
||||||
|
* src/ejabberd_router.erl, src/ejabberd_sm.erl,
|
||||||
|
src/ejabberd_local.erl, src/ejabberd_s2s.erl: Routing is now done with
|
||||||
|
#xmlel. A warning is printed if those modules have to route an old
|
||||||
|
#xmlelement.
|
||||||
|
|
||||||
2008-06-30 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
2008-06-30 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
||||||
|
|
||||||
* src/Makefile.in: Remove the -I flag for exmpp includes; the
|
* src/Makefile.in: Remove the -I flag for exmpp includes; the
|
||||||
|
@ -133,21 +133,24 @@ process_iq_reply(From, To, Packet) ->
|
|||||||
% XXX OLD FORMAT: From, To, Packet.
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
FromOld = jlib:to_old_jid(From),
|
FromOld = jlib:to_old_jid(From),
|
||||||
ToOld = jlib:to_old_jid(To),
|
ToOld = jlib:to_old_jid(To),
|
||||||
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
|
IQ_Rec = jlib:iq_query_or_response_info(Packet),
|
||||||
[?DEFAULT_NS], ?PREFIXED_NS),
|
|
||||||
IQ_Rec = jlib:iq_query_or_response_info(PacketOld),
|
|
||||||
Module:Function(FromOld, ToOld, IQ_Rec);
|
Module:Function(FromOld, ToOld, IQ_Rec);
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
route(FromOld, ToOld, PacketOld) ->
|
route(FromOld, ToOld, #xmlelement{} = PacketOld) ->
|
||||||
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nLOCAL: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
% XXX OLD FORMAT: From, To, Packet.
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
From = jlib:from_old_jid(FromOld),
|
From = jlib:from_old_jid(FromOld),
|
||||||
To = jlib:from_old_jid(ToOld),
|
To = jlib:from_old_jid(ToOld),
|
||||||
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
[?DEFAULT_NS], ?PREFIXED_NS),
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
route(From, To, Packet);
|
||||||
|
route(From, To, Packet) ->
|
||||||
case catch do_route(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",
|
||||||
@ -229,12 +232,17 @@ handle_cast(_Msg, State) ->
|
|||||||
%% {stop, Reason, State}
|
%% {stop, Reason, State}
|
||||||
%% Description: Handling all non call/cast messages
|
%% Description: Handling all non call/cast messages
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
handle_info({route, FromOld, ToOld, PacketOld}, State) ->
|
handle_info({route, FromOld, ToOld, #xmlelement{} = PacketOld}, State) ->
|
||||||
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nLOCAL: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
% XXX OLD FORMAT: From, To, Packet.
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
From = jlib:from_old_jid(FromOld),
|
From = jlib:from_old_jid(FromOld),
|
||||||
To = jlib:from_old_jid(ToOld),
|
To = jlib:from_old_jid(ToOld),
|
||||||
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
[?DEFAULT_NS], ?PREFIXED_NS),
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
handle_info({route, From, To, Packet}, State);
|
||||||
|
handle_info({route, From, To, Packet}, State) ->
|
||||||
case catch do_route(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",
|
||||||
|
@ -64,10 +64,18 @@ start_link() ->
|
|||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
|
||||||
|
route(FromOld, ToOld, #xmlelement{} = PacketOld) ->
|
||||||
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nROUTER: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
|
From = jlib:from_old_jid(FromOld),
|
||||||
|
To = jlib:from_old_jid(ToOld),
|
||||||
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
route(From, To, Packet);
|
||||||
route(From, To, Packet) ->
|
route(From, To, Packet) ->
|
||||||
% XXX OLD FORMAT: This code helps to detect old format routing.
|
case catch do_route(From, To, Packet) of
|
||||||
{FromOld, ToOld, PacketOld} = convert_to_old_structs(From, To, Packet),
|
|
||||||
case catch do_route(FromOld, ToOld, PacketOld) 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}]);
|
||||||
@ -239,9 +247,18 @@ handle_cast(_Msg, State) ->
|
|||||||
%% {stop, Reason, State}
|
%% {stop, Reason, State}
|
||||||
%% Description: Handling all non call/cast messages
|
%% Description: Handling all non call/cast messages
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
handle_info({route, FromOld, ToOld, #xmlelement{} = PacketOld}, State) ->
|
||||||
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nROUTER: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
|
From = jlib:from_old_jid(FromOld),
|
||||||
|
To = jlib:from_old_jid(ToOld),
|
||||||
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
handle_info({route, From, To, Packet}, State);
|
||||||
handle_info({route, From, To, Packet}, State) ->
|
handle_info({route, From, To, Packet}, State) ->
|
||||||
{FromOld, ToOld, PacketOld} = convert_to_old_structs(From, To, Packet),
|
case catch do_route(From, To, Packet) of
|
||||||
case catch do_route(FromOld, ToOld, PacketOld) 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}]);
|
||||||
@ -304,9 +321,19 @@ code_change(_OldVsn, State, _Extra) ->
|
|||||||
do_route(OrigFrom, OrigTo, OrigPacket) ->
|
do_route(OrigFrom, OrigTo, OrigPacket) ->
|
||||||
?DEBUG("route~n\tfrom ~p~n\tto ~p~n\tpacket ~p~n",
|
?DEBUG("route~n\tfrom ~p~n\tto ~p~n\tpacket ~p~n",
|
||||||
[OrigFrom, OrigTo, OrigPacket]),
|
[OrigFrom, OrigTo, OrigPacket]),
|
||||||
|
% XXX OLD FORMAT: OrigFrom, OrigTo, OrigPacket.
|
||||||
|
OrigFromOld = jlib:to_old_jid(OrigFrom),
|
||||||
|
OrigToOld = jlib:to_old_jid(OrigTo),
|
||||||
|
OrigPacketOld = exmpp_xml:xmlel_to_xmlelement(OrigPacket,
|
||||||
|
[?NS_JABBER_CLIENT], [{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
case ejabberd_hooks:run_fold(filter_packet,
|
case ejabberd_hooks:run_fold(filter_packet,
|
||||||
{OrigFrom, OrigTo, OrigPacket}, []) of
|
{OrigFromOld, OrigToOld, OrigPacketOld}, []) of
|
||||||
{From, To, Packet} ->
|
{FromOld, ToOld, PacketOld} ->
|
||||||
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
|
From = jlib:from_old_jid(FromOld),
|
||||||
|
To = jlib:from_old_jid(ToOld),
|
||||||
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
|
||||||
|
[?NS_JABBER_CLIENT], [{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
LDstDomain = To#jid.ldomain,
|
LDstDomain = To#jid.ldomain,
|
||||||
case mnesia:dirty_read(route, LDstDomain) of
|
case mnesia:dirty_read(route, LDstDomain) of
|
||||||
[] ->
|
[] ->
|
||||||
@ -334,11 +361,9 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
|
|||||||
source -> jlib:short_jid(From);
|
source -> jlib:short_jid(From);
|
||||||
destination -> jlib:short_jid(To);
|
destination -> jlib:short_jid(To);
|
||||||
bare_source ->
|
bare_source ->
|
||||||
jlib:short_jid(
|
jlib:short_bare_jid(From);
|
||||||
exmpp_jid:jid_to_bare_jid(From));
|
|
||||||
bare_destination ->
|
bare_destination ->
|
||||||
jlib:short_jid(
|
jlib:short_bare_jid(To)
|
||||||
exmpp_jid:jid_tl_bare_jid(To))
|
|
||||||
end,
|
end,
|
||||||
case get_component_number(LDstDomain) of
|
case get_component_number(LDstDomain) of
|
||||||
undefined ->
|
undefined ->
|
||||||
@ -405,25 +430,3 @@ update_tables() ->
|
|||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
convert_to_old_structs(From, To, Packet) ->
|
|
||||||
% XXX OLD FORMAT: This code helps to detect old format routing.
|
|
||||||
if
|
|
||||||
is_record(Packet, xmlelement) ->
|
|
||||||
catch throw(for_stacktrace), % To have a stacktrace.
|
|
||||||
io:format("~nROUTER: old #xmlelement:~n~p~n~p~n~n",
|
|
||||||
[Packet, erlang:get_stacktrace()]),
|
|
||||||
{From, To, Packet};
|
|
||||||
true ->
|
|
||||||
F = jlib:to_old_jid(From),
|
|
||||||
T = jlib:to_old_jid(To),
|
|
||||||
Default_NS = case lists:member({Packet#xmlel.ns, none},
|
|
||||||
Packet#xmlel.declared_ns) of
|
|
||||||
true -> [];
|
|
||||||
false -> [Packet#xmlel.ns]
|
|
||||||
end,
|
|
||||||
P = exmpp_xml:xmlel_to_xmlelement(Packet,
|
|
||||||
Default_NS,
|
|
||||||
[{?NS_XMPP, ?NS_XMPP_pfx}, {?NS_DIALBACK, ?NS_DIALBACK_pfx}]),
|
|
||||||
{F, T, P}
|
|
||||||
end.
|
|
||||||
|
@ -74,12 +74,17 @@
|
|||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||||
|
|
||||||
route(FromOld, ToOld, PacketOld) ->
|
route(FromOld, ToOld, #xmlelement{} = PacketOld) ->
|
||||||
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nS2S: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
% XXX OLD FORMAT: From, To, Packet.
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
From = jlib:from_old_jid(FromOld),
|
From = jlib:from_old_jid(FromOld),
|
||||||
To = jlib:from_old_jid(ToOld),
|
To = jlib:from_old_jid(ToOld),
|
||||||
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
[?DEFAULT_NS], ?PREFIXED_NS),
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
route(From, To, Packet);
|
||||||
|
route(From, To, Packet) ->
|
||||||
case catch do_route(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",
|
||||||
@ -214,12 +219,17 @@ handle_cast(_Msg, State) ->
|
|||||||
handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
|
handle_info({mnesia_system_event, {mnesia_down, Node}}, State) ->
|
||||||
clean_table_from_bad_node(Node),
|
clean_table_from_bad_node(Node),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info({route, FromOld, ToOld, PacketOld}, State) ->
|
handle_info({route, FromOld, ToOld, #xmlelement{} = PacketOld}, State) ->
|
||||||
% XXX OLD FORMAT: From, To, Packet
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nS2S: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
From = jlib:from_old_jid(FromOld),
|
From = jlib:from_old_jid(FromOld),
|
||||||
To = jlib:from_old_jid(ToOld),
|
To = jlib:from_old_jid(ToOld),
|
||||||
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
[?NS_JABBER_CLIENT], [{?NS_XMPP, ?NS_XMPP_pfx}]),
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
handle_info({route, From, To, Packet}, State);
|
||||||
|
handle_info({route, From, To, Packet}, State) ->
|
||||||
case catch do_route(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",
|
||||||
@ -267,16 +277,15 @@ clean_table_from_bad_node(Node) ->
|
|||||||
do_route(From, To, Packet) ->
|
do_route(From, To, Packet) ->
|
||||||
?DEBUG("s2s manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
?DEBUG("s2s manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
||||||
[From, To, Packet, 8]),
|
[From, To, Packet, 8]),
|
||||||
% XXX OLD FORMAT: From, To.
|
|
||||||
FromOld = jlib:to_old_jid(From),
|
|
||||||
ToOld = jlib:to_old_jid(To),
|
|
||||||
case find_connection(From, To) of
|
case find_connection(From, To) of
|
||||||
{atomic, Pid} when pid(Pid) ->
|
{atomic, Pid} when pid(Pid) ->
|
||||||
?DEBUG("sending to process ~p~n", [Pid]),
|
?DEBUG("sending to process ~p~n", [Pid]),
|
||||||
NewPacket1 = exmpp_stanza:set_sender(Packet, From),
|
NewPacket1 = exmpp_stanza:set_sender(Packet, From),
|
||||||
NewPacket = exmpp_stanza:set_recipient(NewPacket1, To),
|
NewPacket = exmpp_stanza:set_recipient(NewPacket1, To),
|
||||||
#jid{ldomain = MyServer} = From,
|
#jid{ldomain = MyServer} = From,
|
||||||
% XXX OLD FORMAT: NewPacket.
|
% XXX OLD FORMAT: From, To, NewPacket.
|
||||||
|
FromOld = jlib:to_old_jid(From),
|
||||||
|
ToOld = jlib:to_old_jid(To),
|
||||||
NewPacketOld = exmpp_xml:xmlel_to_xmlelement(NewPacket,
|
NewPacketOld = exmpp_xml:xmlel_to_xmlelement(NewPacket,
|
||||||
[?DEFAULT_NS], ?PREFIXED_NS),
|
[?DEFAULT_NS], ?PREFIXED_NS),
|
||||||
ejabberd_hooks:run(
|
ejabberd_hooks:run(
|
||||||
|
@ -84,12 +84,17 @@
|
|||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||||
|
|
||||||
route(FromOld, ToOld, PacketOld) ->
|
route(FromOld, ToOld, #xmlelement{} = PacketOld) ->
|
||||||
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nSM: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
% XXX OLD FORMAT: From, To, Packet.
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
From = jlib:from_old_jid(FromOld),
|
From = jlib:from_old_jid(FromOld),
|
||||||
To = jlib:from_old_jid(ToOld),
|
To = jlib:from_old_jid(ToOld),
|
||||||
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
[?DEFAULT_NS], ?PREFIXED_NS),
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
route(From, To, Packet);
|
||||||
|
route(From, To, Packet) ->
|
||||||
case catch do_route(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",
|
||||||
@ -307,12 +312,17 @@ handle_cast(_Msg, State) ->
|
|||||||
%% {stop, Reason, State}
|
%% {stop, Reason, State}
|
||||||
%% Description: Handling all non call/cast messages
|
%% Description: Handling all non call/cast messages
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
handle_info({route, FromOld, ToOld, PacketOld}, State) ->
|
handle_info({route, FromOld, ToOld, #xmlelement{} = PacketOld}, State) ->
|
||||||
|
catch throw(for_stacktrace), % To have a stacktrace.
|
||||||
|
io:format("~nSM: old #xmlelement:~n~p~n~p~n~n",
|
||||||
|
[PacketOld, erlang:get_stacktrace()]),
|
||||||
% XXX OLD FORMAT: From, To, Packet.
|
% XXX OLD FORMAT: From, To, Packet.
|
||||||
From = jlib:from_old_jid(FromOld),
|
From = jlib:from_old_jid(FromOld),
|
||||||
To = jlib:from_old_jid(ToOld),
|
To = jlib:from_old_jid(ToOld),
|
||||||
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
|
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, [?NS_JABBER_CLIENT],
|
||||||
[?DEFAULT_NS], ?PREFIXED_NS),
|
[{?NS_XMPP, ?NS_XMPP_pfx}]),
|
||||||
|
handle_info({route, From, To, Packet}, State);
|
||||||
|
handle_info({route, From, To, Packet}, State) ->
|
||||||
case catch do_route(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",
|
||||||
|
Loading…
Reference in New Issue
Block a user