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

* src/ejabberd_local.erl: Updated missed errors to new style

* src/mod_register.erl: Likewise
* src/mod_version.erl: Likewise
* src/mod_time.erl: Likewise
* src/mod_stats.erl: Likewise
* src/mod_register.erl: Likewise
* src/mod_private.erl: Likewise
* src/mod_configure.erl: Likewise
* src/ejabberd_sm.erl: Likewise
* src/ejabberd_service.erl: Likewise
* src/ejabberd_c2s.erl: Likewise
* src/ejabberd_s2s_out.erl: Likewise
* src/mod_vcard.erl: Likewise
* src/mod_roster.erl: Likewise

* src/mod_muc/mod_muc.erl: Added vcard to mod_muc module

* src/ejabberd_app.erl: Dump list of opened ports every hour

* src/ejabberd.hrl: Added INFO_MSG macros, ERROR_LOG_PATH renamed
to LOG_PATH

SVN Revision: 106
This commit is contained in:
Alexey Shchepin 2003-05-09 19:32:59 +00:00
parent 848b06db12
commit 86cd1729cb
19 changed files with 146 additions and 122 deletions

View File

@ -1,3 +1,27 @@
2003-05-09 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_local.erl: Updated missed errors to new style
* src/mod_register.erl: Likewise
* src/mod_version.erl: Likewise
* src/mod_time.erl: Likewise
* src/mod_stats.erl: Likewise
* src/mod_register.erl: Likewise
* src/mod_private.erl: Likewise
* src/mod_configure.erl: Likewise
* src/ejabberd_sm.erl: Likewise
* src/ejabberd_service.erl: Likewise
* src/ejabberd_c2s.erl: Likewise
* src/ejabberd_s2s_out.erl: Likewise
* src/mod_vcard.erl: Likewise
* src/mod_roster.erl: Likewise
* src/mod_muc/mod_muc.erl: Added vcard to mod_muc module
* src/ejabberd_app.erl: Dump list of opened ports every hour
* src/ejabberd.hrl: Added INFO_MSG macros, ERROR_LOG_PATH renamed
to LOG_PATH
2003-05-08 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc.erl: Denied using of empty nick

View File

@ -19,7 +19,11 @@
-endif.
-define(ERROR_MSG(Format, Args),
error_logger:format("E(~p:~p:~p): "++Format++"~n",
error_logger:error_msg("E(~p:~p:~p): "++Format++"~n",
[self(),?MODULE,?LINE]++Args)).
-define(INFO_MSG(Format, Args),
error_logger:info_msg("I(~p:~p:~p): "++Format++"~n",
[self(),?MODULE,?LINE]++Args)).
@ -30,5 +34,5 @@
-define(MSGS_DIR, "msgs").
-define(CONFIG_PATH, "ejabberd.cfg").
-define(ERROR_LOG_PATH, "error.log").
-define(LOG_PATH, "ejabberd.log").

View File

@ -14,6 +14,8 @@
-export([start/2, stop/1, init/0]).
-export([dump_ports/0]).
-include("ejabberd.hrl").
start(normal, Args) ->
@ -46,10 +48,10 @@ init() ->
%eprof:start(),
%eprof:profile([self()]),
%erlang:system_flag(fullsweep_after, 0),
error_logger:logfile({open, ?ERROR_LOG_PATH}),
error_logger:logfile({open, ?LOG_PATH}),
timer:apply_interval(3600000, ?MODULE, dump_ports, []),
ok = erl_ddll:load_driver(".", expat_erl),
Port = open_port({spawn, expat_erl}, [binary]),
loop(Port).
@ -79,3 +81,8 @@ load_modules() ->
end, Modules)
end.
dump_ports() ->
?INFO_MSG("ports:~n ~p",
[lists:map(fun(P) -> erlang:port_info(P) end, erlang:ports())]).

View File

