mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
*** empty log message ***
SVN Revision: 53
This commit is contained in:
parent
275b31b0cf
commit
9a3a723f1b
2
TODO
2
TODO
@ -8,4 +8,4 @@ iq:browse(?)
|
|||||||
SRV DNS records
|
SRV DNS records
|
||||||
karma
|
karma
|
||||||
SSL
|
SSL
|
||||||
JEP-62,63
|
JEP-62,63 (?)
|
||||||
|
@ -11,7 +11,6 @@ ERLSHLIBS = expat_erl.so
|
|||||||
|
|
||||||
all: $(ERLSHLIBS)
|
all: $(ERLSHLIBS)
|
||||||
erl -s make all report -noinput -s erlang halt
|
erl -s make all report -noinput -s erlang halt
|
||||||
etags *.erl
|
|
||||||
|
|
||||||
$(ERLSHLIBS): %.so: %.c
|
$(ERLSHLIBS): %.so: %.c
|
||||||
gcc -Wall $(INCLUDES) $(LIBDIRS) \
|
gcc -Wall $(INCLUDES) $(LIBDIRS) \
|
||||||
@ -26,3 +25,7 @@ clean:
|
|||||||
|
|
||||||
Makefile.inc:
|
Makefile.inc:
|
||||||
./configure
|
./configure
|
||||||
|
|
||||||
|
TAGS:
|
||||||
|
etags *.erl
|
||||||
|
|
||||||
|
21
src/acl.erl
21
src/acl.erl
@ -14,13 +14,24 @@
|
|||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
|
-record(acl, {aclname, aclspec}).
|
||||||
|
|
||||||
start() ->
|
start() ->
|
||||||
ets:new(acls, [bag, named_table, public]),
|
%ets:new(acls, [bag, named_table, public]),
|
||||||
|
mnesia:create_table(acl,
|
||||||
|
[{disc_copies, [node()]},
|
||||||
|
{type, bag},
|
||||||
|
{attributes, record_info(fields, acl)}]),
|
||||||
|
mnesia:add_table_copy(acl, node(), ram_copies),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
||||||
add(ACLName, ACLData) ->
|
add(ACLName, ACLSpec) ->
|
||||||
ets:insert(acls, {ACLName, ACLData}).
|
F = fun() ->
|
||||||
|
mnesia:write(#acl{aclname = ACLName, aclspec = ACLSpec})
|
||||||
|
end,
|
||||||
|
mnesia:transaction(F).
|
||||||
|
%ets:insert(acls, {ACLName, ACLData}).
|
||||||
|
|
||||||
match_rule(Rule, JID) ->
|
match_rule(Rule, JID) ->
|
||||||
case ejabberd_config:get_global_option({access, Rule}) of
|
case ejabberd_config:get_global_option({access, Rule}) of
|
||||||
@ -42,7 +53,7 @@ match_acls([{Access, ACL} | ACLs], JID) ->
|
|||||||
|
|
||||||
match_acl(ACL, JID) ->
|
match_acl(ACL, JID) ->
|
||||||
{User, Server, Resource} = jlib:jid_tolower(JID),
|
{User, Server, Resource} = jlib:jid_tolower(JID),
|
||||||
lists:any(fun({_, Spec}) ->
|
lists:any(fun(#acl{aclspec = Spec}) ->
|
||||||
case Spec of
|
case Spec of
|
||||||
all ->
|
all ->
|
||||||
true;
|
true;
|
||||||
@ -53,4 +64,4 @@ match_acl(ACL, JID) ->
|
|||||||
{server, S} ->
|
{server, S} ->
|
||||||
S == Server
|
S == Server
|
||||||
end
|
end
|
||||||
end, ets:lookup(acls, ACL)).
|
end, ets:lookup(acl, ACL)).
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
{8888, ejabberd_service, start, ["asd.e.localhost", "asdqwe"]}
|
{8888, ejabberd_service, start, ["asd.e.localhost", "asdqwe"]}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
% This value (5569) is only for debugging, must be 5269
|
||||||
|
{outgoing_s2s_port, 5569}.
|
||||||
|
|
||||||
{modules, [
|
{modules, [
|
||||||
{mod_register, []},
|
{mod_register, []},
|
||||||
{mod_roster, []},
|
{mod_roster, []},
|
||||||
|
@ -185,17 +185,11 @@ get_password_s(User) ->
|
|||||||
|
|
||||||
is_user_exists(User) ->
|
is_user_exists(User) ->
|
||||||
LUser = jlib:tolower(User),
|
LUser = jlib:tolower(User),
|
||||||
F = fun() ->
|
case catch mnesia:dirty_read({passwd, LUser}) of
|
||||||
case mnesia:read({passwd, LUser}) of
|
|
||||||
[] ->
|
[] ->
|
||||||
false;
|
false;
|
||||||
[_] ->
|
[_] ->
|
||||||
true
|
true;
|
||||||
end
|
|
||||||
end,
|
|
||||||
case mnesia:transaction(F) of
|
|
||||||
{atomic, Res} ->
|
|
||||||
Res;
|
|
||||||
_ ->
|
_ ->
|
||||||
false
|
false
|
||||||
end.
|
end.
|
||||||
|
@ -286,12 +286,14 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
?DEBUG("broadcast!!!!!!!!!!!~n~p~n", [Els]),
|
?DEBUG("broadcast!!!!!!!!!!!~n~p~n", [Els]),
|
||||||
NewSt = case Els of
|
NewSt = case Els of
|
||||||
[{item, IJID, ISubscription}] ->
|
[{item, IJID, ISubscription}] ->
|
||||||
|
{false, Attrs,
|
||||||
roster_change(IJID, ISubscription,
|
roster_change(IJID, ISubscription,
|
||||||
StateData);
|
StateData)};
|
||||||
|
[{exit, Reason}] ->
|
||||||
|
{exit, Attrs, Reason};
|
||||||
_ ->
|
_ ->
|
||||||
StateData
|
{false, Attrs, StateData}
|
||||||
end,
|
end;
|
||||||
{false, Attrs, NewSt};
|
|
||||||
"iq" ->
|
"iq" ->
|
||||||
IQ = jlib:iq_query_info(Packet),
|
IQ = jlib:iq_query_info(Packet),
|
||||||
case IQ of
|
case IQ of
|
||||||
@ -310,16 +312,19 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
_ ->
|
_ ->
|
||||||
{true, Attrs, StateData}
|
{true, Attrs, StateData}
|
||||||
end,
|
end,
|
||||||
if Pass ->
|
if
|
||||||
|
Pass == exit ->
|
||||||
|
{stop, normal, StateData};
|
||||||
|
Pass ->
|
||||||
Attrs2 = jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
Attrs2 = jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||||
jlib:jid_to_string(To),
|
jlib:jid_to_string(To),
|
||||||
NewAttrs),
|
NewAttrs),
|
||||||
Text = xml:element_to_string({xmlelement, Name, Attrs2, Els}),
|
Text = xml:element_to_string({xmlelement, Name, Attrs2, Els}),
|
||||||
send_text(StateData#state.sender, Text);
|
send_text(StateData#state.sender, Text),
|
||||||
|
{next_state, StateName, NewState};
|
||||||
true ->
|
true ->
|
||||||
ok
|
{next_state, StateName, NewState}
|
||||||
end,
|
end.
|
||||||
{next_state, StateName, NewState}.
|
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
%% Func: terminate/3
|
%% Func: terminate/3
|
||||||
|
@ -13,7 +13,9 @@
|
|||||||
-export([start/0, init/0]).
|
-export([start/0, init/0]).
|
||||||
|
|
||||||
-export([register_iq_handler/3,
|
-export([register_iq_handler/3,
|
||||||
register_iq_handler/4]).
|
register_iq_handler/4,
|
||||||
|
unregister_iq_handler/1
|
||||||
|
]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
@ -41,6 +43,18 @@ loop(State) ->
|
|||||||
{register_iq_handler, XMLNS, Module, Function, Opts} ->
|
{register_iq_handler, XMLNS, Module, Function, Opts} ->
|
||||||
ets:insert(State#state.iqtable, {XMLNS, Module, Function, Opts}),
|
ets:insert(State#state.iqtable, {XMLNS, Module, Function, Opts}),
|
||||||
mod_disco:register_feature(XMLNS),
|
mod_disco:register_feature(XMLNS),
|
||||||
|
loop(State);
|
||||||
|
{unregister_iq_handler, XMLNS} ->
|
||||||
|
case ets:lookup(State#state.iqtable, XMLNS) of
|
||||||
|
[{_, Module, Function, Opts}] ->
|
||||||
|
gen_iq_handler:stop_iq_handler(Module, Function, Opts);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
|
ets:delete(State#state.iqtable, XMLNS),
|
||||||
|
mod_disco:unregister_feature(XMLNS),
|
||||||
|
loop(State);
|
||||||
|
_ ->
|
||||||
loop(State)
|
loop(State)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -117,3 +131,7 @@ register_iq_handler(XMLNS, Module, Fun) ->
|
|||||||
|
|
||||||
register_iq_handler(XMLNS, Module, Fun, Opts) ->
|
register_iq_handler(XMLNS, Module, Fun, Opts) ->
|
||||||
ejabberd_local ! {register_iq_handler, XMLNS, Module, Fun, Opts}.
|
ejabberd_local ! {register_iq_handler, XMLNS, Module, Fun, Opts}.
|
||||||
|
|
||||||
|
unregister_iq_handler(XMLNS) ->
|
||||||
|
ejabberd_local ! {unregister_iq_handler, XMLNS}.
|
||||||
|
|
||||||
|
@ -97,7 +97,8 @@ init([From, Server, Type]) ->
|
|||||||
%% {stop, Reason, NewStateData}
|
%% {stop, Reason, NewStateData}
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
open_socket(init, StateData) ->
|
open_socket(init, StateData) ->
|
||||||
case gen_tcp:connect(StateData#state.server, 5569,
|
case gen_tcp:connect(StateData#state.server,
|
||||||
|
ejabberd_config:get_local_option(outgoing_s2s_port),
|
||||||
[binary, {packet, 0}]) of
|
[binary, {packet, 0}]) of
|
||||||
{ok, Socket} ->
|
{ok, Socket} ->
|
||||||
XMLStreamPid = xml_stream:start(self()),
|
XMLStreamPid = xml_stream:start(self()),
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
dirty_get_sessions_list/0,
|
dirty_get_sessions_list/0,
|
||||||
dirty_get_my_sessions_list/0,
|
dirty_get_my_sessions_list/0,
|
||||||
register_iq_handler/3,
|
register_iq_handler/3,
|
||||||
register_iq_handler/4]).
|
register_iq_handler/4,
|
||||||
|
unregister_iq_handler/1
|
||||||
|
]).
|
||||||
|
|
||||||
-include_lib("mnemosyne/include/mnemosyne.hrl").
|
-include_lib("mnemosyne/include/mnemosyne.hrl").
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -77,6 +79,16 @@ loop() ->
|
|||||||
{register_iq_handler, XMLNS, Module, Function, Opts} ->
|
{register_iq_handler, XMLNS, Module, Function, Opts} ->
|
||||||
ets:insert(sm_iqtable, {XMLNS, Module, Function, Opts}),
|
ets:insert(sm_iqtable, {XMLNS, Module, Function, Opts}),
|
||||||
loop();
|
loop();
|
||||||
|
{unregister_iq_handler, XMLNS} ->
|
||||||
|
case ets:lookup(sm_iqtable, XMLNS) of
|
||||||
|
[{_, Module, Function, Opts}] ->
|
||||||
|
gen_iq_handler:stop_iq_handler(Module, Function, Opts);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end,
|
||||||
|
ets:delete(sm_iqtable, XMLNS),
|
||||||
|
mod_disco:unregister_feature(XMLNS),
|
||||||
|
loop();
|
||||||
_ ->
|
_ ->
|
||||||
loop()
|
loop()
|
||||||
end.
|
end.
|
||||||
@ -389,3 +401,6 @@ register_iq_handler(XMLNS, Module, Fun) ->
|
|||||||
register_iq_handler(XMLNS, Module, Fun, Opts) ->
|
register_iq_handler(XMLNS, Module, Fun, Opts) ->
|
||||||
ejabberd_sm ! {register_iq_handler, XMLNS, Module, Fun, Opts}.
|
ejabberd_sm ! {register_iq_handler, XMLNS, Module, Fun, Opts}.
|
||||||
|
|
||||||
|
unregister_iq_handler(XMLNS) ->
|
||||||
|
ejabberd_sm ! {unregister_iq_handler, XMLNS}.
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
-export([start/0,
|
-export([start/0,
|
||||||
add_iq_handler/5,
|
add_iq_handler/5,
|
||||||
|
remove_iq_handler/2,
|
||||||
|
stop_iq_handler/3,
|
||||||
handle/6,
|
handle/6,
|
||||||
process_iq/5,
|
process_iq/5,
|
||||||
queue_init/2]).
|
queue_init/2]).
|
||||||
@ -33,6 +35,17 @@ add_iq_handler(Component, NS, Module, Function, Type) ->
|
|||||||
Component:register_iq_handler(NS, Module, Function, parallel)
|
Component:register_iq_handler(NS, Module, Function, parallel)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
remove_iq_handler(Component, NS) ->
|
||||||
|
Component:unregister_iq_handler(NS).
|
||||||
|
|
||||||
|
stop_iq_handler(Module, Function, Opts) ->
|
||||||
|
case Opts of
|
||||||
|
{one_queue, Pid} ->
|
||||||
|
exit(Pid, kill);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
handle(Module, Function, Opts, From, To, IQ) ->
|
handle(Module, Function, Opts, From, To, IQ) ->
|
||||||
case Opts of
|
case Opts of
|
||||||
no_queue ->
|
no_queue ->
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
|
stop/0,
|
||||||
process_local_iq/3,
|
process_local_iq/3,
|
||||||
process_sm_iq/3]).
|
process_sm_iq/3]).
|
||||||
|
|
||||||
@ -28,6 +29,10 @@ start(Opts) ->
|
|||||||
?MODULE, process_sm_iq, IQDisc),
|
?MODULE, process_sm_iq, IQDisc),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
stop() ->
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_XDATA),
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_XDATA).
|
||||||
|
|
||||||
|
|
||||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
case acl:match_rule(configure, From) of
|
case acl:match_rule(configure, From) of
|
||||||
@ -240,7 +245,7 @@ get_form(["config", "acls"], Lang) ->
|
|||||||
end,
|
end,
|
||||||
string:tokens(
|
string:tokens(
|
||||||
lists:flatten(io_lib:format("~p",
|
lists:flatten(io_lib:format("~p",
|
||||||
[ets:tab2list(acls)])),
|
[ets:tab2list(acl)])),
|
||||||
"\n"))
|
"\n"))
|
||||||
%{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}
|
%{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}
|
||||||
}
|
}
|
||||||
@ -379,6 +384,9 @@ set_form(["config", "remusers"], Lang, XData) ->
|
|||||||
fun({Var, Vals}) ->
|
fun({Var, Vals}) ->
|
||||||
case Vals of
|
case Vals of
|
||||||
["1"] ->
|
["1"] ->
|
||||||
|
ejabberd_sm ! {route, {"", "", ""}, {Var, "", ""},
|
||||||
|
{xmlelement, "broadcast", [],
|
||||||
|
[{exit, "User removed"}]}},
|
||||||
catch ejabberd_auth:remove_user(Var),
|
catch ejabberd_auth:remove_user(Var),
|
||||||
catch mod_roster:remove_user(Var),
|
catch mod_roster:remove_user(Var),
|
||||||
catch mod_offline:remove_user(Var),
|
catch mod_offline:remove_user(Var),
|
||||||
|
@ -13,11 +13,13 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
|
stop/0,
|
||||||
process_local_iq_items/3,
|
process_local_iq_items/3,
|
||||||
process_local_iq_info/3,
|
process_local_iq_info/3,
|
||||||
process_sm_iq_items/3,
|
process_sm_iq_items/3,
|
||||||
process_sm_iq_info/3,
|
process_sm_iq_info/3,
|
||||||
register_feature/1]).
|
register_feature/1,
|
||||||
|
unregister_feature/1]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("namespaces.hrl").
|
-include("namespaces.hrl").
|
||||||
@ -41,10 +43,21 @@ start(Opts) ->
|
|||||||
register_feature("presence-invisible"),
|
register_feature("presence-invisible"),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
stop() ->
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_DISCO_ITEMS),
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_DISCO_INFO),
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_DISCO_ITEMS),
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_DISCO_INFO).
|
||||||
|
|
||||||
|
|
||||||
register_feature(Feature) ->
|
register_feature(Feature) ->
|
||||||
catch ets:new(disco_features, [named_table, ordered_set, public]),
|
catch ets:new(disco_features, [named_table, ordered_set, public]),
|
||||||
ets:insert(disco_features, {Feature}).
|
ets:insert(disco_features, {Feature}).
|
||||||
|
|
||||||
|
unregister_feature(Feature) ->
|
||||||
|
catch ets:new(disco_features, [named_table, ordered_set, public]),
|
||||||
|
ets:delete(disco_features, Feature).
|
||||||
|
|
||||||
process_local_iq_items(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
process_local_iq_items(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
|
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
|
||||||
case Type of
|
case Type of
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
|
stop/0,
|
||||||
store_packet/3,
|
store_packet/3,
|
||||||
resend_offline_messages/1,
|
resend_offline_messages/1,
|
||||||
remove_user/1]).
|
remove_user/1]).
|
||||||
@ -27,6 +28,9 @@ start(_) ->
|
|||||||
{type, bag},
|
{type, bag},
|
||||||
{attributes, record_info(fields, offline_msg)}]).
|
{attributes, record_info(fields, offline_msg)}]).
|
||||||
|
|
||||||
|
stop() ->
|
||||||
|
% TODO: maybe throw error that this module can't be removed?
|
||||||
|
ok.
|
||||||
|
|
||||||
store_packet(From, To, Packet) ->
|
store_packet(From, To, Packet) ->
|
||||||
case check_event(From, To, Packet) of
|
case check_event(From, To, Packet) of
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
|
stop/0,
|
||||||
process_local_iq/3]).
|
process_local_iq/3]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -28,6 +29,9 @@ start(Opts) ->
|
|||||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_PRIVATE,
|
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_PRIVATE,
|
||||||
?MODULE, process_local_iq, IQDisc).
|
?MODULE, process_local_iq, IQDisc).
|
||||||
|
|
||||||
|
stop() ->
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_PRIVATE).
|
||||||
|
|
||||||
|
|
||||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
{User, Server, _} = From,
|
{User, Server, _} = From,
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
|
stop/0,
|
||||||
process_local_iq/3]).
|
process_local_iq/3]).
|
||||||
|
|
||||||
-include("namespaces.hrl").
|
-include("namespaces.hrl").
|
||||||
@ -22,6 +23,9 @@ start(Opts) ->
|
|||||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_STATS,
|
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_STATS,
|
||||||
?MODULE, process_local_iq, IQDisc).
|
?MODULE, process_local_iq, IQDisc).
|
||||||
|
|
||||||
|
stop() ->
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_STATS).
|
||||||
|
|
||||||
|
|
||||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
|
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
|
||||||
@ -77,7 +81,11 @@ get_local_stats(["running nodes", _], []) ->
|
|||||||
{result,
|
{result,
|
||||||
[?STAT("time/uptime"),
|
[?STAT("time/uptime"),
|
||||||
?STAT("time/cputime"),
|
?STAT("time/cputime"),
|
||||||
?STAT("users/online")
|
?STAT("users/online"),
|
||||||
|
?STAT("transactions/commited"),
|
||||||
|
?STAT("transactions/aborted"),
|
||||||
|
?STAT("transactions/restarted"),
|
||||||
|
?STAT("transactions/logged")
|
||||||
]};
|
]};
|
||||||
|
|
||||||
get_local_stats(["running nodes", ENode], Names) ->
|
get_local_stats(["running nodes", ENode], Names) ->
|
||||||
@ -159,6 +167,39 @@ get_node_stat(Node, Name) when Name == "users/online" ->
|
|||||||
Users ->
|
Users ->
|
||||||
?STATVAL(integer_to_list(length(Users)), "users")
|
?STATVAL(integer_to_list(length(Users)), "users")
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
get_node_stat(Node, Name) when Name == "transactions/commited" ->
|
||||||
|
case catch rpc:call(Node, mnesia, system_info, [transaction_commits]) of
|
||||||
|
{badrpc, Reason} ->
|
||||||
|
?STATERR("500", "Internal Server Error");
|
||||||
|
Transactions ->
|
||||||
|
?STATVAL(integer_to_list(Transactions), "transactions")
|
||||||
|
end;
|
||||||
|
|
||||||
|
get_node_stat(Node, Name) when Name == "transactions/aborted" ->
|
||||||
|
case catch rpc:call(Node, mnesia, system_info, [transaction_failures]) of
|
||||||
|
{badrpc, Reason} ->
|
||||||
|
?STATERR("500", "Internal Server Error");
|
||||||
|
Transactions ->
|
||||||
|
?STATVAL(integer_to_list(Transactions), "transactions")
|
||||||
|
end;
|
||||||
|
|
||||||
|
get_node_stat(Node, Name) when Name == "transactions/restarted" ->
|
||||||
|
case catch rpc:call(Node, mnesia, system_info, [transaction_restarts]) of
|
||||||
|
{badrpc, Reason} ->
|
||||||
|
?STATERR("500", "Internal Server Error");
|
||||||
|
Transactions ->
|
||||||
|
?STATVAL(integer_to_list(Transactions), "transactions")
|
||||||
|
end;
|
||||||
|
|
||||||
|
get_node_stat(Node, Name) when Name == "transactions/logged" ->
|
||||||
|
case catch rpc:call(Node, mnesia, system_info, [transaction_log_writes]) of
|
||||||
|
{badrpc, Reason} ->
|
||||||
|
?STATERR("500", "Internal Server Error");
|
||||||
|
Transactions ->
|
||||||
|
?STATVAL(integer_to_list(Transactions), "transactions")
|
||||||
|
end;
|
||||||
|
|
||||||
get_node_stat(_, Name) ->
|
get_node_stat(_, Name) ->
|
||||||
?STATERR("404", "Not Found").
|
?STATERR("404", "Not Found").
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
|
stop/0,
|
||||||
process_local_iq/3]).
|
process_local_iq/3]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -24,6 +25,8 @@ start(Opts) ->
|
|||||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_TIME,
|
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_TIME,
|
||||||
?MODULE, process_local_iq, IQDisc).
|
?MODULE, process_local_iq, IQDisc).
|
||||||
|
|
||||||
|
stop() ->
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_TIME).
|
||||||
|
|
||||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
case Type of
|
case Type of
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
-export([start/1,
|
-export([start/1,
|
||||||
|
stop/0,
|
||||||
process_local_iq/3]).
|
process_local_iq/3]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -25,6 +26,8 @@ start(Opts) ->
|
|||||||
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_VERSION,
|
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_VERSION,
|
||||||
?MODULE, process_local_iq, IQDisc).
|
?MODULE, process_local_iq, IQDisc).
|
||||||
|
|
||||||
|
stop() ->
|
||||||
|
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_VERSION).
|
||||||
|
|
||||||
|
|
||||||
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user