mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
* src/mod_privacy.erl: Privacy List: deny presence-out all + send
presence to: presence is sent (EJAB-255) * src/ejabberd_c2s.erl: Likewise SVN Revision: 1881
This commit is contained in:
parent
22d87353be
commit
b0cc0cdcf9
@ -1,5 +1,9 @@
|
|||||||
2009-02-16 Badlop <badlop@process-one.net>
|
2009-02-16 Badlop <badlop@process-one.net>
|
||||||
|
|
||||||
|
* src/mod_privacy.erl: Privacy List: deny presence-out all + send
|
||||||
|
presence to: presence is sent (EJAB-255)
|
||||||
|
* src/ejabberd_c2s.erl: Likewise
|
||||||
|
|
||||||
* src/mod_muc/mod_muc_room.erl: Owner of a password protected room
|
* src/mod_muc/mod_muc_room.erl: Owner of a password protected room
|
||||||
must provide the password, like other participants (EJAB-867)
|
must provide the password, like other participants (EJAB-867)
|
||||||
|
|
||||||
|
@ -973,7 +973,8 @@ session_established2(El, StateData) ->
|
|||||||
ejabberd_hooks:run(user_send_packet,
|
ejabberd_hooks:run(user_send_packet,
|
||||||
Server,
|
Server,
|
||||||
[FromJID, ToJID, NewEl]),
|
[FromJID, ToJID, NewEl]),
|
||||||
ejabberd_router:route(FromJID, ToJID, NewEl),
|
check_privacy_route(FromJID, StateData, FromJID,
|
||||||
|
ToJID, NewEl),
|
||||||
StateData;
|
StateData;
|
||||||
_ ->
|
_ ->
|
||||||
StateData
|
StateData
|
||||||
@ -1571,13 +1572,13 @@ presence_track(From, To, Packet, StateData) ->
|
|||||||
Server = StateData#state.server,
|
Server = StateData#state.server,
|
||||||
case xml:get_attr_s("type", Attrs) of
|
case xml:get_attr_s("type", Attrs) of
|
||||||
"unavailable" ->
|
"unavailable" ->
|
||||||
ejabberd_router:route(From, To, Packet),
|
check_privacy_route(From, StateData, From, To, Packet),
|
||||||
I = remove_element(LTo, StateData#state.pres_i),
|
I = remove_element(LTo, StateData#state.pres_i),
|
||||||
A = remove_element(LTo, StateData#state.pres_a),
|
A = remove_element(LTo, StateData#state.pres_a),
|
||||||
StateData#state{pres_i = I,
|
StateData#state{pres_i = I,
|
||||||
pres_a = A};
|
pres_a = A};
|
||||||
"invisible" ->
|
"invisible" ->
|
||||||
ejabberd_router:route(From, To, Packet),
|
check_privacy_route(From, StateData, From, To, Packet),
|
||||||
I = ?SETS:add_element(LTo, StateData#state.pres_i),
|
I = ?SETS:add_element(LTo, StateData#state.pres_i),
|
||||||
A = remove_element(LTo, StateData#state.pres_a),
|
A = remove_element(LTo, StateData#state.pres_a),
|
||||||
StateData#state{pres_i = I,
|
StateData#state{pres_i = I,
|
||||||
@ -1586,52 +1587,59 @@ presence_track(From, To, Packet, StateData) ->
|
|||||||
ejabberd_hooks:run(roster_out_subscription,
|
ejabberd_hooks:run(roster_out_subscription,
|
||||||
Server,
|
Server,
|
||||||
[User, Server, To, subscribe]),
|
[User, Server, To, subscribe]),
|
||||||
ejabberd_router:route(jlib:jid_remove_resource(From), To, Packet),
|
check_privacy_route(From, StateData, jlib:jid_remove_resource(From),
|
||||||
|
To, Packet),
|
||||||
StateData;
|
StateData;
|
||||||
"subscribed" ->
|
"subscribed" ->
|
||||||
ejabberd_hooks:run(roster_out_subscription,
|
ejabberd_hooks:run(roster_out_subscription,
|
||||||
Server,
|
Server,
|
||||||
[User, Server, To, subscribed]),
|
[User, Server, To, subscribed]),
|
||||||
ejabberd_router:route(jlib:jid_remove_resource(From), To, Packet),
|
check_privacy_route(From, StateData, jlib:jid_remove_resource(From),
|
||||||
|
To, Packet),
|
||||||
StateData;
|
StateData;
|
||||||
"unsubscribe" ->
|
"unsubscribe" ->
|
||||||
ejabberd_hooks:run(roster_out_subscription,
|
ejabberd_hooks:run(roster_out_subscription,
|
||||||
Server,
|
Server,
|
||||||
[User, Server, To, unsubscribe]),
|
[User, Server, To, unsubscribe]),
|
||||||
ejabberd_router:route(jlib:jid_remove_resource(From), To, Packet),
|
check_privacy_route(From, StateData, jlib:jid_remove_resource(From),
|
||||||
|
To, Packet),
|
||||||
StateData;
|
StateData;
|
||||||
"unsubscribed" ->
|
"unsubscribed" ->
|
||||||
ejabberd_hooks:run(roster_out_subscription,
|
ejabberd_hooks:run(roster_out_subscription,
|
||||||
Server,
|
Server,
|
||||||
[User, Server, To, unsubscribed]),
|
[User, Server, To, unsubscribed]),
|
||||||
ejabberd_router:route(jlib:jid_remove_resource(From), To, Packet),
|
check_privacy_route(From, StateData, jlib:jid_remove_resource(From),
|
||||||
|
To, Packet),
|
||||||
StateData;
|
StateData;
|
||||||
"error" ->
|
"error" ->
|
||||||
ejabberd_router:route(From, To, Packet),
|
check_privacy_route(From, StateData, From, To, Packet),
|
||||||
StateData;
|
StateData;
|
||||||
"probe" ->
|
"probe" ->
|
||||||
ejabberd_router:route(From, To, Packet),
|
check_privacy_route(From, StateData, From, To, Packet),
|
||||||
StateData;
|
StateData;
|
||||||
_ ->
|
_ ->
|
||||||
case ejabberd_hooks:run_fold(
|
check_privacy_route(From, StateData, From, To, Packet),
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, To, Packet},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
|
||||||
ok;
|
|
||||||
allow ->
|
|
||||||
ejabberd_router:route(From, To, Packet)
|
|
||||||
end,
|
|
||||||
I = remove_element(LTo, StateData#state.pres_i),
|
I = remove_element(LTo, StateData#state.pres_i),
|
||||||
A = ?SETS:add_element(LTo, StateData#state.pres_a),
|
A = ?SETS:add_element(LTo, StateData#state.pres_a),
|
||||||
StateData#state{pres_i = I,
|
StateData#state{pres_i = I,
|
||||||
pres_a = A}
|
pres_a = A}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
check_privacy_route(From, StateData, FromRoute, To, Packet) ->
|
||||||
|
case ejabberd_hooks:run_fold(
|
||||||
|
privacy_check_packet, StateData#state.server,
|
||||||
|
allow,
|
||||||
|
[StateData#state.user,
|
||||||
|
StateData#state.server,
|
||||||
|
StateData#state.privacy_list,
|
||||||
|
{From, To, Packet},
|
||||||
|
out]) of
|
||||||
|
deny ->
|
||||||
|
ok;
|
||||||
|
allow ->
|
||||||
|
ejabberd_router:route(FromRoute, To, Packet)
|
||||||
|
end.
|
||||||
|
|
||||||
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
||||||
lists:foreach(fun(JID) ->
|
lists:foreach(fun(JID) ->
|
||||||
FJID = jlib:make_jid(JID),
|
FJID = jlib:make_jid(JID),
|
||||||
|
@ -555,9 +555,12 @@ get_user_list(_, User, Server) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
%% From is the sender, To is the destination.
|
||||||
|
%% If Dir = out, User@Server is the sender account (From).
|
||||||
|
%% If Dir = in, User@Server is the destination account (To).
|
||||||
check_packet(_, User, Server,
|
check_packet(_, User, Server,
|
||||||
#userlist{list = List, needdb = NeedDb},
|
#userlist{list = List, needdb = NeedDb},
|
||||||
{From, To, {xmlelement, PName, _, _}},
|
{From, To, {xmlelement, PName, Attrs, _}},
|
||||||
Dir) ->
|
Dir) ->
|
||||||
case List of
|
case List of
|
||||||
[] ->
|
[] ->
|
||||||
@ -566,50 +569,39 @@ check_packet(_, User, Server,
|
|||||||
PType = case PName of
|
PType = case PName of
|
||||||
"message" -> message;
|
"message" -> message;
|
||||||
"iq" -> iq;
|
"iq" -> iq;
|
||||||
"presence" -> presence
|
"presence" ->
|
||||||
|
case xml:get_attr_s("type", Attrs) of
|
||||||
|
%% notification
|
||||||
|
"" -> presence;
|
||||||
|
"unavailable" -> presence;
|
||||||
|
%% subscribe, subscribed, unsubscribe,
|
||||||
|
%% unsubscribed, error, probe, or other
|
||||||
|
_ -> other
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
case {PType, Dir} of
|
PType2 = case {PType, Dir} of
|
||||||
{message, in} ->
|
{message, in} -> message;
|
||||||
LJID = jlib:jid_tolower(From),
|
{iq, in} -> iq;
|
||||||
{Subscription, Groups} =
|
{presence, in} -> presence_in;
|
||||||
case NeedDb of
|
{presence, out} -> presence_out;
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
{_, _} -> other
|
||||||
false -> {[], []}
|
end,
|
||||||
end,
|
LJID = case Dir of
|
||||||
check_packet_aux(List, message,
|
in -> jlib:jid_tolower(From);
|
||||||
LJID, Subscription, Groups);
|
out -> jlib:jid_tolower(To)
|
||||||
{iq, in} ->
|
end,
|
||||||
LJID = jlib:jid_tolower(From),
|
{Subscription, Groups} =
|
||||||
{Subscription, Groups} =
|
case NeedDb of
|
||||||
case NeedDb of
|
true -> ejabberd_hooks:run_fold(roster_get_jid_info,
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
jlib:nameprep(Server),
|
||||||
false -> {[], []}
|
{none, []},
|
||||||
end,
|
[User, Server, LJID]);
|
||||||
check_packet_aux(List, iq,
|
false -> {[], []}
|
||||||
LJID, Subscription, Groups);
|
end,
|
||||||
{presence, in} ->
|
check_packet_aux(List, PType2, LJID, Subscription, Groups)
|
||||||
LJID = jlib:jid_tolower(From),
|
|
||||||
{Subscription, Groups} =
|
|
||||||
case NeedDb of
|
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
|
||||||
false -> {[], []}
|
|
||||||
end,
|
|
||||||
check_packet_aux(List, presence_in,
|
|
||||||
LJID, Subscription, Groups);
|
|
||||||
{presence, out} ->
|
|
||||||
LJID = jlib:jid_tolower(To),
|
|
||||||
{Subscription, Groups} =
|
|
||||||
case NeedDb of
|
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
|
||||||
false -> {[], []}
|
|
||||||
end,
|
|
||||||
check_packet_aux(List, presence_out,
|
|
||||||
LJID, Subscription, Groups);
|
|
||||||
_ ->
|
|
||||||
allow
|
|
||||||
end
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% Ptype = mesage | iq | presence_in | presence_out | other
|
||||||
check_packet_aux([], _PType, _JID, _Subscription, _Groups) ->
|
check_packet_aux([], _PType, _JID, _Subscription, _Groups) ->
|
||||||
allow;
|
allow;
|
||||||
check_packet_aux([Item | List], PType, JID, Subscription, Groups) ->
|
check_packet_aux([Item | List], PType, JID, Subscription, Groups) ->
|
||||||
@ -647,7 +639,9 @@ is_ptype_match(Item, PType) ->
|
|||||||
presence_in ->
|
presence_in ->
|
||||||
Item#listitem.match_presence_in;
|
Item#listitem.match_presence_in;
|
||||||
presence_out ->
|
presence_out ->
|
||||||
Item#listitem.match_presence_out
|
Item#listitem.match_presence_out;
|
||||||
|
other ->
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user