Fix errors detected with Dialyzer (#277)
This commit is contained in:
parent
857d350a71
commit
b8c42a4766
|
@ -97,10 +97,10 @@ log_packet_receive({Packet, C2SState}) ->
|
||||||
log_packet(From, To, #message{type = Type} = Packet, Host) ->
|
log_packet(From, To, #message{type = Type} = Packet, Host) ->
|
||||||
case Type of
|
case Type of
|
||||||
groupchat -> %% mod_muc_log already does it
|
groupchat -> %% mod_muc_log already does it
|
||||||
?DEBUG("dropping groupchat: ~s", [fxml:element_to_binary(Packet)]),
|
?DEBUG("dropping groupchat: ~s", [fxml:element_to_binary(xmpp:encode(Packet))]),
|
||||||
ok;
|
ok;
|
||||||
error -> %% we don't log errors
|
error -> %% we don't log errors
|
||||||
?DEBUG("dropping error: ~s", [fxml:element_to_binary(Packet)]),
|
?DEBUG("dropping error: ~s", [fxml:element_to_binary(xmpp:encode(Packet))]),
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
write_packet(From, To, Packet, Host)
|
write_packet(From, To, Packet, Host)
|
||||||
|
@ -116,15 +116,15 @@ write_packet(From, To, Packet, Host) ->
|
||||||
end,
|
end,
|
||||||
Format = Config#config.format,
|
Format = Config#config.format,
|
||||||
{Subject, Body} = {case Packet#message.subject of
|
{Subject, Body} = {case Packet#message.subject of
|
||||||
false ->
|
[] ->
|
||||||
"";
|
<<>>;
|
||||||
SubjEl ->
|
SubjEl ->
|
||||||
escape(Format, xmpp:get_text(SubjEl))
|
escape(Format, xmpp:get_text(SubjEl))
|
||||||
end,
|
end,
|
||||||
escape(Format, xmpp:get_text(Packet#message.body))},
|
escape(Format, xmpp:get_text(Packet#message.body))},
|
||||||
case Subject == <<>> andalso Body == <<>> of
|
case Subject == <<>> andalso Body == <<>> of
|
||||||
true -> %% don't log empty messages
|
true -> %% don't log empty messages
|
||||||
?DEBUG("not logging empty message from ~s",[jlib:jid_to_string(From)]),
|
?DEBUG("not logging empty message from ~s",[jid:encode(From)]),
|
||||||
ok;
|
ok;
|
||||||
false ->
|
false ->
|
||||||
Path = Config#config.path,
|
Path = Config#config.path,
|
||||||
|
@ -153,7 +153,7 @@ write_packet(From, To, Packet, Host) ->
|
||||||
end,
|
end,
|
||||||
?DEBUG("FilenameTemplate ~p~n",[FilenameTemplate]),
|
?DEBUG("FilenameTemplate ~p~n",[FilenameTemplate]),
|
||||||
Filename = make_filename(FilenameTemplate, [Y, M, D]),
|
Filename = make_filename(FilenameTemplate, [Y, M, D]),
|
||||||
?DEBUG("logging message from ~s into ~s~n",[jlib:jid_to_string(From), Filename]),
|
?DEBUG("logging message from ~s into ~s~n",[jid:encode(From), Filename]),
|
||||||
File = case file:read_file_info(Filename) of
|
File = case file:read_file_info(Filename) of
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
open_logfile(Filename);
|
open_logfile(Filename);
|
||||||
|
@ -163,7 +163,7 @@ write_packet(From, To, Packet, Host) ->
|
||||||
io:format(NewFile, Header, []),
|
io:format(NewFile, Header, []),
|
||||||
NewFile
|
NewFile
|
||||||
end,
|
end,
|
||||||
MessageText = case Subject == [] of
|
MessageText = case Subject == <<>> of
|
||||||
true ->
|
true ->
|
||||||
Body;
|
Body;
|
||||||
false ->
|
false ->
|
||||||
|
@ -209,10 +209,7 @@ escape(html, <<>>, Acc) ->
|
||||||
Acc.
|
Acc.
|
||||||
|
|
||||||
escape(html, Text) -> escape(html,Text,<<>>);
|
escape(html, Text) -> escape(html,Text,<<>>);
|
||||||
escape(text, Text) ->
|
escape(text, Text) -> Text.
|
||||||
Text;
|
|
||||||
escape(_, "") ->
|
|
||||||
"".
|
|
||||||
|
|
||||||
% return the number of occurence of Word in String
|
% return the number of occurence of Word in String
|
||||||
count(String, Word) ->
|
count(String, Word) ->
|
||||||
|
|
|
@ -153,6 +153,4 @@ make_message(Host, {failed_auth, Username, {IPTuple, IPPort}, Reason}) ->
|
||||||
io_lib:format("Failed authentication for ~s@~s from ~s port ~p: ~s",
|
io_lib:format("Failed authentication for ~s@~s from ~s port ~p: ~s",
|
||||||
[Username, Host, IPString, IPPort, Reason]);
|
[Username, Host, IPString, IPPort, Reason]);
|
||||||
make_message(_Host, {forbidden, JID}) ->
|
make_message(_Host, {forbidden, JID}) ->
|
||||||
io_lib:format("Forbidden session for ~s",
|
io_lib:format("Forbidden session for ~s", [jid:encode(JID)]).
|
||||||
[jlib:jid_to_string(JID)]).
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@ serve(LocalPathBin, #request{host = Host} = Request) ->
|
||||||
{error, eisdir} ->
|
{error, eisdir} ->
|
||||||
FileNameIndex = FileName ++ "/index.html",
|
FileNameIndex = FileName ++ "/index.html",
|
||||||
case file:read_file_info(FileNameIndex) of
|
case file:read_file_info(FileNameIndex) of
|
||||||
{ok, _FileInfo} -> serve(LocalPath ++ ["index.html"], Request);
|
{ok, _FileInfo} ->
|
||||||
|
serve(LocalPathBin ++ [<<"index.html">>], Request);
|
||||||
{error, _Error} -> show_dir_listing(FileName, LocalPath)
|
{error, _Error} -> show_dir_listing(FileName, LocalPath)
|
||||||
end;
|
end;
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
|
|
|
@ -50,8 +50,7 @@ depends(_Host, _Opts) ->
|
||||||
|
|
||||||
process([], #request{method = 'POST', data = Data, host = Host, ip = ClientIp}) ->
|
process([], #request{method = 'POST', data = Data, host = Host, ip = ClientIp}) ->
|
||||||
try
|
try
|
||||||
{ClientAddress, _PortNumber} = ClientIp,
|
check_member_option(Host, ClientIp, allowed_ips),
|
||||||
check_member_option(Host, ClientAddress, allowed_ips),
|
|
||||||
maybe_post_request(Data, Host, ClientIp)
|
maybe_post_request(Data, Host, ClientIp)
|
||||||
catch
|
catch
|
||||||
error:{badmatch, _} = Error ->
|
error:{badmatch, _} = Error ->
|
||||||
|
@ -136,9 +135,9 @@ check_member_option(Host, Element, Option) ->
|
||||||
AllowedValues -> lists:member(Element, AllowedValues)
|
AllowedValues -> lists:member(Element, AllowedValues)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
ip_matches(ClientIp, AllowedValues) ->
|
ip_matches({Address, Port}, AllowedValues) ->
|
||||||
lists:any(fun({Net, Mask}) ->
|
lists:any(fun({Net, Mask}) ->
|
||||||
acl:match_acl(useless_host, {ip,{Net,Mask}}, #{ip => {ClientIp,useless_port}})
|
acl:match_acl(global, {ip,{Net,Mask}}, #{ip => Address})
|
||||||
end,
|
end,
|
||||||
AllowedValues).
|
AllowedValues).
|
||||||
|
|
||||||
|
@ -146,10 +145,8 @@ post_request(Pkt) ->
|
||||||
From = xmpp:get_from(Pkt),
|
From = xmpp:get_from(Pkt),
|
||||||
LServer = From#jid.lserver,
|
LServer = From#jid.lserver,
|
||||||
ejabberd_hooks:run_fold(user_send_packet, LServer, {Pkt, #{jid => From}}, []),
|
ejabberd_hooks:run_fold(user_send_packet, LServer, {Pkt, #{jid => From}}, []),
|
||||||
case ejabberd_router:route(Pkt) of
|
ejabberd_router:route(Pkt),
|
||||||
ok -> {200, [], <<"Ok">>};
|
{200, [], <<"Ok">>}.
|
||||||
_ -> {500, [], <<"Error">>}
|
|
||||||
end.
|
|
||||||
|
|
||||||
%% Split a line into args. Args are splitted by blankspaces. Args can be enclosed in "".
|
%% Split a line into args. Args are splitted by blankspaces. Args can be enclosed in "".
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -1149,8 +1149,7 @@ web_page_main(_, #request{path=[<<"statsdx">>, <<"top">>, Topic, Topnumber], q =
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
{stop, Res};
|
{stop, Res};
|
||||||
web_page_main(_, #request{path=[<<"statsdx">> | FilterURL], q = Q, lang = Lang} = _Request) ->
|
web_page_main(_, #request{path=[<<"statsdx">> | Filter], q = Q, lang = Lang} = _Request) ->
|
||||||
Filter = parse_url_filter(FilterURL),
|
|
||||||
Sort_query = get_sort_query(Q),
|
Sort_query = get_sort_query(Q),
|
||||||
FilterS = io_lib:format("~p", [Filter]),
|
FilterS = io_lib:format("~p", [Filter]),
|
||||||
Res = [?XC(<<"h1">>, <<(translate:translate(Lang, ?T("Statistics")))/binary, " Dx">>),
|
Res = [?XC(<<"h1">>, <<(translate:translate(Lang, ?T("Statistics")))/binary, " Dx">>),
|
||||||
|
@ -1196,8 +1195,8 @@ get_sort_query(Q) ->
|
||||||
_ -> {normal, 1}
|
_ -> {normal, 1}
|
||||||
end.
|
end.
|
||||||
get_sort_query2(Q) ->
|
get_sort_query2(Q) ->
|
||||||
{value, {_, String}} = lists:keysearch("sort", 1, Q),
|
{value, {_, Binary}} = lists:keysearch(<<"sort">>, 1, Q),
|
||||||
Integer = list_to_integer(String),
|
Integer = binary_to_integer(Binary),
|
||||||
case Integer >= 0 of
|
case Integer >= 0 of
|
||||||
true -> {ok, {normal, Integer}};
|
true -> {ok, {normal, Integer}};
|
||||||
false -> {ok, {reverse, abs(Integer)}}
|
false -> {ok, {reverse, abs(Integer)}}
|
||||||
|
@ -1226,16 +1225,6 @@ make_sessions_table_tr(Lang) ->
|
||||||
Titles),
|
Titles),
|
||||||
Titles_TR.
|
Titles_TR.
|
||||||
|
|
||||||
%% @spec (Filter::string()) -> [{Class::string(), Type::string()}]
|
|
||||||
parse_url_filter(FilterURL) ->
|
|
||||||
[List] = string:tokens(FilterURL, "/"),
|
|
||||||
parse_url_filter(List, []).
|
|
||||||
parse_url_filter([Class, Type | List], Res) ->
|
|
||||||
parse_url_filter(List, Res ++ [{Class, Type}]);
|
|
||||||
parse_url_filter(_, Res) ->
|
|
||||||
Res.
|
|
||||||
|
|
||||||
|
|
||||||
web_page_node(_, Node, [<<"statsdx">>], _Query, Lang) ->
|
web_page_node(_, Node, [<<"statsdx">>], _Query, Lang) ->
|
||||||
TransactionsCommited =
|
TransactionsCommited =
|
||||||
rpc:call(Node, mnesia, system_info, [transaction_commits]),
|
rpc:call(Node, mnesia, system_info, [transaction_commits]),
|
||||||
|
@ -1491,9 +1480,8 @@ web_page_host(_, Host, #request{path=[<<"statsdx">>, <<"top">>, Topic, Topnumber
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
{stop, Res};
|
{stop, Res};
|
||||||
web_page_host(_, Host, #request{path=[<<"statsdx">> | FilterURL], q = Q,
|
web_page_host(_, Host, #request{path=[<<"statsdx">> | Filter], q = Q,
|
||||||
lang = Lang} = _Request) ->
|
lang = Lang} = _Request) ->
|
||||||
Filter = parse_url_filter(FilterURL),
|
|
||||||
Sort_query = get_sort_query(Q),
|
Sort_query = get_sort_query(Q),
|
||||||
Res = [?XC(<<"h1">>, <<(translate:translate(Lang, ?T("Statistics")))/binary, " Dx">>),
|
Res = [?XC(<<"h1">>, <<(translate:translate(Lang, ?T("Statistics")))/binary, " Dx">>),
|
||||||
?XC(<<"h2">>, list_to_binary("Sessions with: "++io_lib:format("~p", [Filter]))),
|
?XC(<<"h2">>, list_to_binary("Sessions with: "++io_lib:format("~p", [Filter]))),
|
||||||
|
@ -1590,15 +1578,15 @@ get_sessions_filtered(Filter, server) ->
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
[],
|
[],
|
||||||
ejabberd_config:get_myhosts());
|
ejabberd_config:get_option(hosts));
|
||||||
get_sessions_filtered(Filter, Host) ->
|
get_sessions_filtered(Filter, Host) ->
|
||||||
Match = case Filter of
|
Match = case Filter of
|
||||||
[{<<"client">>, Client}] -> {{session, '$1'}, misc:binary_to_atom(Client), '$2', '$3', '$4', '$5', '$6', '$7'};
|
[<<"client">>, Client] -> {{session, '$1'}, misc:binary_to_atom(Client), '$2', '$3', '$4', '$5', '$6', '$7'};
|
||||||
[{<<"os">>, OS}] -> {{session, '$1'}, '$2', misc:binary_to_atom(OS), '$3', '$4', '$5', '$6', '$7'};
|
[<<"os">>, OS] -> {{session, '$1'}, '$2', misc:binary_to_atom(OS), '$3', '$4', '$5', '$6', '$7'};
|
||||||
[{<<"conntype">>, ConnType}] -> {{session, '$1'}, '$2', '$3', '$4', misc:binary_to_atom(ConnType), '$5', '$6', '$7'};
|
[<<"conntype">>, ConnType] -> {{session, '$1'}, '$2', '$3', '$4', misc:binary_to_atom(ConnType), '$5', '$6', '$7'};
|
||||||
[{<<"languages">>, Lang}] -> {{session, '$1'}, '$2', '$3', binary_to_list(Lang), '$4', '$5', '$6', '$7'};
|
[<<"languages">>, Lang] -> {{session, '$1'}, '$2', '$3', binary_to_list(Lang), '$4', '$5', '$6', '$7'};
|
||||||
[{<<"client">>, Client}, {<<"os">>, OS}] -> {{session, '$1'}, misc:binary_to_atom(Client), misc:binary_to_atom(OS), '$3', '$4', '$5', '$6', '$7'};
|
[<<"client">>, Client, <<"os">>, OS] -> {{session, '$1'}, misc:binary_to_atom(Client), misc:binary_to_atom(OS), '$3', '$4', '$5', '$6', '$7'};
|
||||||
[{<<"client">>, Client}, {<<"conntype">>, ConnType}] -> {{session, '$1'}, misc:binary_to_atom(Client), '$2', '$3', misc:binary_to_atom(ConnType), '$5', '$6', '$7'};
|
[<<"client">>, Client, <<"conntype">>, ConnType] -> {{session, '$1'}, misc:binary_to_atom(Client), '$2', '$3', misc:binary_to_atom(ConnType), '$5', '$6', '$7'};
|
||||||
_ -> {{session, '$1'}, '$2', '$3', '$4', '$5'}
|
_ -> {{session, '$1'}, '$2', '$3', '$4', '$5'}
|
||||||
end,
|
end,
|
||||||
ets:match_object(table_name(Host), Match).
|
ets:match_object(table_name(Host), Match).
|
||||||
|
|
|
@ -242,7 +242,6 @@ do_route1(_Host, _From, _To, #iq{} = IQ, _BaseURL) ->
|
||||||
do_route1(_Host, _From, _To, Packet, _BaseURL) ->
|
do_route1(_Host, _From, _To, Packet, _BaseURL) ->
|
||||||
case xmpp:get_type(Packet) of
|
case xmpp:get_type(Packet) of
|
||||||
error -> ok;
|
error -> ok;
|
||||||
result -> ok;
|
|
||||||
_ ->
|
_ ->
|
||||||
Err = xmpp:err_item_not_found(),
|
Err = xmpp:err_item_not_found(),
|
||||||
ejabberd_router:route_error(Packet, Err)
|
ejabberd_router:route_error(Packet, Err)
|
||||||
|
@ -397,10 +396,6 @@ iq_set_register_info(ServerHost, Host, From, Nick,
|
||||||
Lang) ->
|
Lang) ->
|
||||||
case iq_set_register_info2(ServerHost, Host, From, Nick, Lang) of
|
case iq_set_register_info2(ServerHost, Host, From, Nick, Lang) of
|
||||||
{atomic, ok} -> {result, undefined};
|
{atomic, ok} -> {result, undefined};
|
||||||
{atomic, false} ->
|
|
||||||
ErrText = <<"That nickname is registered by another "
|
|
||||||
"person">>,
|
|
||||||
{error, xmpp:err_conflict(ErrText, Lang)};
|
|
||||||
_ ->
|
_ ->
|
||||||
Txt = <<"Database failure">>,
|
Txt = <<"Database failure">>,
|
||||||
{error, xmpp:err_internal_server_error(Txt, Lang)}
|
{error, xmpp:err_internal_server_error(Txt, Lang)}
|
||||||
|
@ -919,7 +914,7 @@ process2([User, Server | Tail], Request) ->
|
||||||
|
|
||||||
serve_web_presence(TypeURL, User, Server, Tail, #request{lang = Lang1, q = Q}) ->
|
serve_web_presence(TypeURL, User, Server, Tail, #request{lang = Lang1, q = Q}) ->
|
||||||
LServer = jid:nameprep(Server),
|
LServer = jid:nameprep(Server),
|
||||||
true = lists:member(Server, ejabberd_config:get_myhosts()),
|
true = lists:member(Server, ejabberd_config:get_option(hosts)),
|
||||||
LUser = jid:nodeprep(User),
|
LUser = jid:nodeprep(User),
|
||||||
WP = get_wp(LUser, LServer),
|
WP = get_wp(LUser, LServer),
|
||||||
case TypeURL of
|
case TypeURL of
|
||||||
|
|
Loading…
Reference in New Issue