25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

*** empty log message ***

SVN Revision: 46
This commit is contained in:
Alexey Shchepin 2003-01-21 20:36:55 +00:00
parent d73dfd5cbe
commit f0427ecab5
13 changed files with 278 additions and 53 deletions

1
TODO
View File

@ -3,6 +3,7 @@ admin interface
node management node management
backup management backup management
S2S timeouts S2S timeouts
rewrite S2S key validation
iq:browse(?) iq:browse(?)
SVR DNS records SVR DNS records
karma karma

View File

@ -15,14 +15,15 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
start() -> start() ->
ets:new(acls, [bag, named_table, public]). ets:new(acls, [bag, named_table, public]),
ok.
add(ACLName, ACLData) -> add(ACLName, ACLData) ->
ets:insert(acls, {ACLName, ACLData}). ets:insert(acls, {ACLName, ACLData}).
match_rule(Rule, JID) -> match_rule(Rule, JID) ->
case ejabberd_config:get_option(Rule) of case ejabberd_config:get_global_option({access, Rule}) of
undefined -> undefined ->
deny; deny;
ACLs -> ACLs ->

View File

@ -9,10 +9,10 @@
{acl, jabberorg, {server, "jabber.org"}}. {acl, jabberorg, {server, "jabber.org"}}.
{acl, aleksey, {user, "aleksey", "jabber.ru"}}. {acl, aleksey, {user, "aleksey", "jabber.ru"}}.
{disco_admin, [{allow, admin}, {access, disco_admin, [{allow, admin},
{deny, all}]}. {deny, all}]}.
{configure, [{allow, admin}]}. {access, configure, [{allow, admin}]}.
{host, "e.localhost"}. {host, "e.localhost"}.

View File

@ -45,6 +45,11 @@ loop(Port) ->
end. end.
db_init() -> db_init() ->
mnesia:create_schema([node()]), case mnesia:system_info(extra_db_nodes) of
[] ->
mnesia:create_schema([node()]);
_ ->
ok
end,
mnesia:start(), mnesia:start(),
mnesia:wait_for_tables(mnesia:system_info(tables), infinity). mnesia:wait_for_tables(mnesia:system_info(local_tables), infinity).

View File

@ -24,7 +24,7 @@
%-define(MYNAME,"e.localhost"). %-define(MYNAME,"e.localhost").
-define(MYNAME, ejabberd_config:get_option(host)). -define(MYNAME, ejabberd_config:get_global_option(host)).
-define(MSGS_DIR, "msgs"). -define(MSGS_DIR, "msgs").
-define(CONFIG_PATH, "ejabberd.cfg"). -define(CONFIG_PATH, "ejabberd.cfg").

View File

