-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).
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()]}).
{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,
-record(state, {limits = treap:empty() :: treap:treap()}).
-record(captcha, {id :: binary(),
- pid :: pid(),
+ pid :: pid() | undefined,
key :: binary(),
tref :: reference(),
args :: any()}).
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}).
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
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().
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} ->
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) ->
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 ->
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.
-include("xmpp.hrl").
+-type c2s_state() :: ejabberd_c2s:state().
+
%%%===================================================================
%%% API
%%%===================================================================
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
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 ->
%%%===================================================================
%%% 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),
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} ->
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).