Fix compilation and Xref warnings

This commit is contained in:
Badlop 2022-07-27 00:55:43 +02:00
parent b96efd7df2
commit 6be46dacc9
9 changed files with 28 additions and 27 deletions

View File

@ -136,7 +136,7 @@ get_password(_, _) ->
{cache, error}.
-spec get_password_s(binary(), binary()) -> {cache, error}.
get_password_s(User, Server) ->
get_password_s(_User, _Server) ->
{cache, error}.
-spec user_exists(binary(), binary()) -> {ets_cache:tag(), boolean()}.
@ -161,7 +161,7 @@ remove_user(LUser, LServer, Password) ->
{error, not_allowed};
{ok, true} ->
remove_user_req(LUser, LServer, <<"">>, <<"remove_user">>);
{error, Error} ->
{error, _Error} ->
{error, db_failure}
end
end.
@ -195,9 +195,9 @@ make_req(Method, Path, LUser, LServer, Password) ->
false -> <<"/">>
end,
BasicAuth64 = base64:encode(BasicAuth),
LUserE = list_to_binary(http_uri:encode(binary_to_list(LUser))),
LServerE = list_to_binary(http_uri:encode(binary_to_list(LServer))),
PasswordE = list_to_binary(http_uri:encode(binary_to_list(Password))),
LUserE = list_to_binary(misc:uri_parse(binary_to_list(LUser))),
LServerE = list_to_binary(misc:uri_parse(binary_to_list(LServer))),
PasswordE = list_to_binary(misc:uri_parse(binary_to_list(Password))),
Query = <<"user=", LUserE/binary, "&server=", LServerE/binary, "&pass=", PasswordE/binary>>,
Header = [{<<"Authorization">>, <<"Basic ", BasicAuth64/binary>>}],
ContentType = {<<"Content-Type">>, <<"application/x-www-form-urlencoded">>},

View File