@ -166,7 +166,7 @@ wait_for_stream(closed, StateData) ->
wait_for_auth({xmlstreamelement, El}, StateData) ->
case is_auth_packet(El) of
{auth, ID, get, {"", _, _, _}} ->
Err = jlib:make_error_reply(El, "406", "Not Acceptable"),
Err = jlib:make_error_reply(El, ?ERR_BAD_REQUEST),
send_element(StateData, Err),
{next_state, wait_for_auth, StateData};
{auth, ID, get, {U, _, _, _}} ->
@ -305,7 +305,7 @@ wait_for_sasl_auth(closed, StateData) ->
wait_for_resource_auth({xmlstreamelement, El}, StateData) ->
case is_auth_packet(El) of
{auth, ID, get, {"", _, _, _}} ->
Err = jlib:make_error_reply(El, "406", "Not Acceptable"),
Err = jlib:make_error_reply(El, ?ERR_BAD_REQUEST),
send_element(StateData, Err),
{next_state, wait_for_resource_auth, StateData};
{auth, ID, get, {U, _, _, _}} ->
@ -345,7 +345,7 @@ wait_for_resource_auth({xmlstreamelement, El}, StateData) ->
{next_state, wait_for_resource_auth, StateData}
end;
_ ->
Err = jlib:make_error_reply(El, "406", "Not Acceptable"),
Err = jlib:make_error_reply(El, ?ERR_BAD_REQUEST),
send_element(StateData, Err),
{next_state, wait_for_resource_auth, StateData}
end;

View File

