diff --git a/src/cyrsasl_digest.erl b/src/cyrsasl_digest.erl index fa5c5338b..a91566b66 100644 --- a/src/cyrsasl_digest.erl +++ b/src/cyrsasl_digest.erl @@ -39,7 +39,7 @@ -type get_password_fun() :: fun((binary()) -> {false, any()} | {binary(), atom()}). --type check_password_fun() :: fun((binary(), binary(), binary(), +-type check_password_fun() :: fun((binary(), binary(), binary(), binary(), fun((binary()) -> binary())) -> {boolean(), any()} | false). @@ -51,8 +51,8 @@ nonce = <<"">> :: binary(), username = <<"">> :: binary(), authzid = <<"">> :: binary(), - get_password = fun(_) -> {false, <<>>} end :: get_password_fun(), - check_password = fun(_, _, _, _, _) -> false end :: check_password_fun(), + get_password :: get_password_fun(), + check_password :: check_password_fun(), auth_module :: atom(), host = <<"">> :: binary(), hostfqdn = <<"">> :: binary() | [binary()]}). @@ -111,7 +111,7 @@ mech_step(#state{step = 3, nonce = Nonce} = State, {false, _} -> {error, not_authorized, UserName}; {Passwd, AuthModule} -> case (State#state.check_password)(UserName, UserName, <<"">>, - proplists:get_value(<<"response">>, KeyVals, <<>>), + proplists:get_value(<<"response">>, KeyVals, <<>>), fun (PW) -> response(KeyVals, UserName, diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index 5ab6cf980..176245782 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -56,7 +56,7 @@ -record(state, {limits = treap:empty() :: treap:treap()}). -record(captcha, {id :: binary(), - pid :: pid(), + pid :: pid() | undefined, key :: binary(), tref :: reference(), args :: any()}). diff --git a/src/ejabberd_receiver.erl b/src/ejabberd_receiver.erl index 13c6d3b7f..253ca93b4 100644 --- a/src/ejabberd_receiver.erl +++ b/src/ejabberd_receiver.erl @@ -93,7 +93,7 @@ change_shaper(Pid, Shaper) -> 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) -> do_call(Pid, {starttls, TLSSocket}). diff --git a/src/ejabberd_router_multicast.erl b/src/ejabberd_router_multicast.erl index c2a99528d..bb2442b4f 100644 --- a/src/ejabberd_router_multicast.erl +++ b/src/ejabberd_router_multicast.erl @@ -218,7 +218,7 @@ code_change(_OldVsn, State, _Extra) -> do_route(Domain, Destinations, Packet) -> ?DEBUG("route multicast:~n~s~nDomain: ~s~nDestinations: ~s~n", [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 case mnesia:dirty_read(route_multicast, Domain) of diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 578b3e7e0..20774369e 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -52,7 +52,7 @@ opts = [] :: opts() | '_' | '$2'}). -type opts() :: [{atom(), any()}]. --type db_type() :: sql | mnesia | riak. +-type db_type() :: atom(). -callback start(binary(), opts()) -> ok | {ok, pid()}. -callback stop(binary()) -> any(). diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index c9b87c177..fc07faacb 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -1460,7 +1460,7 @@ send_stanza(FromString, ToString, Stanza) -> try #xmlel{} = El = fxml_stream:parse_element(Stanza), #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]), ejabberd_router:route(xmpp:set_from_to(Pkt, From, To)) catch _:{xmpp_codec, Why} -> diff --git a/src/mod_announce.erl b/src/mod_announce.erl index 2c3730122..29def8378 100644 --- a/src/mod_announce.erl +++ b/src/mod_announce.erl @@ -406,7 +406,7 @@ commands_result(Allow, From, To, Request) -> announce_commands(From, To, Request) 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()}. announce_commands(Acc, From, #jid{lserver = LServer} = To, #adhoc_command{node = Node} = Request) -> diff --git a/src/mod_client_state.erl b/src/mod_client_state.erl index f57e3e32d..d912bef50 100644 --- a/src/mod_client_state.erl +++ b/src/mod_client_state.erl @@ -253,7 +253,7 @@ filter_other({Stanza, #{jid := JID} = C2SState} = Acc) when ?is_stanza(Stanza) - filter_other(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) -> case gen_mod:is_loaded(Host, ?MODULE) of true -> diff --git a/src/mod_delegation.erl b/src/mod_delegation.erl index ec58b3c46..b3377fe75 100644 --- a/src/mod_delegation.erl +++ b/src/mod_delegation.erl @@ -65,8 +65,7 @@ mod_opt_type(_) -> depends(_, _) -> []. --spec decode_iq_subel(xmpp_element()) -> xmpp_element(); - (xmlel()) -> xmlel(). +-spec decode_iq_subel(xmpp_element() | xmlel()) -> xmpp_element() | xmlel(). %% Tell gen_iq_handler not to auto-decode IQ payload decode_iq_subel(El) -> El. diff --git a/src/mod_legacy_auth.erl b/src/mod_legacy_auth.erl index 03a7c91af..16770983c 100644 --- a/src/mod_legacy_auth.erl +++ b/src/mod_legacy_auth.erl @@ -31,6 +31,8 @@ -include("xmpp.hrl"). +-type c2s_state() :: ejabberd_c2s:state(). + %%%=================================================================== %%% API %%%=================================================================== @@ -52,6 +54,8 @@ depends(_Host, _Opts) -> 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) when T == get; T == set -> 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, _) -> State. +-spec c2s_stream_features([xmpp_element()], binary()) -> [xmpp_element()]. c2s_stream_features(Acc, LServer) -> case gen_mod:is_loaded(LServer, ?MODULE) of true -> @@ -74,6 +79,7 @@ c2s_stream_features(Acc, LServer) -> %%%=================================================================== %%% Internal functions %%%=================================================================== +-spec authenticate(c2s_state(), iq()) -> c2s_state(). authenticate(#{server := Server} = State, #iq{type = get, sub_els = [#legacy_auth{}]} = IQ) -> LServer = jid:nameprep(Server), @@ -129,6 +135,7 @@ authenticate(#{stream_id := StreamID, server := Server, process_auth_failure(State, U, Err, 'forbidden') end. +-spec open_session(c2s_state(), iq(), binary()) -> c2s_state(). open_session(State, IQ, R) -> case ejabberd_c2s:bind(R, State) of {ok, State1} -> @@ -139,6 +146,7 @@ open_session(State, IQ, R) -> ejabberd_c2s:send(State1, Res) end. +-spec process_auth_failure(c2s_state(), binary(), stanza_error(), atom()) -> c2s_state(). process_auth_failure(State, User, StanzaErr, Reason) -> State1 = ejabberd_c2s:send(State, StanzaErr), ejabberd_c2s:handle_auth_failure(User, <<"legacy">>, Reason, State1).