@ -61,7 +61,7 @@
-spec salted_password(binary(), binary(), non_neg_integer()) -> binary().
salted_password(Password, Salt, IterationCount) ->
hi(jlib:resourceprep(Password), Salt, IterationCount).
hi(jid:resourceprep(Password), Salt, IterationCount).
-spec client_key(binary()) -> binary().
client_key(SaltedPassword) ->
@ -106,7 +106,7 @@ hi_round(Password, UPrev, IterationCount) ->
enabled(Host) ->
case ejabberd_config:get_option({auth_opts, Host}, fun(V) -> V end) of
case ejabberd_config:get_option({auth_opts, Host}) of
undefined ->
false;
AuthOpts ->
@ -116,7 +116,7 @@ enabled(Host) ->
iterations() -> ?SCRAM_DEFAULT_ITERATION_COUNT.
iterations(Host) ->
case ejabberd_config:get_option({auth_opts, Host}, fun(V) -> V end) of
case ejabberd_config:get_option({auth_opts, Host}) of
undefined ->
iterations();
AuthOpts ->
@ -179,7 +179,7 @@ scram_to_tuple(Scram) ->
-spec check_digest(scram(), binary(), fun(), binary()) -> boolean().
check_digest(#scram{storedkey = StoredKey}, Digest, DigestGen, Password) ->
Passwd = jlib:decode_base64(StoredKey),
Passwd = base64:decode(StoredKey),
DigRes = if Digest /= <<"">> ->
Digest == DigestGen(Passwd);
true -> false
@ -188,11 +188,5 @@ check_digest(#scram{storedkey = StoredKey}, Digest, DigestGen, Password) ->
true -> (Passwd == Password) and (Password /= <<"">>)
end.
-ifdef(no_crypto_hmac).
crypto_hmac(sha, Key, Data) ->
crypto:sha_mac(Key, Data).
-else.
crypto_hmac(sha, Key, Data) ->
crypto:hmac(sha, Key, Data).
-endif.
misc:crypto_hmac(sha, Key, Data).

View File

@ -51,7 +51,7 @@ sheet_body(PrevState) ->
Host,
length(ejabberd_sm:get_user_resources(Username, Host)),
length(mod_roster:get_roster(Username, Host)),
mod_offline:get_queue_length(Username, Host),
mod_offline:count_offline_messages(Username, Host),
get_last_activity(Username, Host)
]
end

View File

@ -23,7 +23,7 @@
-define(GLOBAL_HOOKS, [component_connected, component_disconnected]).
-export([start/2, stop/1, mod_opt_type/1,
-export([start/2, stop/1, mod_opt_type/1, mod_options/1,
depends/2, mod_doc/0, udp_loop_start/1, push/2]).
-export([offline_message_hook/3,
@ -50,9 +50,9 @@ start(Host, Opts) ->
|| Hook <- ?HOOKS],
[ejabberd_hooks:add(Hook, ?MODULE, Hook, 18)
|| Hook <- ?GLOBAL_HOOKS],
StatsDH = gen_mod:get_opt(statsdhost, Opts, fun(X) -> X end, "localhost"),
StatsDH = gen_mod:get_opt(statsdhost, Opts),
{ok, StatsDHost} = getaddrs(StatsDH),
StatsDPort = gen_mod:get_opt(statsdport, Opts, fun(X) -> X end, 8125),
StatsDPort = gen_mod:get_opt(statsdport, Opts),
register(?PROCNAME, spawn(?MODULE, udp_loop_start, [#state{host = StatsDHost, port = StatsDPort}])),
ok.
@ -113,7 +113,7 @@ push(Host, Probe) ->
whereis(?PROCNAME) ! {send, Payload}.
encode_metrics(Host, Probe) ->
[_, NodeId] = str:tokens(jlib:atom_to_binary(node()), <<"@">>),
[_, NodeId] = str:tokens(misc:atom_to_binary(node()), <<"@">>),
[Node | _] = str:tokens(NodeId, <<".">>),
Data = case Probe of
{Key, Val} ->
@ -198,7 +198,13 @@ timestamp() ->
%% mod Options
%%====================================================================
mod_opt_type(statsdhost) -> fun(X) -> X end;
mod_opt_type(statsdport) -> fun(X) when is_integer(X) -> X end;
mod_opt_type(statsdhost) ->
econf:string();
mod_opt_type(statsdport) ->
econf:pos_int();
mod_opt_type(_) ->
[statsdhost, statsdport].
mod_options(_Host) ->
[{statsdhost, "localhost"},
{statsdport, 8125}].

View File

@ -64,6 +64,7 @@ start(Host, Opts) ->
stop(Host) ->
ejabberd_hooks:delete(reopen_log_hook, Host, ?MODULE, reopen_log, 50),
ejabberd_hooks:delete(forbidden_session_hook, Host, ?MODULE, forbidden, 50),
ejabberd_hooks:delete(c2s_auth_result, Host, ?MODULE, failed_auth, 50),
ejabberd_commands:unregister_commands(commands()),
Proc = get_process_name(Host),
exit(whereis(Proc), stop),

View File

@ -131,7 +131,7 @@ init([_Host, Opts]) ->
{ok, #state{filename = Filename, iodevice = IoDevice}}.
-spec handle_call(_, {pid(), _}, state()) -> {noreply, state()}.
handle_call(get_filename, From, State) ->
handle_call(get_filename, _From, State) ->
{reply, {filename, State#state.filename}, State};
handle_call(_Request, _From, State) ->
{noreply, State}.

View File

@ -133,7 +133,7 @@ report_error(ReportArgs) ->
ok = error_logger:error_report([ mod_post_log_cannot_post | ReportArgs ]).
format_jid(JID) ->
binary_to_list(jid:to_string(JID)).
binary_to_list(jid:encode(JID)).
%% Erlang now()-style timestamps are in UTC by definition, and we are
%% assuming ISO 8601 dates should be printed in UTC as well, so no

View File

@ -70,7 +70,7 @@ start(_Host, Opts) ->
stop(Host) ->
Blacklists = gen_mod:get_module_opt(Host, ?MODULE, blacklists),
lists:map(fun banword_gen_server:stop/1, Blacklists),
lists:map(fun banword_gen_server:stop/0, Blacklists),
CharMaps = gen_mod:get_module_opt(Host, ?MODULE, charmaps),
lists:map(fun normalize_leet_gen_server:stop/1, CharMaps),
ejabberd_hooks:delete(filter_packet, global, ?MODULE, on_filter_packet, 0),

View File

@ -606,7 +606,7 @@ get_proc_name(Host) ->
-spec get_spam_filter_hosts() -> [binary()].
get_spam_filter_hosts() ->
[H || H <- ejabberd_config:get_myhosts(), gen_mod:is_loaded(H, ?MODULE)].
[H || H <- ejabberd_option:hosts(), gen_mod:is_loaded(H, ?MODULE)].
-spec expand_host(binary() | none, binary()) -> binary() | none.
expand_host(none, _Host) ->