mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
*** empty log message ***
SVN Revision: 41
This commit is contained in:
parent
5645292526
commit
23e1914e94
9
TODO
9
TODO
@ -1,8 +1,5 @@
|
|||||||
S2S timeouts
|
S2S timeouts
|
||||||
...
|
iq:browse(?)
|
||||||
iq:browse
|
|
||||||
iq:disco
|
|
||||||
...
|
|
||||||
services support
|
|
||||||
JUD
|
|
||||||
SVR DNS records
|
SVR DNS records
|
||||||
|
karma
|
||||||
|
SSL
|
||||||
|
@ -136,10 +136,10 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
case jlib:iq_query_info(El) of
|
case jlib:iq_query_info(El) of
|
||||||
{iq, ID, Type, "jabber:iq:register", SubEl} ->
|
{iq, ID, Type, ?NS_REGISTER, SubEl} ->
|
||||||
ResIQ = mod_register:process_iq(
|
ResIQ = mod_register:process_iq(
|
||||||
{"", "", ""}, {"", ?MYNAME, ""},
|
{"", "", ""}, {"", ?MYNAME, ""},
|
||||||
{iq, ID, Type, "jabber:iq:register", SubEl}),
|
{iq, ID, Type, ?NS_REGISTER, SubEl}),
|
||||||
Res1 = jlib:replace_from_to({"", ?MYNAME, ""},
|
Res1 = jlib:replace_from_to({"", ?MYNAME, ""},
|
||||||
{"", "", ""},
|
{"", "", ""},
|
||||||
jlib:iq_to_xml(ResIQ)),
|
jlib:iq_to_xml(ResIQ)),
|
||||||
@ -388,26 +388,16 @@ new_id() ->
|
|||||||
randoms:get_string().
|
randoms:get_string().
|
||||||
|
|
||||||
|
|
||||||
is_auth_packet({xmlelement, Name, Attrs, Els}) when Name == "iq" ->
|
is_auth_packet(El) ->
|
||||||
case xml:get_attr_s("type", Attrs) of
|
case jlib:iq_query_info(El) of
|
||||||
"set" ->
|
{iq, ID, Type, ?NS_AUTH, SubEl} ->
|
||||||
case xml:remove_cdata(Els) of
|
{xmlelement, _, _, Els} = SubEl,
|
||||||
[{xmlelement, "query", Attrs2, Els2}] ->
|
{auth, ID,
|
||||||
case xml:get_attr_s("xmlns", Attrs2) of
|
get_auth_tags(Els, "", "", "", "")};
|
||||||
"jabber:iq:auth" ->
|
|
||||||
{auth,
|
|
||||||
xml:get_attr_s("id", Attrs),
|
|
||||||
get_auth_tags(Els2, "", "", "", "")};
|
|
||||||
_ -> false
|
|
||||||
end;
|
|
||||||
_ ->
|
_ ->
|
||||||
false
|
false
|
||||||
end;
|
end.
|
||||||
true ->
|
|
||||||
false
|
|
||||||
end;
|
|
||||||
is_auth_packet(_) ->
|
|
||||||
false.
|
|
||||||
|
|
||||||
get_auth_tags([{xmlelement, Name, Attrs, Els}| L], U, P, D, R) ->
|
get_auth_tags([{xmlelement, Name, Attrs, Els}| L], U, P, D, R) ->
|
||||||
CData = xml:get_cdata(Els),
|
CData = xml:get_cdata(Els),
|
||||||
|
@ -20,23 +20,16 @@ start() ->
|
|||||||
|
|
||||||
|
|
||||||
load_file(File) ->
|
load_file(File) ->
|
||||||
{ok, Bin} = file:read_file(File),
|
case file:consult(File) of
|
||||||
Content = binary_to_list(Bin),
|
{ok, Terms} ->
|
||||||
parse(Content).
|
lists:foreach(fun({Opt, Val}) ->
|
||||||
|
ets:insert(ejabberd_config, {Opt, Val})
|
||||||
|
end, Terms);
|
||||||
parse(String) ->
|
{error, Reason} ->
|
||||||
case erl_scan:tokens([], String, 0) of
|
exit(file:format_error(Reason))
|
||||||
{done, Result, Left} ->
|
|
||||||
{ok, Tokens, _} = Result,
|
|
||||||
{ok, Term} = erl_parse:parse_term(Tokens),
|
|
||||||
{Opt, Val} = Term,
|
|
||||||
ets:insert(ejabberd_config, {Opt, Val}),
|
|
||||||
parse(Left);
|
|
||||||
_ ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
get_option(Opt) ->
|
get_option(Opt) ->
|
||||||
case ets:lookup(ejabberd_config, Opt) of
|
case ets:lookup(ejabberd_config, Opt) of
|
||||||
[{_, Val}] ->
|
[{_, Val}] ->
|
||||||
|
@ -27,6 +27,7 @@ start() ->
|
|||||||
mod_vcard:start(),
|
mod_vcard:start(),
|
||||||
mod_offline:start(),
|
mod_offline:start(),
|
||||||
mod_echo:start(),
|
mod_echo:start(),
|
||||||
|
mod_private:start(),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
init() ->
|
init() ->
|
||||||
|
@ -142,8 +142,15 @@ do_route(From, To, Packet) ->
|
|||||||
ejabberd_s2s ! {route, From, To, Packet};
|
ejabberd_s2s ! {route, From, To, Packet};
|
||||||
[R] ->
|
[R] ->
|
||||||
Node = R#route.node,
|
Node = R#route.node,
|
||||||
|
case node() of
|
||||||
|
Node ->
|
||||||
|
Pid = R#local_route.pid,
|
||||||
|
?DEBUG("routed to process ~p~n", [Pid]),
|
||||||
|
Pid ! {route, From, To, Packet};
|
||||||
|
_ ->
|
||||||
?DEBUG("routed to node ~p~n", [Node]),
|
?DEBUG("routed to node ~p~n", [Node]),
|
||||||
{ejabberd_router, Node} ! {route, From, To, Packet}
|
{ejabberd_router, Node} ! {route, From, To, Packet}
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
[R] ->
|
[R] ->
|
||||||
Pid = R#local_route.pid,
|
Pid = R#local_route.pid,
|
||||||
|
95
src/mod_private.erl
Normal file
95
src/mod_private.erl
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
%%%----------------------------------------------------------------------
|
||||||
|
%%% File : mod_private.erl
|
||||||
|
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
%%% Purpose :
|
||||||
|
%%% Created : 16 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
%%% Id : $Id$
|
||||||
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(mod_private).
|
||||||
|
-author('alexey@sevcom.net').
|
||||||
|
-vsn('$Revision$ ').
|
||||||
|
|
||||||
|
-export([start/0,
|
||||||
|
process_local_iq/3]).
|
||||||
|
|
||||||
|
-include("ejabberd.hrl").
|
||||||
|
-include("namespaces.hrl").
|
||||||
|
|
||||||
|
-record(private_storage, {userns, xml}).
|
||||||
|
|
||||||
|
start() ->
|
||||||
|
mnesia:create_table(private_storage,
|
||||||
|
[{disc_only_copies, [node()]},
|
||||||
|
{attributes, record_info(fields, private_storage)}]),
|
||||||
|
ejabberd_local:register_iq_handler(?NS_PRIVATE, ?MODULE, process_local_iq).
|
||||||
|
|
||||||
|
|
||||||
|
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
|
{User, Server, _} = From,
|
||||||
|
LUser = jlib:tolower(User),
|
||||||
|
LServer = jlib:tolower(Server),
|
||||||
|
case ?MYNAME of
|
||||||
|
Server ->
|
||||||
|
{xmlelement, Name, Attrs, Els} = SubEl,
|
||||||
|
case Type of
|
||||||
|
set ->
|
||||||
|
F = fun() ->
|
||||||
|
lists:foreach(
|
||||||
|
fun(El) ->
|
||||||
|
set_data(LUser, El)
|
||||||
|
end, Els)
|
||||||
|
end,
|
||||||
|
mnesia:transaction(F),
|
||||||
|
{iq, ID, result, XMLNS, [{xmlelement, Name, Attrs, []}]};
|
||||||
|
get ->
|
||||||
|
case catch get_data(LUser, Els) of
|
||||||
|
{'EXIT', Reason} ->
|
||||||
|
{iq, ID, error, XMLNS,
|
||||||
|
[SubEl, {xmlelement, "error",
|
||||||
|
[{"code", "500"}],
|
||||||
|
[{xmlcdata, "Internal Server Error"}]}]};
|
||||||
|
Res ->
|
||||||
|
{iq, ID, error, XMLNS,
|
||||||
|
[{xmlelement, Name, Attrs, Res}]}
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
{iq, ID, error, XMLNS, [SubEl, {xmlelement, "error",
|
||||||
|
[{"code", "405"}],
|
||||||
|
[{xmlcdata, "Not Allowed"}]}]}
|
||||||
|
end.
|
||||||
|
|
||||||
|
set_data(LUser, El) ->
|
||||||
|
case El of
|
||||||
|
{xmlelement, Name, Attrs, Els} ->
|
||||||
|
XMLNS = xml:get_attr_s("xmlns", Attrs),
|
||||||
|
case XMLNS of
|
||||||
|
"" ->
|
||||||
|
ignore;
|
||||||
|
_ ->
|
||||||
|
mnesia:write(#private_storage{userns = {LUser, XMLNS},
|
||||||
|
xml = El})
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
ignore
|
||||||
|
end.
|
||||||
|
|
||||||
|
get_data(LUser, Els) ->
|
||||||
|
get_data(LUser, Els, []).
|
||||||
|
|
||||||
|
get_data(LUser, [], Res) ->
|
||||||
|
lists:reverse(Res);
|
||||||
|
get_data(LUser, [El | Els], Res) ->
|
||||||
|
case El of
|
||||||
|
{xmlelement, Name, Attrs, _} ->
|
||||||
|
XMLNS = xml:get_attr_s("xmlns", Attrs),
|
||||||
|
case mnesia:dirty_read(private_storage, {LUser, XMLNS}) of
|
||||||
|
[R] ->
|
||||||
|
get_data(LUser, Els, [R#private_storage.xml | Res]);
|
||||||
|
[] ->
|
||||||
|
get_data(LUser, Els, [El | Res])
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
get_data(LUser, Els, Res)
|
||||||
|
end.
|
@ -53,13 +53,13 @@ start() ->
|
|||||||
mnesia:add_table_index(vcard_search, lorgname),
|
mnesia:add_table_index(vcard_search, lorgname),
|
||||||
mnesia:add_table_index(vcard_search, lorgunit),
|
mnesia:add_table_index(vcard_search, lorgunit),
|
||||||
|
|
||||||
|
|
||||||
ejabberd_local:register_iq_handler(?NS_VCARD,
|
ejabberd_local:register_iq_handler(?NS_VCARD,
|
||||||
?MODULE, process_local_iq),
|
?MODULE, process_local_iq),
|
||||||
ejabberd_sm:register_iq_handler(?NS_VCARD,
|
ejabberd_sm:register_iq_handler(?NS_VCARD,
|
||||||
?MODULE, process_sm_iq),
|
?MODULE, process_sm_iq),
|
||||||
spawn(?MODULE, init, []).
|
spawn(?MODULE, init, []).
|
||||||
|
|
||||||
|
|
||||||
init() ->
|
init() ->
|
||||||
ejabberd_router:register_local_route("vjud." ++ ?MYNAME),
|
ejabberd_router:register_local_route("vjud." ++ ?MYNAME),
|
||||||
loop().
|
loop().
|
||||||
|
@ -8,8 +8,11 @@
|
|||||||
-define(NS_DISCO_ITEMS, "http://jabber.org/protocol/disco#items").
|
-define(NS_DISCO_ITEMS, "http://jabber.org/protocol/disco#items").
|
||||||
-define(NS_DISCO_INFO, "http://jabber.org/protocol/disco#info").
|
-define(NS_DISCO_INFO, "http://jabber.org/protocol/disco#info").
|
||||||
-define(NS_VCARD, "vcard-temp").
|
-define(NS_VCARD, "vcard-temp").
|
||||||
|
-define(NS_AUTH, "jabber:iq:auth").
|
||||||
|
-define(NS_REGISTER, "jabber:iq:register").
|
||||||
-define(NS_SEARCH, "jabber:iq:search").
|
-define(NS_SEARCH, "jabber:iq:search").
|
||||||
-define(NS_ROSTER, "jabber:iq:roster").
|
-define(NS_ROSTER, "jabber:iq:roster").
|
||||||
|
-define(NS_PRIVATE, "jabber:iq:private").
|
||||||
-define(NS_XDATA, "jabber:x:data").
|
-define(NS_XDATA, "jabber:x:data").
|
||||||
-define(NS_DELAY, "jabber:x:delay").
|
-define(NS_DELAY, "jabber:x:delay").
|
||||||
-define(NS_EVENT, "jabber:x:event").
|
-define(NS_EVENT, "jabber:x:event").
|
||||||
|
@ -41,21 +41,14 @@ load_dir(Dir) ->
|
|||||||
ok.
|
ok.
|
||||||
|
|
||||||
load_file(Lang, File) ->
|
load_file(Lang, File) ->
|
||||||
{ok, Bin} = file:read_file(File),
|
case file:consult(File) of
|
||||||
Content = binary_to_list(Bin),
|
{ok, Terms} ->
|
||||||
parse(Lang, Content).
|
lists:foreach(fun({Orig, Trans}) ->
|
||||||
|
ets:insert(translations,
|
||||||
|
{{Lang, Orig}, Trans})
|
||||||
parse(Lang, String) ->
|
end, Terms);
|
||||||
case erl_scan:tokens([], String, 0) of
|
{error, Reason} ->
|
||||||
{done, Result, Left} ->
|
exit(file:format_error(Reason))
|
||||||
{ok, Tokens, _} = Result,
|
|
||||||
{ok, Term} = erl_parse:parse_term(Tokens),
|
|
||||||
{Orig, Trans} = Term,
|
|
||||||
ets:insert(translations, {{Lang, Orig}, Trans}),
|
|
||||||
parse(Lang, Left);
|
|
||||||
_ ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
translate(Lang, Msg) ->
|
translate(Lang, Msg) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user