@ -110,7 +110,7 @@ process_iq(State, From, To, Packet) ->
From, To, IQ);
[] ->
Err = jlib:make_error_reply(
Packet, "501", "Not Implemented"),
Packet, ?ERR_FEATURE_NOT_IMPLEMENTED),
ejabberd_router ! {route,
{"", State#state.mydomain, ""},
From,

View File

@ -80,6 +80,7 @@ start(SockData, Opts) ->
%% {stop, StopReason}
%%----------------------------------------------------------------------
init([{SockMod, Socket}]) ->
?INFO_MSG("started: ~p", [{SockMod, Socket}]),
ReceiverPid = spawn(?MODULE, receiver, [Socket, self()]),
{ok, wait_for_stream, #state{socket = Socket,
receiver = ReceiverPid,
@ -121,7 +122,7 @@ wait_for_stream(closed, StateData) ->
wait_for_key({xmlstreamelement, El}, StateData) ->
case is_key_packet(El) of
{key, To, From, Id, Key} ->
io:format("GET KEY: ~p~n", [{To, From, Id, Key}]),
?INFO_MSG("GET KEY: ~p", [{To, From, Id, Key}]),
case lists:member(To, ejabberd_router:dirty_get_all_domains()) of
true ->
ejabberd_s2s_out:start(To, From,
@ -135,7 +136,7 @@ wait_for_key({xmlstreamelement, El}, StateData) ->
{stop, normal, StateData}
end;
{verify, To, From, Id, Key} ->
io:format("VERIFY KEY: ~p~n", [{To, From, Id, Key}]),
?INFO_MSG("VERIFY KEY: ~p", [{To, From, Id, Key}]),
Key1 = ejabberd_s2s:get_key({StateData#state.myname, From}),
Type = if Key == Key1 -> "valid";
true -> "invalid"
@ -184,7 +185,7 @@ wait_for_verification(invalid, StateData) ->
wait_for_verification({xmlstreamelement, El}, StateData) ->
case is_key_packet(El) of
{verify, To, From, Id, Key} ->
io:format("VERIFY KEY: ~p~n", [{To, From, Id, Key}]),
?INFO_MSG("VERIFY KEY: ~p", [{To, From, Id, Key}]),
Key1 = ejabberd_s2s:get_key({StateData#state.myname, From}),
Type = if Key == Key1 -> "valid";
true -> "invalid"
@ -215,7 +216,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
"db:verify" ->
case is_key_packet(El) of
{verify, To, From, Id, Key} ->
io:format("VERIFY KEY: ~p~n", [{To, From, Id, Key}]),
?INFO_MSG("VERIFY KEY: ~p", [{To, From, Id, Key}]),
Key1 = ejabberd_s2s:get_key({StateData#state.myname,
From}),
Type = if Key == Key1 -> "valid";
@ -343,6 +344,7 @@ terminate(Reason, StateName, StateData) ->
% % StateData#state.resource)
% end,
%ejabberd_s2s ! {closed_conection, StateData#state.server},
?INFO_MSG("terminated: ~p", [Reason]),
gen_tcp:close(StateData#state.socket),
ok.

View File

@ -28,6 +28,7 @@
code_change/4]).
-include("ejabberd.hrl").
-include("jlib.hrl").
-record(state, {socket, receiver, streamid,
myname, server, xmlpid, queue,
@ -77,6 +78,7 @@ start(From, Host, Type) ->
%% {stop, StopReason}
%%----------------------------------------------------------------------
init([From, Server, Type]) ->
?INFO_MSG("started: ~p", [{From, Server, Type}]),
gen_fsm:send_event(self(), init),
{New, Verify} = case Type of
{new, Key} ->
@ -112,11 +114,11 @@ open_socket(init, StateData) ->
streamid = new_id()}};
{error, Reason} ->
?DEBUG("s2s_out: connect return ~p~n", [Reason]),
Text = case Reason of
timeout -> "Server Connect Timeout";
_ -> "Server Connect Failed"
Error = case Reason of
timeout -> ?ERR_REMOTE_SERVER_TIMEOUT;
_ -> ?ERR_REMOTE_SERVER_NOT_FOUND
end,
bounce_messages(Text),
bounce_messages(Error),
{stop, normal, StateData}
end.
@ -175,6 +177,7 @@ wait_for_stream(closed, StateData) ->
wait_for_validation({xmlstreamelement, El}, StateData) ->
case is_verify_res(El) of
{result, To, From, Id, Type} ->
?INFO_MSG("recv result: ~p", [{From, To, Id, Type}]),
case Type of
"valid" ->
send_queue(StateData#state.socket, StateData#state.queue),
@ -184,6 +187,7 @@ wait_for_validation({xmlstreamelement, El}, StateData) ->
{stop, normal, StateData}
end;
{verify, To, From, Id, Type} ->
?INFO_MSG("recv verify: ~p", [{From, To, Id, Type}]),
case StateData#state.verify of
false ->
{next_state, wait_for_validation, StateData};
@ -215,9 +219,10 @@ wait_for_validation(closed, StateData) ->
stream_established({xmlstreamelement, El}, StateData) ->
io:format("s2s out~n"),
?INFO_MSG("stream established", []),
case is_verify_res(El) of
{verify, VTo, VFrom, VId, VType} ->
?INFO_MSG("recv verify: ~p", [{VFrom, VTo, VId, VType}]),
case StateData#state.verify of
{VPid, VKey} ->
case VType of
@ -338,7 +343,7 @@ handle_info({tcp_error, Socket, Reason}, StateName, StateData) ->
%% Returns: any
%%----------------------------------------------------------------------
terminate(Reason, StateName, StateData) ->
?DEBUG("s2s_out: terminate ~p~n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!~n", [[Reason, StateName, StateData]]),
?INFO_MSG("terminated: ~p", [Reason]),
case StateData#state.new of
false ->
ok;
@ -377,7 +382,7 @@ send_queue(Socket, Q) ->
new_id() ->
randoms:get_string().
bounce_messages(Reason) ->
bounce_messages(Error) ->
receive
{send_element, El} ->
{xmlelement, Name, Attrs, SubTags} = El,
@ -385,13 +390,12 @@ bounce_messages(Reason) ->
"error" ->
ok;
_ ->
Err = jlib:make_error_reply(El,
"502", Reason),
Err = jlib:make_error_reply(El, Error),
From = jlib:string_to_jid(xml:get_attr_s("from", Attrs)),
To = jlib:string_to_jid(xml:get_attr_s("to", Attrs)),
ejabberd_router ! {route, To, From, Err}
end,
bounce_messages(Reason)
bounce_messages(Error)
after 0 ->
ok
end.

View File

@ -27,6 +27,7 @@
terminate/3]).
-include("ejabberd.hrl").
-include("jlib.hrl").
-record(state, {socket, receiver, streamid,
host, password}).
@ -173,7 +174,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
(ToJID /= error) and (FromJID /= error) ->
ejabberd_router:route(FromJID, ToJID, El);
true ->
Err = jlib:make_error_reply(El, "400", "Bad Request"),
Err = jlib:make_error_reply(El, ?ERR_BAD_REQUEST),
send_element(StateData#state.socket, Err),
error
end,

View File

@ -23,6 +23,7 @@
-include_lib("mnemosyne/include/mnemosyne.hrl").
-include("ejabberd.hrl").
-include("jlib.hrl").
-record(session, {ur, user, node}).
-record(local_session, {ur, pid}).
@ -301,14 +302,14 @@ route_message(From, To, Packet) ->
case catch mod_offline:store_packet(From, To, Packet) of
{'EXIT', _} ->
Err = jlib:make_error_reply(
Packet, "503", "Service Unavailable"),
Packet, ?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route(To, From, Err);
_ ->
ok
end;
_ ->
Err = jlib:make_error_reply(
Packet, "404", "Not Found"),
Packet, ?ERR_JID_NOT_FOUND),
ejabberd_router:route(To, From, Err)
end;
{_, R} ->
@ -399,7 +400,7 @@ process_iq(From, To, Packet) ->
reply ->
ok;
_ ->
Err = jlib:make_error_reply(Packet, "400", "Bad Request"),
Err = jlib:make_error_reply(Packet, ?ERR_BAD_REQUEST),
ejabberd_router ! {route, To, From, Err},
ok
end.

View File

@ -51,9 +51,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case XData of
invalid ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "400"}],
[{xmlcdata, "Bad Request"}]}]};
[SubEl, ?ERR_BAD_REQUEST]};
_ ->
Node =
string:tokens(
@ -73,9 +71,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
end;
_ ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]}
[SubEl, ?ERR_NOT_ALLOWED]}
end;
get ->
Node =
@ -447,7 +443,7 @@ set_form(["running nodes", ENode, "modules", "start"], Lang, XData) ->
Node ->
case lists:keysearch("modules", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, Strings}} ->
String = lists:foldl(fun(S, Res) ->
Res ++ S ++ "\n"
@ -465,13 +461,13 @@ set_form(["running nodes", ENode, "modules", "start"], Lang, XData) ->
end, Modules),
{result, []};
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end
end;
@ -483,7 +479,7 @@ set_form(["running nodes", ENode, "backup", "backup"], Lang, XData) ->
Node ->
case lists:keysearch("path", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, [String]}} ->
case rpc:call(Node, mnesia, backup, [String]) of
{badrpc, Reason} ->
@ -494,7 +490,7 @@ set_form(["running nodes", ENode, "backup", "backup"], Lang, XData) ->
{result, []}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end
end;
@ -506,7 +502,7 @@ set_form(["running nodes", ENode, "backup", "restore"], Lang, XData) ->
Node ->
case lists:keysearch("path", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, [String]}} ->
case rpc:call(Node, mnesia, restore,
[String, [{default_op, keep_tables}]]) of
@ -518,7 +514,7 @@ set_form(["running nodes", ENode, "backup", "restore"], Lang, XData) ->
{result, []}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end
end;
@ -530,7 +526,7 @@ set_form(["running nodes", ENode, "backup", "textfile"], Lang, XData) ->
Node ->
case lists:keysearch("path", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, [String]}} ->
case rpc:call(Node, mnesia, dump_to_textfile, [String]) of
{badrpc, Reason} ->
@ -541,7 +537,7 @@ set_form(["running nodes", ENode, "backup", "textfile"], Lang, XData) ->
{result, []}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end
end;
@ -553,12 +549,12 @@ set_form(["running nodes", ENode, "import", "file"], Lang, XData) ->
Node ->
case lists:keysearch("path", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, [String]}} ->
rpc:call(Node, jd2ejd, import_file, [String]),
{result, []};
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end
end;
@ -570,11 +566,11 @@ set_form(["running nodes", ENode, "import", "dir"], Lang, XData) ->
Node ->
case lists:keysearch("path", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, [String]}} ->
rpc:call(Node, jd2ejd, import_dir, [String]);
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end
end;
@ -582,14 +578,14 @@ set_form(["running nodes", ENode, "import", "dir"], Lang, XData) ->
set_form(["config", "hostname"], Lang, XData) ->
case lists:keysearch("hostname", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, [""]}} ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
{value, {_, [NewName]}} ->
ejabberd_config:add_global_option(hostname, NewName),
{result, []};
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
set_form(["config", "acls"], Lang, XData) ->
@ -606,16 +602,16 @@ set_form(["config", "acls"], Lang, XData) ->
ok ->
{result, []};
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
set_form(["config", "access"], Lang, XData) ->
@ -652,16 +648,16 @@ set_form(["config", "access"], Lang, XData) ->
{result, []};
E ->
io:format("A: ~p~n", [E]),
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
_ ->
{error, "406", "Not Acceptable"}
{error, ?ERR_BAD_REQUEST}
end;
set_form(["config", "remusers"], Lang, XData) ->
@ -705,9 +701,7 @@ search_running_node(SNode, [Node | Nodes]) ->
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"}]}]};
{iq, ID, error, XMLNS, [SubEl, ?ERR_NOT_ALLOWED]};
allow ->
{User, _, _} = To,
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
@ -722,9 +716,7 @@ process_sm_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case XData of
invalid ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "400"}],
[{xmlcdata, "Bad Request"}]}]};
[SubEl, ?ERR_BAD_REQUEST]};
_ ->
Node =
string:tokens(
@ -745,9 +737,7 @@ process_sm_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
end;
_ ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]}
[SubEl, ?ERR_NOT_ALLOWED]}
end;
get ->
Node =

