diff options
Diffstat (limited to 'src/mod_admin_extra.erl')
-rw-r--r-- | src/mod_admin_extra.erl | 130 |
1 files changed, 99 insertions, 31 deletions
diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index dae775e4..343a1a3a 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -101,89 +101,156 @@ get_commands_spec() -> desc = "Recompile and reload Erlang source code file", module = ?MODULE, function = compile, args = [{file, string}], - result = {res, rescode}}, + args_example = ["/home/me/srcs/ejabberd/mod_example.erl"], + args_desc = ["Filename of erlang source file to compile"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = get_cookie, tags = [erlang], desc = "Get the Erlang cookie of this node", module = ?MODULE, function = get_cookie, args = [], - result = {cookie, string}}, + result = {cookie, string}, + result_example = "MWTAVMODFELNLSMYXPPD", + result_desc = "Erlang cookie used for authentication by ejabberd"}, #ejabberd_commands{name = remove_node, tags = [erlang], desc = "Remove an ejabberd node from Mnesia clustering config", module = ?MODULE, function = remove_node, args = [{node, string}], - result = {res, rescode}}, - + args_example = ["ejabberd@server2"], + args_desc = ["Name of erlang node to remove"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = num_active_users, tags = [accounts, stats], desc = "Get number of users active in the last days", policy = admin, module = ?MODULE, function = num_active_users, args = [{host, binary}, {days, integer}], - result = {users, integer}}, + args_example = [<<"myserver.com">>, 3], + args_desc = ["Name of host to check", "Number of days to calculate sum"], + result = {users, integer}, + result_example = 123, + result_desc = "Number of users active on given server in last n days"}, #ejabberd_commands{name = delete_old_users, tags = [accounts, purge], desc = "Delete users that didn't log in last days, or that never logged", module = ?MODULE, function = delete_old_users, args = [{days, integer}], - result = {res, restuple}}, + args_example = [30], + args_desc = ["Last login age in days of accounts that should be removed"], + result = {res, restuple}, + result_example = {ok, <<"Deleted 2 users: [\"oldman@myserver.com\", \"test@myserver.com\"]">>}, + result_desc = "Result tuple"}, #ejabberd_commands{name = delete_old_users_vhost, tags = [accounts, purge], desc = "Delete users that didn't log in last days in vhost, or that never logged", module = ?MODULE, function = delete_old_users_vhost, args = [{host, binary}, {days, integer}], - result = {res, restuple}}, - + args_example = [<<"myserver.com">>, 30], + args_desc = ["Server name", + "Last login age in days of accounts that should be removed"], + result = {res, restuple}, + result_example = {ok, <<"Deleted 2 users: [\"oldman@myserver.com\", \"test@myserver.com\"]">>}, + result_desc = "Result tuple"}, #ejabberd_commands{name = check_account, tags = [accounts], desc = "Check if an account exists or not", module = ejabberd_auth, function = is_user_exists, args = [{user, binary}, {host, binary}], - result = {res, rescode}}, + args_example = [<<"peter">>, <<"myserver.com">>], + args_desc = ["User name to check", "Server to check"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = check_password, tags = [accounts], desc = "Check if a password is correct", module = ejabberd_auth, function = check_password, args = [{user, binary}, {host, binary}, {password, binary}], - result = {res, rescode}}, + args_example = [<<"peter">>, <<"myserver.com">>, <<"secret">>], + args_desc = ["User name to check", "Server to check", "Password to check"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = check_password_hash, tags = [accounts], desc = "Check if the password hash is correct", longdesc = "Allowed hash methods: md5, sha.", module = ?MODULE, function = check_password_hash, - args = [{user, binary}, {host, binary}, {passwordhash, string}, {hashmethod, string}], - result = {res, rescode}}, + args = [{user, binary}, {host, binary}, {passwordhash, string}, + {hashmethod, string}], + args_example = [<<"peter">>, <<"myserver.com">>, + <<"5ebe2294ecd0e0f08eab7690d2a6ee69">>, <<"md5">>], + args_desc = ["User name to check", "Server to check", + "Password's hash value", "Name of hash method"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = change_password, tags = [accounts], desc = "Change the password of an account", module = ?MODULE, function = set_password, args = [{user, binary}, {host, binary}, {newpass, binary}], - result = {res, rescode}}, + args_example = [<<"peter">>, <<"myserver.com">>, <<"blank">>], + args_desc = ["User name", "Server name", + "New password for user"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = ban_account, tags = [accounts], desc = "Ban an account: kick sessions and set random password", module = ?MODULE, function = ban_account, args = [{user, binary}, {host, binary}, {reason, binary}], - result = {res, rescode}}, - + args_example = [<<"attacker">>, <<"myserver.com">>, <<"Spaming other users">>], + args_desc = ["User name to ban", "Server name", + "Reason for banning user"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = num_resources, tags = [session], desc = "Get the number of resources of a user", module = ?MODULE, function = num_resources, args = [{user, binary}, {host, binary}], - result = {resources, integer}}, + args_example = [<<"peter">>, <<"myserver.com">>], + args_desc = ["User name", "Server name"], + result = {resources, integer}, + result_example = 5, + result_desc = "Number of active resources for a user"}, #ejabberd_commands{name = resource_num, tags = [session], desc = "Resource string of a session number", module = ?MODULE, function = resource_num, args = [{user, binary}, {host, binary}, {num, integer}], - result = {resource, string}}, + args_example = [<<"peter">>, <<"myserver.com">>, 2], + args_desc = ["User name", "Server name", "ID of resource to return"], + result = {resource, string}, + result_example = <<"Psi">>, + result_desc = "Name of user resource"}, #ejabberd_commands{name = kick_session, tags = [session], desc = "Kick a user session", module = ?MODULE, function = kick_session, args = [{user, binary}, {host, binary}, {resource, binary}, {reason, binary}], - result = {res, rescode}}, + args_example = [<<"peter">>, <<"myserver.com">>, <<"Psi">>, + <<"Stuck connection">>], + args_desc = ["User name", "Server name", "User's resource", + "Reason for closing session"], + result = {res, rescode}, + result_example = ok, + result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = status_num_host, tags = [session, stats], desc = "Number of logged users with this status in host", policy = admin, module = ?MODULE, function = status_num, args = [{host, binary}, {status, binary}], - result = {users, integer}}, + args_example = [<<"myserver.com">>, <<"dnd">>], + args_desc = ["Server name", "Status type to check"], + result = {users, integer}, + result_example = 23, + result_desc = "Number of connected sessions with given status type"}, #ejabberd_commands{name = status_num, tags = [session, stats], desc = "Number of logged users with this status", policy = admin, module = ?MODULE, function = status_num, args = [{status, binary}], - result = {users, integer}}, + args_example = [<<"dnd">>], + args_desc = ["Status type to check"], + result = {users, integer}, + result_example = 23, + result_desc = "Number of connected sessions with given status type"}, #ejabberd_commands{name = status_list_host, tags = [session], desc = "List of users logged in host with their statuses", module = ?MODULE, function = status_list, @@ -464,7 +531,7 @@ get_commands_spec() -> tags = [offline], desc = "Get the number of unread offline messages", policy = user, - module = mod_offline, function = get_queue_length, + module = mod_offline, function = count_offline_messages, args = [], result = {res, integer}}, #ejabberd_commands{name = send_message, tags = [stanza], @@ -794,7 +861,8 @@ connected_users_info() -> PI when is_integer(PI) -> PI; _ -> nil end, - {[U, $@, S, $/, R], atom_to_list(Conn), IPS, Port, PriorityI, NodeS, Uptime} + {binary_to_list(<<U/binary, $@, S/binary, $/, R/binary>>), + atom_to_list(Conn), IPS, Port, PriorityI, NodeS, Uptime} end, USRIs). @@ -912,7 +980,7 @@ get_vcard_content(User, Server, Data) -> [_|_] -> case get_vcard(Data, A1) of [false] -> throw(error_no_value_found_in_vcard); - ElemList -> ?DEBUG("ELS ~p", [ElemList]), [xml:get_tag_cdata(Elem) || Elem <- ElemList] + ElemList -> ?DEBUG("ELS ~p", [ElemList]), [fxml:get_tag_cdata(Elem) || Elem <- ElemList] end; [] -> throw(error_no_vcard_found) @@ -933,7 +1001,7 @@ get_vcard([Data], A1) -> get_subtag(A1, Data). get_subtag(Xmlelement, Name) -> - [xml:get_subtag(Xmlelement, Name)]. + [fxml:get_subtag(Xmlelement, Name)]. set_vcard_content(User, Server, Data, SomeContent) -> ContentList = case SomeContent of @@ -963,7 +1031,7 @@ set_vcard_content(User, Server, Data, SomeContent) -> take_vcard_tel(TelType, [{xmlel, <<"TEL">>, _, SubEls}=OldEl | OldEls], NewEls, Taken) -> {Taken2, NewEls2} = case lists:keymember(TelType, 2, SubEls) of - true -> {xml:get_subtag(OldEl, <<"NUMBER">>), NewEls}; + true -> {fxml:get_subtag(OldEl, <<"NUMBER">>), NewEls}; false -> {Taken, [OldEl | NewEls]} end, take_vcard_tel(TelType, OldEls, NewEls2, Taken2); @@ -1126,7 +1194,7 @@ push_roster_item(LU, LS, R, U, S, Action) -> ejabberd_sm:route(LJID, LJID, BroadcastEl), Item = build_roster_item(U, S, Action), ResIQ = build_iq_roster_push(Item), - ejabberd_router:route(LJID, LJID, ResIQ). + ejabberd_router:route(jid:remove_resource(LJID), LJID, ResIQ). build_roster_item(U, S, {add, Nick, Subs, Group}) -> {xmlel, <<"item">>, @@ -1206,10 +1274,10 @@ private_get(Username, Host, Element, Ns) -> [{xmlel, <<"query">>, [{<<"xmlns">>, ?NS_PRIVATE}], [SubEl]}] = ResIq#iq.sub_el, - binary_to_list(xml:element_to_binary(SubEl)). + binary_to_list(fxml:element_to_binary(SubEl)). private_set(Username, Host, ElementString) -> - case xml_stream:parse_element(ElementString) of + case fxml_stream:parse_element(ElementString) of {error, Error} -> io:format("Error found parsing the element:~n ~p~nError: ~p~n", [ElementString, Error]), @@ -1333,7 +1401,7 @@ build_packet(Type, Subject, Body) -> }. send_stanza(FromString, ToString, Stanza) -> - case xml_stream:parse_element(Stanza) of + case fxml_stream:parse_element(Stanza) of {error, Error} -> {error, Error}; XmlEl -> @@ -1344,7 +1412,7 @@ send_stanza(FromString, ToString, Stanza) -> end. send_stanza_c2s(Username, Host, Resource, Stanza) -> - case {xml_stream:parse_element(Stanza), + case {fxml_stream:parse_element(Stanza), ejabberd_sm:get_session_pid(Username, Host, Resource)} of {{error, Error}, _} -> @@ -1358,7 +1426,7 @@ send_stanza_c2s(Username, Host, Resource, Stanza) -> privacy_set(Username, Host, QueryS) -> From = jid:make(Username, Host, <<"">>), To = jid:make(<<"">>, Host, <<"">>), - QueryEl = xml_stream:parse_element(QueryS), + QueryEl = fxml_stream:parse_element(QueryS), StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]}, IQ = jlib:iq_query_info(StanzaEl), ejabberd_hooks:run_fold( |