@ -22,6 +22,7 @@
check_password/4, check_password/4,
try_register/2, try_register/2,
dirty_get_registered_users/0, dirty_get_registered_users/0,
get_password_s/1,
is_user_exists/1]). is_user_exists/1]).
%% gen_server callbacks %% gen_server callbacks
@ -163,6 +164,15 @@ try_register(User, Password) ->
dirty_get_registered_users() -> dirty_get_registered_users() ->
mnesia:dirty_all_keys(passwd). mnesia:dirty_all_keys(passwd).
get_password_s(User) ->
LUser = jlib:tolower(User),
case catch mnesia:dirty_read(passwd, LUser) of
[#passwd{password = Password}] ->
Password;
_ ->
[]
end.
is_user_exists(User) -> is_user_exists(User) ->
LUser = jlib:tolower(User), LUser = jlib:tolower(User),
F = fun() -> F = fun() ->

View File

@ -10,12 +10,26 @@
-author('alexey@sevcom.net'). -author('alexey@sevcom.net').
-vsn('$Revision$ '). -vsn('$Revision$ ').
-export([start/0, load_file/1, get_option/1]). -export([start/0, load_file/1,
add_global_option/2, add_local_option/2,
get_global_option/1, get_local_option/1]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-record(config, {key, value}).
-record(local_config, {key, value}).
start() -> start() ->
ets:new(ejabberd_config, [named_table, public]), %ets:new(ejabberd_config, [named_table, public]),
mnesia:create_table(config,
[{disc_copies, [node()]},
{attributes, record_info(fields, config)}]),
mnesia:add_table_copy(config, node(), ram_copies),
mnesia:create_table(local_config,
[{disc_copies, [node()]},
{local_content, true},
{attributes, record_info(fields, local_config)}]),
mnesia:add_table_copy(local_config, node(), ram_copies),
load_file(?CONFIG_PATH). load_file(?CONFIG_PATH).
@ -31,14 +45,50 @@ process_term(Term) ->
case Term of case Term of
{acl, ACLName, ACLData} -> {acl, ACLName, ACLData} ->
acl:add(ACLName, ACLData); acl:add(ACLName, ACLData);
{access, RuleName, Rules} ->
add_global_option({access, RuleName}, Rules);
{Opt, Val} -> {Opt, Val} ->
ets:insert(ejabberd_config, {Opt, Val}) add_option(Opt, Val)
end. end.
add_option(Opt, Val) ->
Table = case Opt of
host ->
config;
_ ->
local_config
end,
case Table of
config ->
add_global_option(Opt, Val);
local_config ->
add_local_option(Opt, Val)
end.
get_option(Opt) -> add_global_option(Opt, Val) ->
case ets:lookup(ejabberd_config, Opt) of mnesia:transaction(fun() ->
[{_, Val}] -> mnesia:write(#config{key = Opt,
value = Val})
end).
add_local_option(Opt, Val) ->
mnesia:transaction(fun() ->
mnesia:write(#local_config{key = Opt,
value = Val})
end).
get_global_option(Opt) ->
case ets:lookup(config, Opt) of
[#config{value = Val}] ->
Val;
_ ->
undefined
end.
get_local_option(Opt) ->
case ets:lookup(local_config, Opt) of
[#local_config{value = Val}] ->
Val; Val;
_ -> _ ->
undefined undefined

View File

@ -17,7 +17,7 @@ start() ->
init(_) -> init(_) ->
case ejabberd_config:get_option(listen) of case ejabberd_config:get_local_option(listen) of
undefined -> undefined ->
ignore; ignore;
Ls -> Ls ->

View File

@ -41,6 +41,7 @@ init() ->
{local_content, true}, {local_content, true},
{attributes, {attributes,
record_info(fields, local_route)}]), record_info(fields, local_route)}]),
mnesia:add_table_copy(local_route, node(), ram_copies),
loop(). loop().
loop() -> loop() ->

View File