View File

@ -115,9 +115,18 @@ do_route(Host, From, To, Packet) ->
Packet, Error),
ejabberd_router:route(To, From, Err)
end;
{iq, ID, get, ?NS_VCARD = XMLNS, SubEl} ->
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
Res = {iq, ID, result, XMLNS,
[{xmlelement, "query",
[{"xmlns", XMLNS}],
iq_get_vcard(Lang)}]},
ejabberd_router:route(To,
From,
jlib:iq_to_xml(Res));
_ ->
Err = jlib:make_error_reply(
Packet, ?ERR_SERVICE_UNAVAILABLE),
Packet, ?ERR_FEATURE_NOT_IMPLEMENTED),
ejabberd_router:route(To, From, Err)
end;
_ ->
@ -212,7 +221,8 @@ iq_disco_info() ->
{"type", "text"},
{"name", "ejabberd/mod_muc"}], []},
{xmlelement, "feature", [{"var", ?NS_MUC}], []},
{xmlelement, "feature", [{"var", ?NS_REGISTER}], []}].
{xmlelement, "feature", [{"var", ?NS_REGISTER}], []},
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}].
process_iq_disco_items(Host, From, To, ID, SubEl) ->
@ -337,6 +347,17 @@ process_iq_register_set(From, SubEl) ->
{error, ?ERR_BAD_REQUEST}
end.
iq_get_vcard(Lang) ->
[{xmlelement, "FN", [],
[{xmlcdata, "ejabberd/mod_muc"}]},
{xmlelement, "URL", [],
[{xmlcdata,
"http://ejabberd.jabberstudio.org/"}]},
{xmlelement, "DESC", [],
[{xmlcdata, "ejabberd MUC module\n"
"Copyright (c) 2003 Alexey Shchepin"}]}].
can_use_nick(JID, "") ->
false;

