mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Merge branch '2.2.x' of gitorious.process-one.net:+ejabberd-developers/ejabberd/maincustomers into 2.2.x
This commit is contained in:
commit
92b6c12420
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,6 +18,7 @@
|
||||
/doc/version.tex
|
||||
/src/*.beam
|
||||
/src/*.so
|
||||
/src/*.so.dSYM
|
||||
/src/*/*.beam
|
||||
/src/*/Makefile
|
||||
/src/Makefile
|
||||
|
@ -2,7 +2,7 @@
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Ejabberd 2.1.6 Developers Guide
|
||||
<TITLE>Ejabberd 2.1.x Developers Guide
|
||||
</TITLE>
|
||||
|
||||
<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
@ -49,7 +49,7 @@ TD P{margin:0px;}
|
||||
<!--HEVEA command line is: /usr/bin/hevea -fix -pedantic dev.tex -->
|
||||
<!--CUT DEF section 1 --><P><A NAME="titlepage"></A>
|
||||
|
||||
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.6 Developers Guide</H1><H3 CLASS="titlerest">Alexey Shchepin<BR>
|
||||
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.x Developers Guide</H1><H3 CLASS="titlerest">Alexey Shchepin<BR>
|
||||
<A HREF="mailto:alexey@sevcom.net"><TT>mailto:alexey@sevcom.net</TT></A><BR>
|
||||
<A HREF="xmpp:aleksey@jabber.ru"><TT>xmpp:aleksey@jabber.ru</TT></A></H3></TD></TR>
|
||||
</TABLE><DIV CLASS="center">
|
||||
|
@ -2,7 +2,7 @@
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Ejabberd 2.1.6 Feature Sheet
|
||||
<TITLE>Ejabberd 2.1.x Feature Sheet
|
||||
</TITLE>
|
||||
|
||||
<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
@ -50,7 +50,7 @@ SPAN{width:20%; float:right; text-align:left; margin-left:auto;}
|
||||
<!--HEVEA command line is: /usr/bin/hevea -fix -pedantic features.tex -->
|
||||
<!--CUT DEF section 1 --><P><A NAME="titlepage"></A>
|
||||
|
||||
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.6 Feature Sheet</H1><H3 CLASS="titlerest">Sander Devrieze<BR>
|
||||
</P><TABLE CLASS="title"><TR><TD><H1 CLASS="titlemain">Ejabberd 2.1.x Feature Sheet</H1><H3 CLASS="titlerest">Sander Devrieze<BR>
|
||||
<A HREF="mailto:s.devrieze@pandora.be"><TT>mailto:s.devrieze@pandora.be</TT></A><BR>
|
||||
<A HREF="xmpp:sander@devrieze.dyndns.org"><TT>xmpp:sander@devrieze.dyndns.org</TT></A></H3></TD></TR>
|
||||
</TABLE><DIV CLASS="center">
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
ejabberd 2.1.6
|
||||
ejabberd 2.1.x
|
||||
|
||||
Installation and Operation Guide
|
||||
|
||||
@ -76,7 +76,7 @@ BLOCKQUOTE.figure DIV.center DIV.center HR{display:none;}
|
||||
<HR SIZE=2><BR>
|
||||
<BR>
|
||||
|
||||
<TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP> <FONT SIZE=6><B>ejabberd 2.1.6 </B></FONT></TD></TR>
|
||||
<TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=right NOWRAP> <FONT SIZE=6><B>ejabberd 2.1.x </B></FONT></TD></TR>
|
||||
<TR><TD ALIGN=right NOWRAP> </TD></TR>
|
||||
<TR><TD ALIGN=right NOWRAP> <FONT SIZE=6>Installation and Operation Guide</FONT></TD></TR>
|
||||
</TABLE><BR>
|
||||
|
@ -1,2 +1,2 @@
|
||||
% ejabberd version (automatically generated).
|
||||
\newcommand{\version}{2.1.6}
|
||||
\newcommand{\version}{2.1.x}
|
||||
|
@ -1783,7 +1783,7 @@ change_shaper(StateData, JID) ->
|
||||
|
||||
send_text(StateData, Text) when StateData#state.xml_socket ->
|
||||
?DEBUG("Send Text on stream = ~p", [lists:flatten(Text)]),
|
||||
(StateData#state.sockmod):send_xml(StateData#state.socket,
|
||||
(StateData#state.sockmod):send_xml(StateData#state.socket,
|
||||
{xmlstreamraw, Text});
|
||||
send_text(StateData, Text) ->
|
||||
?DEBUG("Send XML on stream = ~p", [Text]),
|
||||
@ -2092,37 +2092,33 @@ presence_update(From, Packet, StateData) ->
|
||||
StateData#state.pres_invis,
|
||||
?DEBUG("from unavail = ~p~n", [FromUnavail]),
|
||||
NewState =
|
||||
NewStateData = StateData#state{pres_last = Packet,
|
||||
pres_invis = false,
|
||||
pres_timestamp = Timestamp},
|
||||
if
|
||||
FromUnavail ->
|
||||
ejabberd_hooks:run(user_available_hook,
|
||||
StateData#state.server,
|
||||
[StateData#state.jid]),
|
||||
NewStateData#state.server,
|
||||
[NewStateData#state.jid]),
|
||||
if NewPriority >= 0 ->
|
||||
resend_offline_messages(StateData),
|
||||
resend_subscription_requests(StateData);
|
||||
resend_offline_messages(NewStateData),
|
||||
resend_subscription_requests(NewStateData);
|
||||
true ->
|
||||
ok
|
||||
end,
|
||||
presence_broadcast_first(
|
||||
From, StateData#state{pres_last = Packet,
|
||||
pres_invis = false,
|
||||
pres_timestamp = Timestamp
|
||||
}, Packet);
|
||||
presence_broadcast_first(From, NewStateData, Packet);
|
||||
true ->
|
||||
presence_broadcast_to_trusted(StateData,
|
||||
presence_broadcast_to_trusted(NewStateData,
|
||||
From,
|
||||
StateData#state.pres_f,
|
||||
StateData#state.pres_a,
|
||||
NewStateData#state.pres_f,
|
||||
NewStateData#state.pres_a,
|
||||
Packet),
|
||||
if OldPriority < 0, NewPriority >= 0 ->
|
||||
resend_offline_messages(StateData);
|
||||
resend_offline_messages(NewStateData);
|
||||
true ->
|
||||
ok
|
||||
end,
|
||||
StateData#state{pres_last = Packet,
|
||||
pres_invis = false,
|
||||
pres_timestamp = Timestamp
|
||||
}
|
||||
NewStateData
|
||||
end,
|
||||
NewState
|
||||
end.
|
||||
@ -2440,11 +2436,13 @@ resend_offline_messages(StateData) ->
|
||||
jlib:jid_to_string(To),
|
||||
Attrs),
|
||||
FixedPacket = {xmlelement, Name, Attrs2, Els},
|
||||
send_element(StateData, FixedPacket),
|
||||
ejabberd_hooks:run(user_receive_packet,
|
||||
StateData#state.server,
|
||||
[StateData#state.debug, StateData#state.jid,
|
||||
From, To, FixedPacket]);
|
||||
%% Use route instead of send_element to go through standard workflow
|
||||
ejabberd_router:route(From, To, Packet);
|
||||
%% send_element(StateData, FixedPacket),
|
||||
%% ejabberd_hooks:run(user_receive_packet,
|
||||
%% StateData#state.server,
|
||||
%% [StateData#state.jid,
|
||||
%% From, To, FixedPacket]);
|
||||
true ->
|
||||
ok
|
||||
end
|
||||
|
@ -415,6 +415,7 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
|
||||
end
|
||||
end;
|
||||
drop ->
|
||||
?DEBUG("packet dropped~n", []),
|
||||
ok
|
||||
end.
|
||||
|
||||
|
@ -254,7 +254,7 @@ open_socket(init, StateData) ->
|
||||
wait_before_reconnect(StateData)
|
||||
end
|
||||
end;
|
||||
open_socket(stop, StateData) ->
|
||||
open_socket(closed, StateData) ->
|
||||
?INFO_MSG("s2s connection: ~s -> ~s (stopped in open socket)",
|
||||
[StateData#state.myname, StateData#state.server]),
|
||||
{stop, normal, StateData};
|
||||
|
@ -803,4 +803,6 @@ ip_to_list({_,_,_,_,_,_,_,_} = Ipv6Address) ->
|
||||
inet_parse:ntoa(Ipv6Address);
|
||||
%% This function clause could use inet_parse too:
|
||||
ip_to_list({A,B,C,D}) ->
|
||||
lists:flatten(io_lib:format("~w.~w.~w.~w",[A,B,C,D])).
|
||||
lists:flatten(io_lib:format("~w.~w.~w.~w",[A,B,C,D]));
|
||||
ip_to_list(IP) ->
|
||||
lists:flatten(io_lib:format("~w", [IP])).
|
||||
|
@ -110,12 +110,14 @@ offline_message(From, To, Packet) ->
|
||||
mnesia:dirty_write(Record),
|
||||
ok.
|
||||
|
||||
filter_packet({From, To, Packet}) ->
|
||||
filter_packet({From, To, {xmlelement, "message", _, _}}) ->
|
||||
{User, Server, _} = jlib:jid_tolower(From),
|
||||
case mnesia:dirty_read({autofilter, {User, Server}}) of
|
||||
[#autofilter{drop=true}] -> drop;
|
||||
[#autofilter{drop=true}] -> drop
|
||||
_ -> {From, To, Packet}
|
||||
end.
|
||||
end;
|
||||
filter_packet(OK) ->
|
||||
OK.
|
||||
|
||||
close_session(SID, JID) ->
|
||||
close_session(SID, JID, []).
|
||||
|
@ -350,7 +350,7 @@ out_subscription(UserFrom, ServerFrom, JIDTo, unsubscribed) ->
|
||||
|
||||
%% Remove pending out subscription
|
||||
#jid{luser = UserTo, lserver = ServerTo} = JIDTo,
|
||||
JIDFrom = jlib:make_jid(UserFrom, UserTo, ""),
|
||||
JIDFrom = jlib:make_jid(UserFrom, ServerFrom, ""),
|
||||
Mod:out_subscription(UserTo, ServerTo, JIDFrom, unsubscribe),
|
||||
|
||||
%% Remove pending in subscription
|
||||
|
@ -30,18 +30,12 @@
|
||||
%%% Exported functions
|
||||
%%%
|
||||
|
||||
-spec start_link() -> {'ok', pid()} | {'error', term()}.
|
||||
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
-spec start() -> {'ok', pid()} | {'error', term()}.
|
||||
|
||||
start() ->
|
||||
ensure_started().
|
||||
|
||||
-spec create(term()) -> 'ok'.
|
||||
|
||||
create(Name) ->
|
||||
ensure_started(),
|
||||
case ets:member(pg2_table, {group, Name}) of
|
||||
@ -55,10 +49,6 @@ create(Name) ->
|
||||
ok
|
||||
end.
|
||||
|
||||
-type name() :: term().
|
||||
|
||||
-spec delete(name()) -> 'ok'.
|
||||
|
||||
delete(Name) ->
|
||||
ensure_started(),
|
||||
global:trans({{?MODULE, Name}, self()},
|
||||
@ -67,8 +57,6 @@ delete(Name) ->
|
||||
end),
|
||||
ok.
|
||||
|
||||
-spec join(name(), pid()) -> 'ok' | {'error', {'no_such_group', term()}}.
|
||||
|
||||
join(Name, Pid) when is_pid(Pid) ->
|
||||
ensure_started(),
|
||||
case ets:member(pg2_table, {group, Name}) of
|
||||
@ -83,8 +71,6 @@ join(Name, Pid) when is_pid(Pid) ->
|
||||
ok
|
||||
end.
|
||||
|
||||
-spec leave(name(), pid()) -> 'ok' | {'error', {'no_such_group', name()}}.
|
||||
|
||||
leave(Name, Pid) when is_pid(Pid) ->
|
||||
ensure_started(),
|
||||
case ets:member(pg2_table, {group, Name}) of
|
||||
@ -99,10 +85,6 @@ leave(Name, Pid) when is_pid(Pid) ->
|
||||
ok
|
||||
end.
|
||||
|
||||
-type get_members_ret() :: [pid()] | {'error', {'no_such_group', name()}}.
|
||||
|
||||
-spec get_members(name()) -> get_members_ret().
|
||||
|
||||
get_members(Name) ->
|
||||
ensure_started(),
|
||||
case ets:member(pg2_table, {group, Name}) of
|
||||
@ -112,8 +94,6 @@ get_members(Name) ->
|
||||
{error, {no_such_group, Name}}
|
||||
end.
|
||||
|
||||
-spec get_local_members(name()) -> get_members_ret().
|
||||
|
||||
get_local_members(Name) ->
|
||||
ensure_started(),
|
||||
case ets:member(pg2_table, {group, Name}) of
|
||||
@ -123,16 +103,10 @@ get_local_members(Name) ->
|
||||
{error, {no_such_group, Name}}
|
||||
end.
|
||||
|
||||
-spec which_groups() -> [name()].
|
||||
|
||||
which_groups() ->
|
||||
ensure_started(),
|
||||
all_groups().
|
||||
|
||||
-type gcp_error_reason() :: {'no_process', term()} | {'no_such_group', term()}.
|
||||
|
||||
-spec get_closest_pid(term()) -> pid() | {'error', gcp_error_reason()}.
|
||||
|
||||
get_closest_pid(Name) ->
|
||||
case get_local_members(Name) of
|
||||
[Pid] ->
|
||||
@ -157,8 +131,6 @@ get_closest_pid(Name) ->
|
||||
|
||||
-record(state, {}).
|
||||
|
||||
-spec init([]) -> {'ok', #state{}}.
|
||||
|
||||
init([]) ->
|
||||
Ns = nodes(),
|
||||
net_kernel:monitor_nodes(true),
|
||||
@ -169,14 +141,6 @@ init([]) ->
|
||||
pg2_table = ets:new(pg2_table, [ordered_set, protected, named_table]),
|
||||
{ok, #state{}}.
|
||||
|
||||
-type call() :: {'create', name()}
|
||||
| {'delete', name()}
|
||||
| {'join', name(), pid()}
|
||||
| {'leave', name(), pid()}.
|
||||
|
||||
-spec handle_call(call(), _, #state{}) ->
|
||||
{'reply', 'ok', #state{}}.
|
||||
|
||||
handle_call({create, Name}, _From, S) ->
|
||||
assure_group(Name),
|
||||
{reply, ok, S};
|
||||
@ -195,12 +159,6 @@ handle_call(Request, From, S) ->
|
||||
[Request, From]),
|
||||
{noreply, S}.
|
||||
|
||||
-type all_members() :: [[name(),...]].
|
||||
-type cast() :: {'exchange', node(), all_members()}
|
||||
| {'del_member', name(), pid()}.
|
||||
|
||||
-spec handle_cast(cast(), #state{}) -> {'noreply', #state{}}.
|
||||
|
||||
handle_cast({exchange, _Node, List}, S) ->
|
||||
store(List),
|
||||
{noreply, S};
|
||||
@ -208,8 +166,6 @@ handle_cast(_, S) ->
|
||||
%% Ignore {del_member, Name, Pid}.
|
||||
{noreply, S}.
|
||||
|
||||
-spec handle_info(tuple(), #state{}) -> {'noreply', #state{}}.
|
||||
|
||||
handle_info({'DOWN', MonitorRef, process, _Pid, _Info}, S) ->
|
||||
member_died(MonitorRef),
|
||||
{noreply, S};
|
||||
@ -222,8 +178,6 @@ handle_info({new_pg2, Node}, S) ->
|
||||
handle_info(_, S) ->
|
||||
{noreply, S}.
|
||||
|
||||
-spec terminate(term(), #state{}) -> 'ok'.
|
||||
|
||||
terminate(_Reason, _S) ->
|
||||
true = ets:delete(pg2_table),
|
||||
ok.
|
||||
@ -289,8 +243,9 @@ join_group(Name, Pid) ->
|
||||
try _ = ets:update_counter(pg2_table, Member_Name_Pid, {2, +1})
|
||||
catch _:_ ->
|
||||
true = ets:insert(pg2_table, {Member_Name_Pid, 1}),
|
||||
_ = [ets:insert(pg2_table, {{local_member, Name, Pid}}) ||
|
||||
node(Pid) =:= node()],
|
||||
_ = [ets:insert(pg2_table, {{local_member, Name, PidX}}) ||
|
||||
PidX <- [Pid],
|
||||
node(PidX) =:= node()],
|
||||
true = ets:insert(pg2_table, {{pid, Pid, Name}})
|
||||
end.
|
||||
|
||||
@ -301,8 +256,9 @@ leave_group(Name, Pid) ->
|
||||
if
|
||||
N =:= 0 ->
|
||||
true = ets:delete(pg2_table, {pid, Pid, Name}),
|
||||
_ = [ets:delete(pg2_table, {local_member, Name, Pid}) ||
|
||||
node(Pid) =:= node()],
|
||||
_ = [ets:delete(pg2_table, {local_member, Name, PidX}) ||
|
||||
PidX <- [Pid],
|
||||
node(PidX) =:= node()],
|
||||
true = ets:delete(pg2_table, Member_Name_Pid);
|
||||
true ->
|
||||
ok
|
||||
|
Loading…
Reference in New Issue
Block a user