@ -20,7 +20,7 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-record(s2s, {fromto, node, key}). -record(s2s, {fromto, node, key}).
-record(mys2s, {fromto, pid}). -record(local_s2s, {fromto, pid}).
start() -> start() ->
@ -31,10 +31,11 @@ init() ->
mnesia:create_table(s2s,[{ram_copies, [node()]}, mnesia:create_table(s2s,[{ram_copies, [node()]},
{attributes, record_info(fields, s2s)}]), {attributes, record_info(fields, s2s)}]),
mnesia:add_table_index(session, node), mnesia:add_table_index(session, node),
mnesia:create_table(mys2s, mnesia:create_table(local_s2s,
[{ram_copies, [node()]}, [{ram_copies, [node()]},
{local_content, true}, {local_content, true},
{attributes, record_info(fields, mys2s)}]), {attributes, record_info(fields, local_s2s)}]),
mnesia:add_table_copy(local_s2s, node(), ram_copies),
mnesia:subscribe(system), mnesia:subscribe(system),
loop(). loop().
@ -70,7 +71,7 @@ loop() ->
remove_connection(FromTo) -> remove_connection(FromTo) ->
F = fun() -> F = fun() ->
mnesia:delete({mys2s, FromTo}), mnesia:delete({local_s2s, FromTo}),
mnesia:delete({s2s, FromTo}) mnesia:delete({s2s, FromTo})
end, end,
mnesia:transaction(F). mnesia:transaction(F).
@ -133,7 +134,7 @@ try_register(FromTo) ->
mnesia:write(#s2s{fromto = FromTo, mnesia:write(#s2s{fromto = FromTo,
node = node(), node = node(),
key = Key}), key = Key}),
mnesia:write(#mys2s{fromto = FromTo, mnesia:write(#local_s2s{fromto = FromTo,
pid = self()}), pid = self()}),
{key, Key}; {key, Key};
_ -> _ ->
@ -159,7 +160,7 @@ do_route(From, To, Packet) ->
FromTo = {MyServer, Server}, FromTo = {MyServer, Server},
Key = randoms:get_string(), Key = randoms:get_string(),
F = fun() -> F = fun() ->
case mnesia:read({mys2s, FromTo}) of case mnesia:read({local_s2s, FromTo}) of
[] -> [] ->
case mnesia:read({s2s, FromTo}) of case mnesia:read({s2s, FromTo}) of
[Er] -> [Er] ->
@ -172,7 +173,7 @@ do_route(From, To, Packet) ->
new new
end; end;
[El] -> [El] ->
{local, El#mys2s.pid} {local, El#local_s2s.pid}
end end
end, end,
case mnesia:transaction(F) of case mnesia:transaction(F) of
@ -192,8 +193,10 @@ do_route(From, To, Packet) ->
{atomic, new} -> {atomic, new} ->
?DEBUG("starting new s2s connection~n", []), ?DEBUG("starting new s2s connection~n", []),
Pid = ejabberd_s2s_out:start(MyServer, Server, {new, Key}), Pid = ejabberd_s2s_out:start(MyServer, Server, {new, Key}),
mnesia:transaction(fun() -> mnesia:write(#mys2s{fromto = FromTo, mnesia:transaction(fun() ->
pid = Pid}) end), mnesia:write(#local_s2s{fromto = FromTo,
pid = Pid})
end),
{xmlelement, Name, Attrs, Els} = Packet, {xmlelement, Name, Attrs, Els} = Packet,
NewAttrs = jlib:replace_from_to_attrs(jlib:jid_to_string(From), NewAttrs = jlib:replace_from_to_attrs(jlib:jid_to_string(From),
jlib:jid_to_string(To), jlib:jid_to_string(To),

View File

@ -22,7 +22,7 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-record(session, {ur, user, node}). -record(session, {ur, user, node}).
-record(mysession, {ur, pid}). -record(local_session, {ur, pid}).
-record(presence, {ur, user, priority}). -record(presence, {ur, user, priority}).
start() -> start() ->
@ -34,10 +34,11 @@ init() ->
{attributes, record_info(fields, session)}]), {attributes, record_info(fields, session)}]),
mnesia:add_table_index(session, user), mnesia:add_table_index(session, user),
mnesia:add_table_index(session, node), mnesia:add_table_index(session, node),
mnesia:create_table(mysession, mnesia:create_table(local_session,
[{ram_copies, [node()]}, [{ram_copies, [node()]},
{local_content, true}, {local_content, true},
{attributes, record_info(fields, mysession)}]), {attributes, record_info(fields, local_session)}]),
mnesia:add_table_copy(local_session, node(), ram_copies),
mnesia:create_table(presence, mnesia:create_table(presence,
[{ram_copies, [node()]}, [{ram_copies, [node()]},
{attributes, record_info(fields, presence)}]), {attributes, record_info(fields, presence)}]),
@ -111,15 +112,15 @@ replace_my_connection(User, Resource) ->
LUser = jlib:tolower(User), LUser = jlib:tolower(User),
F = fun() -> F = fun() ->
UR = {LUser, Resource}, UR = {LUser, Resource},
Es = mnesia:read({mysession, UR}), Es = mnesia:read({local_session, UR}),
mnesia:delete({mysession, UR}), mnesia:delete({local_session, UR}),
Es Es
end, end,
case mnesia:transaction(F) of case mnesia:transaction(F) of
{atomic, Rs} -> {atomic, Rs} ->
lists:foreach( lists:foreach(
fun(R) -> fun(R) ->
R#mysession.pid ! replaced R#local_session.pid ! replaced
end, Rs); end, Rs);
_ -> _ ->
false false
@ -129,7 +130,7 @@ remove_connection(User, Resource) ->
LUser = jlib:tolower(User), LUser = jlib:tolower(User),
F = fun() -> F = fun() ->
UR = {LUser, Resource}, UR = {LUser, Resource},
mnesia:delete({mysession, UR}), mnesia:delete({local_session, UR}),
mnesia:delete({session, UR}) mnesia:delete({session, UR})
end, end,
mnesia:transaction(F). mnesia:transaction(F).
@ -138,15 +139,15 @@ replace_and_register_my_connection(User, Resource, Pid) ->
LUser = jlib:tolower(User), LUser = jlib:tolower(User),
F = fun() -> F = fun() ->
UR = {LUser, Resource}, UR = {LUser, Resource},
Es = mnesia:read({mysession, UR}), Es = mnesia:read({local_session, UR}),
mnesia:write(#mysession{ur = UR, pid = Pid}), mnesia:write(#local_session{ur = UR, pid = Pid}),
Es Es
end, end,
case mnesia:transaction(F) of case mnesia:transaction(F) of
{atomic, Rs} -> {atomic, Rs} ->
lists:foreach( lists:foreach(
fun(R) -> fun(R) ->
R#mysession.pid ! replaced R#local_session.pid ! replaced
end, Rs); end, Rs);
_ -> _ ->
false false
@ -262,13 +263,13 @@ do_route(From, To, Packet) ->
?DEBUG("packet droped~n", []) ?DEBUG("packet droped~n", [])
end; end;
[Ses] -> [Ses] ->
case mnesia:dirty_read({mysession, LUR}) of case mnesia:dirty_read({local_session, LUR}) of
[] -> [] ->
Node = Ses#session.node, Node = Ses#session.node,
?DEBUG("sending to node ~p~n", [Node]), ?DEBUG("sending to node ~p~n", [Node]),
{ejabberd_sm, Node} ! {route, From, To, Packet}; {ejabberd_sm, Node} ! {route, From, To, Packet};
[El] -> [El] ->
Pid = El#mysession.pid, Pid = El#local_session.pid,
?DEBUG("sending to process ~p~n", [Pid]), ?DEBUG("sending to process ~p~n", [Pid]),
Pid ! {route, From, To, Packet} Pid ! {route, From, To, Packet}
end end
@ -341,7 +342,7 @@ dirty_get_sessions_list() ->
mnesia:dirty_all_keys(session). mnesia:dirty_all_keys(session).
dirty_get_my_sessions_list() -> dirty_get_my_sessions_list() ->
mnesia:dirty_all_keys(mysession). mnesia:dirty_all_keys(local_session).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -11,7 +11,8 @@
-vsn('$Revision$ '). -vsn('$Revision$ ').
-export([start/0, -export([start/0,
process_local_iq/3]). process_local_iq/3,
process_sm_iq/3]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("namespaces.hrl"). -include("namespaces.hrl").
@ -19,7 +20,10 @@
start() -> start() ->
ejabberd_local:register_iq_handler(?NS_XDATA, ejabberd_local:register_iq_handler(?NS_XDATA,
?MODULE, process_local_iq). ?MODULE, process_local_iq),
ejabberd_sm:register_iq_handler(?NS_XDATA,
?MODULE, process_sm_iq),
ok.
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) -> process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
@ -92,6 +96,12 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
{"label", translate:translate(Lang, Label)}, {"label", translate:translate(Lang, Label)},
{"var", Var}], []}). {"var", Var}], []}).
-define(XFIELD(Type, Label, Var, Val),
{xmlelement, "field", [{"type", Type},
{"label", translate:translate(Lang, Label)},
{"var", Var}],
[{xmlelement, "value", [], [{xmlcdata, Val}]}]}).
-define(TABLEFIELD(Table, Val), -define(TABLEFIELD(Table, Val),
{xmlelement, "field", [{"type", "list-single"}, {xmlelement, "field", [{"type", "list-single"},
{"label", atom_to_list(Table)}, {"label", atom_to_list(Table)},
@ -105,7 +115,8 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
"RAM and disc copy")}], "RAM and disc copy")}],
[{xmlelement, "value", [], [{xmlcdata, "disc_copies"}]}]}, [{xmlelement, "value", [], [{xmlcdata, "disc_copies"}]}]},
{xmlelement, "option", [{"label", {xmlelement, "option", [{"label",
translate:translate(Lang, "Disk copy")}], translate:translate(Lang,
"Disc only copy")}],
[{xmlelement, "value", [], [{xmlcdata, "disc_only_copies"}]}]}, [{xmlelement, "value", [], [{xmlcdata, "disc_only_copies"}]}]},
{xmlelement, "option", [{"label", {xmlelement, "option", [{"label",
translate:translate(Lang, "Remote copy")}], translate:translate(Lang, "Remote copy")}],
@ -123,6 +134,7 @@ get_form(["running nodes", ENode, "DB"], Lang) ->
{badrpc, Reason} -> {badrpc, Reason} ->
{error, "500", "Internal Server Error"}; {error, "500", "Internal Server Error"};
Tables -> Tables ->
STables = lists:sort(Tables),
{result, [{xmlelement, "title", [], {result, [{xmlelement, "title", [],
[{xmlcdata, [{xmlcdata,
translate:translate( translate:translate(
@ -142,11 +154,27 @@ get_form(["running nodes", ENode, "DB"], Lang) ->
Type -> Type ->
?TABLEFIELD(Table, Type) ?TABLEFIELD(Table, Type)
end end
end, Tables) end, STables)
]} ]}
end end
end; end;
get_form(["config", "hostname"], Lang) ->
{result, [{xmlelement, "title", [],
[{xmlcdata,
translate:translate(
Lang, "DB Tables Configuration")}]},
{xmlelement, "instructions", [],
[{xmlcdata,
translate:translate(
Lang, "Choose host name")}]},
{xmlelement, "field", [{"type", "text-single"},
{"label",
translate:translate(Lang, "Host name")},
{"var", "hostname"}],
[{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}]}
]};
get_form(_, Lang) -> get_form(_, Lang) ->
{error, "503", "Service Unavailable"}. {error, "503", "Service Unavailable"}.
@ -159,7 +187,7 @@ set_form(["running nodes", ENode, "DB"], Lang, XData) ->
Node -> Node ->
lists:foreach( lists:foreach(
fun({SVar, SVals}) -> fun({SVar, SVals}) ->
% We believe that this allowed only for good peoples % We believe that this is allowed only for good peoples
Table = list_to_atom(SVar), Table = list_to_atom(SVar),
Type = case SVals of Type = case SVals of
["unknown"] -> unknown; ["unknown"] -> unknown;
@ -186,6 +214,19 @@ set_form(["running nodes", ENode, "DB"], Lang, XData) ->
{result, []} {result, []}
end; end;
set_form(["config", "hostname"], Lang, XData) ->
case lists:keysearch("hostname", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{value, {_, [""]}} ->
{error, "406", "Not Acceptable"};
{value, {_, [NewName]}} ->
ejabberd_config:add_global_option(hostname, NewName),
{result, []};
_ ->
{error, "406", "Not Acceptable"}
end;
set_form(_, Lang, XData) -> set_form(_, Lang, XData) ->
{error, "503", "Service Unavailable"}. {error, "503", "Service Unavailable"}.
@ -204,4 +245,97 @@ search_running_node(SNode, [Node | Nodes]) ->
search_running_node(SNode, Nodes) search_running_node(SNode, Nodes)
end. end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process_sm_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case acl:match_rule(configure, From) of
deny ->
{iq, ID, error, XMLNS, [SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]};
allow ->
{User, _, _} = To,
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
case Type of
set ->
case xml:get_tag_attr_s("type", SubEl) of
"cancel" ->
{iq, ID, result, XMLNS,
[{xmlelement, "query", [{"xmlns", XMLNS}], []}]};
"submit" ->
XData = jlib:parse_xdata_submit(SubEl),
case XData of
invalid ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "400"}],
[{xmlcdata, "Bad Request"}]}]};
_ ->
Node =
string:tokens(
xml:get_tag_attr_s("node", SubEl),
"/"),
case set_sm_form(
User, Node, Lang, XData) of
{result, Res} ->
{iq, ID, result, XMLNS,
[{xmlelement, "query",
[{"xmlns", XMLNS}],
Res
}]};
{error, Code, Desc} ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", Code}],
[{xmlcdata, Desc}]}]}
end
end;
_ ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]}
end;
get ->
Node =
string:tokens(xml:get_tag_attr_s("node", SubEl), "/"),
case get_sm_form(User, Node, Lang) of
{result, Res} ->
{iq, ID, result, XMLNS,
[{xmlelement, "query", [{"xmlns", XMLNS}],
Res
}]};
{error, Code, Desc} ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", Code}],
[{xmlcdata, Desc}]}]}
end
end
end.
get_sm_form(User, [], Lang) ->
{result, [{xmlelement, "title", [],
[{xmlcdata,
translate:translate(
Lang, "Administration of " ++ User)}]},
%{xmlelement, "instructions", [],
% [{xmlcdata,
% translate:translate(
% Lang, "Choose host name")}]},
?XFIELD("text-private", "Password", "password",
ejabberd_auth:get_password_s(User))
%{xmlelement, "field", [{"type", "text-single"},
% {"label",
% translate:translate(Lang, "Host name")},
% {"var", "hostname"}],
% [{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}]}
]};
get_sm_form(_, _, Lang) ->
{error, "503", "Service Unavailable"}.
set_sm_form(_, _, Lang, XData) ->
{error, "503", "Service Unavailable"}.