View File

@ -306,7 +306,8 @@ normal_state({route, From, Nick,
case is_nick_exists(Nick, StateData) of
true ->
Err = jlib:make_error_reply(
Packet, ?ERR_MUC_NICK_CHANGE_CONFLICT),
Packet,
?ERR_MUC_NICK_CHANGE_CONFLICT),
ejabberd_router:route(
{StateData#state.room,
StateData#state.host,

View File

@ -54,18 +54,14 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case catch get_data(LUser, Els) of
{'EXIT', Reason} ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "500"}],
[{xmlcdata, "Internal Server Error"}]}]};
[SubEl, ?ERR_INTERNAL_SERVER_ERROR]};
Res ->
{iq, ID, result, XMLNS,
[{xmlelement, Name, Attrs, Res}]}
end
end;
_ ->
{iq, ID, error, XMLNS, [SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]}
{iq, ID, error, XMLNS, [SubEl, ?ERR_NOT_ALLOWED]}
end.
set_data(LUser, El) ->

View File

@ -50,11 +50,7 @@ process_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
{iq, ID, result, XMLNS, [SubEl]};
not_allowed ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement,
"error",
[{"code", "405"}],
[{xmlcdata,
"Not Allowed"}]}]};
[SubEl, ?ERR_NOT_ALLOWED]};
not_exists ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement,
@ -65,27 +61,15 @@ process_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
_ ->
{iq, ID, error, XMLNS,
[SubEl,
{xmlelement,
"error",
[{"code", "500"}],
[{xmlcdata,
"Internal Server Error"}]}]}
?ERR_INTERNAL_SERVER_ERROR]}
end;
true ->
{iq, ID, error, XMLNS,
[SubEl,
{xmlelement,
"error",
[{"code", "400"}],
[{xmlcdata,
"Bad Request"}]}]}
[SubEl, ?ERR_BAD_REQUEST]}
end
end;
{iq, ID, error, XMLNS,
[SubEl, {xmlelement,
"error",
[{"code", "501"}],
[{xmlcdata, "Not Implemented"}]}]};
[SubEl, ?ERR_FEATURE_NOT_IMPLEMENTED]};
(UTag /= false) and (PTag /= false) ->
User = xml:get_tag_cdata(UTag),
Password = xml:get_tag_cdata(PTag),
@ -119,7 +103,7 @@ process_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
try_register(User, Password) ->
case jlib:is_nodename(User) of
false ->
{error, "406", "Not Acceptable"};
{error, ?ERR_BAD_REQUEST};
_ ->
case ejabberd_auth:try_register(User, Password) of
{atomic, ok} ->

