mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
Fix some dialyzer warnings
This commit is contained in:
parent
8b2d308498
commit
218eeae797
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
-type get_password_fun() :: fun((binary()) -> {false, any()} |
|
-type get_password_fun() :: fun((binary()) -> {false, any()} |
|
||||||
{binary(), atom()}).
|
{binary(), atom()}).
|
||||||
-type check_password_fun() :: fun((binary(), binary(), binary(),
|
-type check_password_fun() :: fun((binary(), binary(), binary(), binary(),
|
||||||
fun((binary()) -> binary())) ->
|
fun((binary()) -> binary())) ->
|
||||||
{boolean(), any()} |
|
{boolean(), any()} |
|
||||||
false).
|
false).
|
||||||
@ -51,8 +51,8 @@
|
|||||||
nonce = <<"">> :: binary(),
|
nonce = <<"">> :: binary(),
|
||||||
username = <<"">> :: binary(),
|
username = <<"">> :: binary(),
|
||||||
authzid = <<"">> :: binary(),
|
authzid = <<"">> :: binary(),
|
||||||
get_password = fun(_) -> {false, <<>>} end :: get_password_fun(),
|
get_password :: get_password_fun(),
|
||||||
check_password = fun(_, _, _, _, _) -> false end :: check_password_fun(),
|
check_password :: check_password_fun(),
|
||||||
auth_module :: atom(),
|
auth_module :: atom(),
|
||||||
host = <<"">> :: binary(),
|
host = <<"">> :: binary(),
|
||||||
hostfqdn = <<"">> :: binary() | [binary()]}).
|
hostfqdn = <<"">> :: binary() | [binary()]}).
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
-record(state, {limits = treap:empty() :: treap:treap()}).
|
-record(state, {limits = treap:empty() :: treap:treap()}).
|
||||||
|
|
||||||
-record(captcha, {id :: binary(),
|
-record(captcha, {id :: binary(),
|
||||||
pid :: pid(),
|
pid :: pid() | undefined,
|
||||||
key :: binary(),
|
key :: binary(),
|
||||||
tref :: reference(),
|
tref :: reference(),
|
||||||
args :: any()}).
|
args :: any()}).
|
||||||
|
@ -93,7 +93,7 @@ change_shaper(Pid, Shaper) ->
|
|||||||
|
|
||||||
reset_stream(Pid) -> do_call(Pid, reset_stream).
|
reset_stream(Pid) -> do_call(Pid, reset_stream).
|
||||||
|
|
||||||
-spec starttls(pid(), fast_tls:tls_socket()) -> ok.
|
-spec starttls(pid(), fast_tls:tls_socket()) -> ok | {error, any()}.
|
||||||
|
|
||||||
starttls(Pid, TLSSocket) ->
|
starttls(Pid, TLSSocket) ->
|
||||||
do_call(Pid, {starttls, TLSSocket}).
|
do_call(Pid, {starttls, TLSSocket}).
|
||||||
|
@ -218,7 +218,7 @@ code_change(_OldVsn, State, _Extra) ->
|
|||||||
do_route(Domain, Destinations, Packet) ->
|
do_route(Domain, Destinations, Packet) ->
|
||||||
?DEBUG("route multicast:~n~s~nDomain: ~s~nDestinations: ~s~n",
|
?DEBUG("route multicast:~n~s~nDomain: ~s~nDestinations: ~s~n",
|
||||||
[xmpp:pp(Packet), Domain,
|
[xmpp:pp(Packet), Domain,
|
||||||
str:join([jid:to_string(To) || To <- Destinations], ", ")]),
|
str:join([jid:to_string(To) || To <- Destinations], <<", ">>)]),
|
||||||
%% Try to find an appropriate multicast service
|
%% Try to find an appropriate multicast service
|
||||||
case mnesia:dirty_read(route_multicast, Domain) of
|
case mnesia:dirty_read(route_multicast, Domain) of
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
opts = [] :: opts() | '_' | '$2'}).
|
opts = [] :: opts() | '_' | '$2'}).
|
||||||
|
|
||||||
-type opts() :: [{atom(), any()}].
|
-type opts() :: [{atom(), any()}].
|
||||||
-type db_type() :: sql | mnesia | riak.
|
-type db_type() :: atom().
|
||||||
|
|
||||||
-callback start(binary(), opts()) -> ok | {ok, pid()}.
|
-callback start(binary(), opts()) -> ok | {ok, pid()}.
|
||||||
-callback stop(binary()) -> any().
|
-callback stop(binary()) -> any().
|
||||||
|
@ -1460,7 +1460,7 @@ send_stanza(FromString, ToString, Stanza) ->
|
|||||||
try
|
try
|
||||||
#xmlel{} = El = fxml_stream:parse_element(Stanza),
|
#xmlel{} = El = fxml_stream:parse_element(Stanza),
|
||||||
#jid{} = From = jid:from_string(FromString),
|
#jid{} = From = jid:from_string(FromString),
|
||||||
#jid{} = To = jid:to_string(ToString),
|
#jid{} = To = jid:from_string(ToString),
|
||||||
Pkt = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
|
Pkt = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
|
||||||
ejabberd_router:route(xmpp:set_from_to(Pkt, From, To))
|
ejabberd_router:route(xmpp:set_from_to(Pkt, From, To))
|
||||||
catch _:{xmpp_codec, Why} ->
|
catch _:{xmpp_codec, Why} ->
|
||||||
|
@ -406,7 +406,7 @@ commands_result(Allow, From, To, Request) ->
|
|||||||
announce_commands(From, To, Request)
|
announce_commands(From, To, Request)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec announce_commands(adhoc_command(), jid(), jid(), adhoc_command()) ->
|
-spec announce_commands(empty | adhoc_command(), jid(), jid(), adhoc_command()) ->
|
||||||
adhoc_command() | {error, stanza_error()}.
|
adhoc_command() | {error, stanza_error()}.
|
||||||
announce_commands(Acc, From, #jid{lserver = LServer} = To,
|
announce_commands(Acc, From, #jid{lserver = LServer} = To,
|
||||||
#adhoc_command{node = Node} = Request) ->
|
#adhoc_command{node = Node} = Request) ->
|
||||||
|
@ -253,7 +253,7 @@ filter_other({Stanza, #{jid := JID} = C2SState} = Acc) when ?is_stanza(Stanza) -
|
|||||||
filter_other(Acc) ->
|
filter_other(Acc) ->
|
||||||
Acc.
|
Acc.
|
||||||
|
|
||||||
-spec add_stream_feature([xmpp_element()], binary) -> [xmpp_element()].
|
-spec add_stream_feature([xmpp_element()], binary()) -> [xmpp_element()].
|
||||||
add_stream_feature(Features, Host) ->
|
add_stream_feature(Features, Host) ->
|
||||||
case gen_mod:is_loaded(Host, ?MODULE) of
|
case gen_mod:is_loaded(Host, ?MODULE) of
|
||||||
true ->
|
true ->
|
||||||
|
@ -65,8 +65,7 @@ mod_opt_type(_) ->
|
|||||||
depends(_, _) ->
|
depends(_, _) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
-spec decode_iq_subel(xmpp_element()) -> xmpp_element();
|
-spec decode_iq_subel(xmpp_element() | xmlel()) -> xmpp_element() | xmlel().
|
||||||
(xmlel()) -> xmlel().
|
|
||||||
%% Tell gen_iq_handler not to auto-decode IQ payload
|
%% Tell gen_iq_handler not to auto-decode IQ payload
|
||||||
decode_iq_subel(El) ->
|
decode_iq_subel(El) ->
|
||||||
El.
|
El.
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
-include("xmpp.hrl").
|
-include("xmpp.hrl").
|
||||||
|
|
||||||
|
-type c2s_state() :: ejabberd_c2s:state().
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% API
|
%%% API
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
@ -52,6 +54,8 @@ depends(_Host, _Opts) ->
|
|||||||
mod_opt_type(_) ->
|
mod_opt_type(_) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
|
-spec c2s_unauthenticated_packet(c2s_state(), iq()) ->
|
||||||
|
c2s_state() | {stop, c2s_state()}.
|
||||||
c2s_unauthenticated_packet(State, #iq{type = T, sub_els = [_]} = IQ)
|
c2s_unauthenticated_packet(State, #iq{type = T, sub_els = [_]} = IQ)
|
||||||
when T == get; T == set ->
|
when T == get; T == set ->
|
||||||
case xmpp:get_subtag(IQ, #legacy_auth{}) of
|
case xmpp:get_subtag(IQ, #legacy_auth{}) of
|
||||||
@ -63,6 +67,7 @@ c2s_unauthenticated_packet(State, #iq{type = T, sub_els = [_]} = IQ)
|
|||||||
c2s_unauthenticated_packet(State, _) ->
|
c2s_unauthenticated_packet(State, _) ->
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
-spec c2s_stream_features([xmpp_element()], binary()) -> [xmpp_element()].
|
||||||
c2s_stream_features(Acc, LServer) ->
|
c2s_stream_features(Acc, LServer) ->
|
||||||
case gen_mod:is_loaded(LServer, ?MODULE) of
|
case gen_mod:is_loaded(LServer, ?MODULE) of
|
||||||
true ->
|
true ->
|
||||||
@ -74,6 +79,7 @@ c2s_stream_features(Acc, LServer) ->
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
-spec authenticate(c2s_state(), iq()) -> c2s_state().
|
||||||
authenticate(#{server := Server} = State,
|
authenticate(#{server := Server} = State,
|
||||||
#iq{type = get, sub_els = [#legacy_auth{}]} = IQ) ->
|
#iq{type = get, sub_els = [#legacy_auth{}]} = IQ) ->
|
||||||
LServer = jid:nameprep(Server),
|
LServer = jid:nameprep(Server),
|
||||||
@ -129,6 +135,7 @@ authenticate(#{stream_id := StreamID, server := Server,
|
|||||||
process_auth_failure(State, U, Err, 'forbidden')
|
process_auth_failure(State, U, Err, 'forbidden')
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec open_session(c2s_state(), iq(), binary()) -> c2s_state().
|
||||||
open_session(State, IQ, R) ->
|
open_session(State, IQ, R) ->
|
||||||
case ejabberd_c2s:bind(R, State) of
|
case ejabberd_c2s:bind(R, State) of
|
||||||
{ok, State1} ->
|
{ok, State1} ->
|
||||||
@ -139,6 +146,7 @@ open_session(State, IQ, R) ->
|
|||||||
ejabberd_c2s:send(State1, Res)
|
ejabberd_c2s:send(State1, Res)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec process_auth_failure(c2s_state(), binary(), stanza_error(), atom()) -> c2s_state().
|
||||||
process_auth_failure(State, User, StanzaErr, Reason) ->
|
process_auth_failure(State, User, StanzaErr, Reason) ->
|
||||||
State1 = ejabberd_c2s:send(State, StanzaErr),
|
State1 = ejabberd_c2s:send(State, StanzaErr),
|
||||||
ejabberd_c2s:handle_auth_failure(User, <<"legacy">>, Reason, State1).
|
ejabberd_c2s:handle_auth_failure(User, <<"legacy">>, Reason, State1).
|
||||||
|
Loading…
Reference in New Issue
Block a user