View File

@ -90,6 +90,7 @@ process_local_iq_info(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
{"name", "ejabberd"}], []}] ++ {"name", "ejabberd"}], []}] ++
Features Features
}]}; }]};
["config"] -> ?EMPTY_INFO_RESULT;
["online users"] -> ?EMPTY_INFO_RESULT; ["online users"] -> ?EMPTY_INFO_RESULT;
["all users"] -> ?EMPTY_INFO_RESULT; ["all users"] -> ?EMPTY_INFO_RESULT;
["outgoing s2s" | _] -> ?EMPTY_INFO_RESULT; ["outgoing s2s" | _] -> ?EMPTY_INFO_RESULT;
@ -98,7 +99,7 @@ process_local_iq_info(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
["running nodes", ENode] -> ["running nodes", ENode] ->
{iq, ID, result, XMLNS, [{xmlelement, {iq, ID, result, XMLNS, [{xmlelement,
"query", "query",
[{"xmlns", ?NS_DISCO_INFO}], [{"xmlns", XMLNS}],
[{xmlelement, "identity", [{xmlelement, "identity",
[{"category", "ejabberd"}, [{"category", "ejabberd"},
{"type", "node"}, {"type", "node"},
@ -109,10 +110,14 @@ process_local_iq_info(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
["running nodes", ENode, "DB"] -> ["running nodes", ENode, "DB"] ->
{iq, ID, result, XMLNS, [{xmlelement, {iq, ID, result, XMLNS, [{xmlelement,
"query", "query",
[{"xmlns", ?NS_DISCO_INFO}], [{"xmlns", XMLNS}],
[feature_to_xml({?NS_XDATA}) [feature_to_xml({?NS_XDATA})
] ]
}]}; }]};
["config", _] ->
{iq, ID, result, XMLNS,
[{xmlelement, "query", [{"xmlns", XMLNS}],
[feature_to_xml({?NS_XDATA})]}]};
_ -> _ ->
{iq, ID, error, XMLNS, {iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error", [SubEl, {xmlelement, "error",
@ -142,13 +147,24 @@ get_local_items([], Server, Lang) ->
ejabberd_router:dirty_get_all_routes()), ejabberd_router:dirty_get_all_routes()),
{result, {result,
Domains ++ Domains ++
[?NODE("Online Users", "online users"), [?NODE("Configuration", "config"),
?NODE("Online Users", "online users"),
?NODE("All Users", "all users"), ?NODE("All Users", "all users"),
?NODE("Outgoing S2S connections", "outgoing s2s"), ?NODE("Outgoing S2S connections", "outgoing s2s"),
?NODE("Running Nodes", "running nodes"), ?NODE("Running Nodes", "running nodes"),
?NODE("Stopped Nodes", "stopped nodes") ?NODE("Stopped Nodes", "stopped nodes")
]}; ]};
get_local_items(["config"], Server, Lang) ->
{result,
[?NODE("Host Name", "config/hostname"),
?NODE("ACLs", "config/acls"),
?NODE("Access Rules", "config/access")
]};
get_local_items(["config", _], Server, Lang) ->
{result, []};
get_local_items(["online users"], Server, Lang) -> get_local_items(["online users"], Server, Lang) ->
{result, get_online_users()}; {result, get_online_users()};
@ -310,7 +326,10 @@ process_sm_iq_info(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
[{xmlcdata, "Not Allowed"}]}]}; [{xmlcdata, "Not Allowed"}]}]};
get -> get ->
case xml:get_tag_attr_s("node", SubEl) of case xml:get_tag_attr_s("node", SubEl) of
"" -> ?EMPTY_INFO_RESULT; "" ->
{iq, ID, result, XMLNS,
[{xmlelement, "query", [{"xmlns", XMLNS}],
[feature_to_xml({?NS_XDATA})]}]};
_ -> _ ->
{iq, ID, error, XMLNS, {iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error", [SubEl, {xmlelement, "error",