Created
September 25, 2013 10:17
-
-
Save sourenaraya/6697722 to your computer and use it in GitHub Desktop.
XEP vioalation, send messages to all connected resources. patch based on https://github.com/gjedeer/ejabberd sourcetree Tested on ejabberd-v2.1.13-0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -Naur processone-ejabberd-2ed62dc/src/ejabberd_local.erl processone-ejabberd-xep_violation/src/ejabberd_local.erl | |
--- processone-ejabberd-2ed62dc/src/ejabberd_local.erl 2013-06-25 19:46:12.000000000 +1100 | |
+++ processone-ejabberd-xep_violation/src/ejabberd_local.erl 2013-09-18 23:21:21.804147966 +1100 | |
@@ -5,7 +5,7 @@ | |
%%% Created : 30 Nov 2002 by Alexey Shchepin <alexey@process-one.net> | |
%%% | |
%%% | |
-%%% ejabberd, Copyright (C) 2002-2013 ProcessOne | |
+%%% ejabberd, Copyright (C) 2002-2012 ProcessOne | |
%%% | |
%%% This program is free software; you can redistribute it and/or | |
%%% modify it under the terms of the GNU General Public License as | |
@@ -302,27 +302,18 @@ | |
if | |
To#jid.luser /= "" -> | |
ejabberd_sm:route(From, To, Packet); | |
- To#jid.lresource == "" -> | |
+ true -> | |
{xmlelement, Name, _Attrs, _Els} = Packet, | |
+ ResourcelessTo = To#jid{lresource=""}, | |
case Name of | |
"iq" -> | |
- process_iq(From, To, Packet); | |
+ process_iq(From, ResourcelessTo, Packet); | |
"message" -> | |
ok; | |
"presence" -> | |
ok; | |
_ -> | |
ok | |
- end; | |
- true -> | |
- {xmlelement, _Name, Attrs, _Els} = Packet, | |
- case xml:get_attr_s("type", Attrs) of | |
- "error" -> ok; | |
- "result" -> ok; | |
- _ -> | |
- ejabberd_hooks:run(local_send_to_resource_hook, | |
- To#jid.lserver, | |
- [From, To, Packet]) | |
end | |
end. | |
diff -Naur processone-ejabberd-2ed62dc/src/ejabberd_sm.erl processone-ejabberd-xep_violation/src/ejabberd_sm.erl | |
--- processone-ejabberd-2ed62dc/src/ejabberd_sm.erl 2013-06-25 19:46:12.000000000 +1100 | |
+++ processone-ejabberd-xep_violation/src/ejabberd_sm.erl 2013-09-18 23:21:18.574165465 +1100 | |
@@ -5,7 +5,7 @@ | |
%%% Created : 24 Nov 2002 by Alexey Shchepin <alexey@process-one.net> | |
%%% | |
%%% | |
-%%% ejabberd, Copyright (C) 2002-2013 ProcessOne | |
+%%% ejabberd, Copyright (C) 2002-2012 ProcessOne | |
%%% | |
%%% This program is free software; you can redistribute it and/or | |
%%% modify it under the terms of the GNU General Public License as | |
@@ -485,32 +485,58 @@ | |
ok | |
end; | |
_ -> | |
- USR = {LUser, LServer, LResource}, | |
- case mnesia:dirty_index_read(session, USR, #session.usr) of | |
- [] -> | |
- case Name of | |
- "message" -> | |
- route_message(From, To, Packet); | |
- "iq" -> | |
- case xml:get_attr_s("type", Attrs) of | |
- "error" -> ok; | |
- "result" -> ok; | |
- _ -> | |
- Err = | |
- jlib:make_error_reply( | |
- Packet, ?ERR_SERVICE_UNAVAILABLE), | |
- ejabberd_router:route(To, From, Err) | |
- end; | |
- _ -> | |
- ?DEBUG("packet droped~n", []) | |
- end; | |
- Ss -> | |
- Session = lists:max(Ss), | |
- Pid = element(2, Session#session.sid), | |
- ?DEBUG("sending to process ~p~n", [Pid]), | |
- Pid ! {route, From, To, Packet} | |
- end | |
- end. | |
+ case Name of | |
+ "message" -> | |
+ %% GDR! %% | |
+ PrioRes = get_user_present_resources(LUser, LServer), | |
+ lists:foreach( | |
+ fun({P, R}) when P >= 0 -> | |
+ %% /GDR! %% | |
+ USR = {LUser, LServer, jlib:resourceprep(R)}, | |
+ case mnesia:dirty_index_read(session, USR, #session.usr) of | |
+ [] -> | |
+ route_message(From, To, Packet); | |
+ Ss -> % Session found | |
+ Session = lists:max(Ss), | |
+ Pid = element(2, Session#session.sid), | |
+ ?DEBUG("sending to process ~p~n", [Pid]), | |
+ Pid ! {route, From, | |
+ jlib:jid_replace_resource(To, R), | |
+ Packet} | |
+ end; | |
+ %% Ignore other priority: | |
+ ({_Prio, _Res}) -> | |
+ ok | |
+ end, | |
+ PrioRes); % loop.foreach | |
+ _ -> | |
+ USR = {LUser, LServer, LResource}, | |
+ case mnesia:dirty_index_read(session, USR, #session.usr) of | |
+ [] -> | |
+ case Name of | |
+ "message" -> | |
+ route_message(From, To, Packet); | |
+ "iq" -> | |
+ case xml:get_attr_s("type", Attrs) of | |
+ "error" -> ok; | |
+ "result" -> ok; | |
+ _ -> | |
+ Err = | |
+ jlib:make_error_reply( | |
+ Packet, ?ERR_SERVICE_UNAVAILABLE), | |
+ ejabberd_router:route(To, From, Err) | |
+ end; | |
+ _ -> | |
+ ?DEBUG("packet droped~n", []) | |
+ end; | |
+ Ss -> % Session found | |
+ Session = lists:max(Ss), | |
+ Pid = element(2, Session#session.sid), | |
+ ?DEBUG("sending to process ~p~n", [Pid]), | |
+ Pid ! {route, From, To, Packet} | |
+ end | |
+ end | |
+end. | |
%% The default list applies to the user as a whole, | |
%% and is processed if there is no active list set |
I'm also interested on this patch for 15.x. Any suggestions ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Доброго дня! а есть подобный патч для версии 15.x?