View File

@ -62,7 +62,7 @@ process_iq(From, To, IQ) ->
ignore;
_ ->
{iq, ID, error, XMLNS,
[SubEl, jlib:make_error_element("404", "Not Found")]}
[SubEl, ?ERR_JID_NOT_FOUND]}
end.
process_iq_get(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
@ -79,8 +79,7 @@ process_iq_get(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
XItems}]};
_ ->
{iq, ID, error, XMLNS,
[SubEl, jlib:make_error_element("500",
"Internal Server Error")]}
[SubEl, ?ERR_INTERNAL_SERVER_ERROR]}
end.
item_to_xml(Item) ->

View File

@ -31,9 +31,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
Lang = xml:get_tag_attr_s("xml:lang", SubEl),
case Type of
set ->
{iq, ID, error, XMLNS, [SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]};
{iq, ID, error, XMLNS, [SubEl, ?ERR_NOT_ALLOWED]};
get ->
{xmlelement, _, Attrs, Els} = SubEl,
Node = string:tokens(xml:get_tag_attr_s("node", SubEl), "/"),

View File

@ -32,9 +32,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case Type of
set ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]};
[SubEl, ?ERR_NOT_ALLOWED]};
get ->
UTC = jlib:timestamp_to_iso(calendar:universal_time()),
{iq, ID, result, XMLNS,

View File

@ -91,9 +91,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
{iq, ID, result, XMLNS, []};
_ ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]}
[SubEl, ?ERR_NOT_ALLOWED]}
end;
get ->
{iq, ID, result, XMLNS,
@ -116,9 +114,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
process_sm_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case Type of
set ->
{iq, ID, error, XMLNS, [SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]};
{iq, ID, error, XMLNS, [SubEl, ?ERR_NOT_ALLOWED]};
get ->
{User, _, _} = To,
LUser = jlib:tolower(User),
@ -217,7 +213,7 @@ do_route(From, To, Packet) ->
{User, Server, Resource} = To,
if
(User /= "") or (Resource /= "") ->
Err = jlib:make_error_reply(Packet, "503", "Service Unavailable"),
Err = jlib:make_error_reply(Packet, ?ERR_SERVICE_UNAVAILABLE),
ejabberd_router ! {route, To, From, Err};
true ->
IQ = jlib:iq_query_info(Packet),
@ -230,7 +226,7 @@ do_route(From, To, Packet) ->
case XDataEl of
false ->
Err = jlib:make_error_reply(
Packet, "400", "Bad Request"),
Packet, ?ERR_BAD_REQUEST),
ejabberd_router:route(To, From, Err);
_ ->
XData = jlib:parse_xdata_submit(XDataEl),
@ -238,7 +234,7 @@ do_route(From, To, Packet) ->
invalid ->
Err = jlib:make_error_reply(
Packet,
"400", "Bad Request"),
?ERR_BAD_REQUEST),
ejabberd_router:route(To, From,
Err);
_ ->
@ -271,7 +267,7 @@ do_route(From, To, Packet) ->
case Type of
set ->
Err = jlib:make_error_reply(
Packet, "405", "Not Allowed"),
Packet, ?ERR_NOT_ALLOWED),
ejabberd_router:route(To, From, Err);
get ->
ResIQ = {iq, ID, result, ?NS_DISCO_INFO,
@ -294,7 +290,7 @@ do_route(From, To, Packet) ->
case Type of
set ->
Err = jlib:make_error_reply(
Packet, "405", "Not Allowed"),
Packet, ?ERR_NOT_ALLOWED),
ejabberd_router:route(To, From, Err);
get ->
ResIQ = {iq, ID, result, ?NS_DISCO_INFO,
@ -307,7 +303,7 @@ do_route(From, To, Packet) ->
end;
_ ->
Err = jlib:make_error_reply(Packet,
"503", "Service Unavailable"),
?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route(To, From, Err)
end
end.

View File

@ -34,9 +34,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case Type of
set ->
{iq, ID, error, XMLNS,
[SubEl, {xmlelement, "error",
[{"code", "405"}],
[{xmlcdata, "Not Allowed"}]}]};
[SubEl, ?ERR_NOT_ALLOWED]};
get ->
OSType = case os:type() of
{Osfamily, Osname} ->