mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
Fix all calls to functions of p1_tls application
This commit is contained in:
parent
66ad9e9722
commit
4dc80dddd4
@ -220,7 +220,7 @@ get_local_fqdn2() ->
|
||||
end.
|
||||
|
||||
hex(S) ->
|
||||
sha:to_hexlist(S).
|
||||
p1_sha:to_hexlist(S).
|
||||
|
||||
proplists_get_bin_value(Key, Pairs, Default) ->
|
||||
case proplists:get_value(Key, Pairs, Default) of
|
||||
|
@ -339,7 +339,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||
CompressFeature =
|
||||
case Zlib andalso
|
||||
((SockMod == gen_tcp) orelse
|
||||
(SockMod == tls)) of
|
||||
(SockMod == p1_tls)) of
|
||||
true ->
|
||||
[#xmlel{name = <<"compression">>,
|
||||
attrs = [{<<"xmlns">>, ?NS_FEATURE_COMPRESS}],
|
||||
@ -524,7 +524,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||
of
|
||||
true ->
|
||||
DGen = fun (PW) ->
|
||||
sha:sha(<<(StateData#state.streamid)/binary, PW/binary>>)
|
||||
p1_sha:sha(<<(StateData#state.streamid)/binary, PW/binary>>)
|
||||
end,
|
||||
case ejabberd_auth:check_password_with_authmodule(U,
|
||||
StateData#state.server,
|
||||
@ -709,7 +709,7 @@ wait_for_feature_request({xmlstreamelement, El},
|
||||
tls_enabled = true});
|
||||
{?NS_COMPRESS, <<"compress">>}
|
||||
when Zlib == true,
|
||||
(SockMod == gen_tcp) or (SockMod == tls) ->
|
||||
(SockMod == gen_tcp) or (SockMod == p1_tls) ->
|
||||
case xml:get_subtag(El, <<"method">>) of
|
||||
false ->
|
||||
send_element(StateData,
|
||||
@ -1738,11 +1738,11 @@ get_auth_tags([], U, P, D, R) ->
|
||||
get_conn_type(StateData) ->
|
||||
case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of
|
||||
gen_tcp -> c2s;
|
||||
tls -> c2s_tls;
|
||||
p1_tls -> c2s_tls;
|
||||
ezlib ->
|
||||
case ezlib:get_sockmod((StateData#state.socket)#socket_state.socket) of
|
||||
gen_tcp -> c2s_compressed;
|
||||
tls -> c2s_compressed_tls
|
||||
p1_tls -> c2s_compressed_tls
|
||||
end;
|
||||
ejabberd_http_poll -> http_poll;
|
||||
ejabberd_http_bind -> http_bind;
|
||||
|
@ -93,7 +93,7 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
|
||||
Id = <<(randoms:get_string())/binary>>,
|
||||
B64Image = jlib:encode_base64((Image)),
|
||||
JID = jlib:jid_to_string(From),
|
||||
CID = <<"sha1+", (sha:sha(Image))/binary,
|
||||
CID = <<"sha1+", (p1_sha:sha(Image))/binary,
|
||||
"@bob.xmpp.org">>,
|
||||
Data = #xmlel{name = <<"data">>,
|
||||
attrs =
|
||||
@ -185,7 +185,7 @@ create_captcha_x(SID, To, Lang, Limiter, HeadEls,
|
||||
{ok, Type, Key, Image} ->
|
||||
Id = <<(randoms:get_string())/binary>>,
|
||||
B64Image = jlib:encode_base64((Image)),
|
||||
CID = <<"sha1+", (sha:sha(Image))/binary,
|
||||
CID = <<"sha1+", (p1_sha:sha(Image))/binary,
|
||||
"@bob.xmpp.org">>,
|
||||
Data = #xmlel{name = <<"data">>,
|
||||
attrs =
|
||||
|
@ -170,20 +170,20 @@ init([Module, SockMod, Socket, Opts, Receiver]) ->
|
||||
%% Description: Handling call messages
|
||||
%%--------------------------------------------------------------------
|
||||
handle_call({starttls, TLSOpts}, _From, State) ->
|
||||
{ok, TLSSocket} = tls:tcp_to_tls(State#state.socket, TLSOpts),
|
||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(State#state.socket, TLSOpts),
|
||||
ejabberd_receiver:starttls(State#state.receiver, TLSSocket),
|
||||
Reply = ok,
|
||||
{reply, Reply, State#state{socket = TLSSocket, sockmod = tls},
|
||||
{reply, Reply, State#state{socket = TLSSocket, sockmod = p1_tls},
|
||||
?HIBERNATE_TIMEOUT};
|
||||
|
||||
handle_call({starttls, TLSOpts, Data}, _From, State) ->
|
||||
{ok, TLSSocket} = tls:tcp_to_tls(State#state.socket, TLSOpts),
|
||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(State#state.socket, TLSOpts),
|
||||
ejabberd_receiver:starttls(State#state.receiver, TLSSocket),
|
||||
catch (State#state.sockmod):send(
|
||||
State#state.socket, Data),
|
||||
Reply = ok,
|
||||
{reply, Reply,
|
||||
State#state{socket = TLSSocket, sockmod = tls},
|
||||
State#state{socket = TLSSocket, sockmod = p1_tls},
|
||||
?HIBERNATE_TIMEOUT};
|
||||
|
||||
handle_call({compress, Data}, _From, State) ->
|
||||
@ -210,10 +210,10 @@ handle_call(get_sockmod, _From, State) ->
|
||||
Reply = State#state.sockmod,
|
||||
{reply, Reply, State, ?HIBERNATE_TIMEOUT};
|
||||
handle_call(get_peer_certificate, _From, State) ->
|
||||
Reply = tls:get_peer_certificate(State#state.socket),
|
||||
Reply = p1_tls:get_peer_certificate(State#state.socket),
|
||||
{reply, Reply, State, ?HIBERNATE_TIMEOUT};
|
||||
handle_call(get_verify_result, _From, State) ->
|
||||
Reply = tls:get_verify_result(State#state.socket),
|
||||
Reply = p1_tls:get_verify_result(State#state.socket),
|
||||
{reply, Reply, State, ?HIBERNATE_TIMEOUT};
|
||||
handle_call(close, _From, State) ->
|
||||
ejabberd_receiver:close(State#state.receiver),
|
||||
@ -286,9 +286,9 @@ check_starttls(SockMod, Socket, Receiver, Opts) ->
|
||||
end, Opts),
|
||||
if
|
||||
TLSEnabled ->
|
||||
{ok, TLSSocket} = tls:tcp_to_tls(Socket, TLSOpts),
|
||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(Socket, TLSOpts),
|
||||
ejabberd_receiver:starttls(Receiver, TLSSocket),
|
||||
{tls, TLSSocket};
|
||||
{p1_tls, TLSSocket};
|
||||
true ->
|
||||
{SockMod, Socket}
|
||||
end.
|
||||
|
@ -99,9 +99,9 @@ init({SockMod, Socket}, Opts) ->
|
||||
TLSOpts = [verify_none | TLSOpts1],
|
||||
{SockMod1, Socket1} = if TLSEnabled ->
|
||||
inet:setopts(Socket, [{recbuf, 8192}]),
|
||||
{ok, TLSSocket} = tls:tcp_to_tls(Socket,
|
||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(Socket,
|
||||
TLSOpts),
|
||||
{tls, TLSSocket};
|
||||
{p1_tls, TLSSocket};
|
||||
true -> {SockMod, Socket}
|
||||
end,
|
||||
case SockMod1 of
|
||||
@ -326,8 +326,8 @@ get_transfer_protocol(SockMod, HostPort) ->
|
||||
{gen_tcp, []} -> {Host, 80, http};
|
||||
{gen_tcp, [Port]} ->
|
||||
{Host, jlib:binary_to_integer(Port), http};
|
||||
{tls, []} -> {Host, 443, https};
|
||||
{tls, [Port]} ->
|
||||
{p1_tls, []} -> {Host, 443, https};
|
||||
{p1_tls, [Port]} ->
|
||||
{Host, jlib:binary_to_integer(Port), https}
|
||||
end.
|
||||
|
||||
|
@ -217,7 +217,7 @@ process_request(Data, IP) ->
|
||||
"dressing' xmlns='",
|
||||
(?NS_HTTP_BIND)/binary, "'/>">>};
|
||||
XmppDomain ->
|
||||
Sid = sha:sha(term_to_binary({now(), make_ref()})),
|
||||
Sid = p1_sha:sha(term_to_binary({now(), make_ref()})),
|
||||
case start(XmppDomain, Sid, <<"">>, IP) of
|
||||
{error, _} ->
|
||||
{500, ?HEADER,
|
||||
@ -615,7 +615,7 @@ process_http_put(#http_put{rid = Rid, attrs = Attrs,
|
||||
case StateData#state.key of
|
||||
<<"">> -> true;
|
||||
OldKey ->
|
||||
NextKey = sha:sha(Key),
|
||||
NextKey = p1_sha:sha(Key),
|
||||
?DEBUG("Key/OldKey/NextKey: ~s/~s/~s",
|
||||
[Key, OldKey, NextKey]),
|
||||
if OldKey == NextKey -> true;
|
||||
|
@ -112,7 +112,7 @@ process([],
|
||||
{ok, ID1, Key, NewKey, Packet} ->
|
||||
ID = if
|
||||
(ID1 == <<"0">>) or (ID1 == <<"mobile">>) ->
|
||||
NewID = sha:sha(term_to_binary({now(), make_ref()})),
|
||||
NewID = p1_sha:sha(term_to_binary({now(), make_ref()})),
|
||||
{ok, Pid} = start(NewID, <<"">>, IP),
|
||||
mnesia:transaction(
|
||||
fun() ->
|
||||
|
@ -49,8 +49,8 @@
|
||||
-include("logger.hrl").
|
||||
|
||||
-record(state,
|
||||
{socket :: inet:socket() | tls:tls_socket() | ezlib:zlib_socket(),
|
||||
sock_mod = gen_tcp :: gen_tcp | tls | ezlib,
|
||||
{socket :: inet:socket() | p1_tls:tls_socket() | ezlib:zlib_socket(),
|
||||
sock_mod = gen_tcp :: gen_tcp | p1_tls | ezlib,
|
||||
shaper_state = none :: shaper:shaper(),
|
||||
c2s_pid :: pid(),
|
||||
max_stanza_size = infinity :: non_neg_integer() | infinity,
|
||||
@ -102,7 +102,7 @@ change_shaper(Pid, Shaper) ->
|
||||
|
||||
reset_stream(Pid) -> do_call(Pid, reset_stream).
|
||||
|
||||
-spec starttls(pid(), iodata()) -> {ok, tls:tls_socket()} | {error, any()}.
|
||||
-spec starttls(pid(), iodata()) -> {ok, p1_tls:tls_socket()} | {error, any()}.
|
||||
|
||||
starttls(Pid, TLSSocket) ->
|
||||
do_call(Pid, {starttls, TLSSocket}).
|
||||
@ -163,9 +163,9 @@ handle_call({starttls, TLSSocket}, _From,
|
||||
NewXMLStreamState = xml_stream:new(C2SPid,
|
||||
MaxStanzaSize),
|
||||
NewState = State#state{socket = TLSSocket,
|
||||
sock_mod = tls,
|
||||
sock_mod = p1_tls,
|
||||
xml_stream_state = NewXMLStreamState},
|
||||
case tls:recv_data(TLSSocket, <<"">>) of
|
||||
case p1_tls:recv_data(TLSSocket, <<"">>) of
|
||||
{ok, TLSData} ->
|
||||
{reply, ok, process_data(TLSData, NewState), ?HIBERNATE_TIMEOUT};
|
||||
{error, _Reason} ->
|
||||
@ -239,8 +239,8 @@ handle_info({Tag, _TCPSocket, Data},
|
||||
when (Tag == tcp) or (Tag == ssl) or
|
||||
(Tag == ejabberd_xml) ->
|
||||
case SockMod of
|
||||
tls ->
|
||||
case tls:recv_data(Socket, Data) of
|
||||
p1_tls ->
|
||||
case p1_tls:recv_data(Socket, Data) of
|
||||
{ok, TLSData} ->
|
||||
{noreply, process_data(TLSData, State),
|
||||
?HIBERNATE_TIMEOUT};
|
||||
|
@ -249,7 +249,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs},
|
||||
end,
|
||||
case SASL of
|
||||
{error_cert_verif, CertVerifyResult, Certificate} ->
|
||||
CertError = tls:get_cert_verify_string(CertVerifyResult,
|
||||
CertError = p1_tls:get_cert_verify_string(CertVerifyResult,
|
||||
Certificate),
|
||||
RemoteServer = xml:get_attr_s(<<"from">>, Attrs),
|
||||
?INFO_MSG("Closing s2s connection: ~s <--> ~s (~s)",
|
||||
|
@ -197,7 +197,7 @@ wait_for_handshake({xmlstreamelement, El}, StateData) ->
|
||||
#xmlel{name = Name, children = Els} = El,
|
||||
case {Name, xml:get_cdata(Els)} of
|
||||
{<<"handshake">>, Digest} ->
|
||||
case sha:sha(<<(StateData#state.streamid)/binary,
|
||||
case p1_sha:sha(<<(StateData#state.streamid)/binary,
|
||||
(StateData#state.password)/binary>>)
|
||||
of
|
||||
Digest ->
|
||||
|
@ -53,10 +53,10 @@
|
||||
|
||||
-type sockmod() :: ejabberd_http_poll |
|
||||
ejabberd_http_bind |
|
||||
gen_tcp | tls | ezlib.
|
||||
gen_tcp | p1_tls | ezlib.
|
||||
-type receiver() :: pid () | atom().
|
||||
-type socket() :: pid() | inet:socket() |
|
||||
tls:tls_socket() |
|
||||
p1_tls:tls_socket() |
|
||||
ezlib:zlib_socket() |
|
||||
ejabberd_http_bind:bind_socket() |
|
||||
ejabberd_http_poll:poll_socket().
|
||||
@ -150,15 +150,15 @@ connect(Addr, Port, Opts, Timeout) ->
|
||||
end.
|
||||
|
||||
starttls(SocketData, TLSOpts) ->
|
||||
{ok, TLSSocket} = tls:tcp_to_tls(SocketData#socket_state.socket, TLSOpts),
|
||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(SocketData#socket_state.socket, TLSOpts),
|
||||
ejabberd_receiver:starttls(SocketData#socket_state.receiver, TLSSocket),
|
||||
SocketData#socket_state{socket = TLSSocket, sockmod = tls}.
|
||||
SocketData#socket_state{socket = TLSSocket, sockmod = p1_tls}.
|
||||
|
||||
starttls(SocketData, TLSOpts, Data) ->
|
||||
{ok, TLSSocket} = tls:tcp_to_tls(SocketData#socket_state.socket, TLSOpts),
|
||||
{ok, TLSSocket} = p1_tls:tcp_to_tls(SocketData#socket_state.socket, TLSOpts),
|
||||
ejabberd_receiver:starttls(SocketData#socket_state.receiver, TLSSocket),
|
||||
send(SocketData, Data),
|
||||
SocketData#socket_state{socket = TLSSocket, sockmod = tls}.
|
||||
SocketData#socket_state{socket = TLSSocket, sockmod = p1_tls}.
|
||||
|
||||
compress(SocketData) -> compress(SocketData, undefined).
|
||||
|
||||
@ -221,10 +221,10 @@ get_sockmod(SocketData) ->
|
||||
SocketData#socket_state.sockmod.
|
||||
|
||||
get_peer_certificate(SocketData) ->
|
||||
tls:get_peer_certificate(SocketData#socket_state.socket).
|
||||
p1_tls:get_peer_certificate(SocketData#socket_state.socket).
|
||||
|
||||
get_verify_result(SocketData) ->
|
||||
tls:get_verify_result(SocketData#socket_state.socket).
|
||||
p1_tls:get_verify_result(SocketData#socket_state.socket).
|
||||
|
||||
close(SocketData) ->
|
||||
ejabberd_receiver:close(SocketData#socket_state.receiver).
|
||||
|
@ -469,10 +469,10 @@ make_disco_hash(DiscoEls, Algo) ->
|
||||
jlib:encode_base64(case Algo of
|
||||
md5 -> crypto:md5(Concat);
|
||||
sha1 -> crypto:sha(Concat);
|
||||
sha224 -> sha:sha224(Concat);
|
||||
sha256 -> sha:sha256(Concat);
|
||||
sha384 -> sha:sha384(Concat);
|
||||
sha512 -> sha:sha512(Concat)
|
||||
sha224 -> p1_sha:sha224(Concat);
|
||||
sha256 -> p1_sha:sha256(Concat);
|
||||
sha384 -> p1_sha:sha384(Concat);
|
||||
sha512 -> p1_sha:sha512(Concat)
|
||||
end).
|
||||
|
||||
check_hash(Caps, Els) ->
|
||||
|
@ -818,7 +818,7 @@ flush() -> receive _ -> flush() after 0 -> ok end.
|
||||
|
||||
iq_get_unique(From) ->
|
||||
{xmlcdata,
|
||||
sha:sha(term_to_binary([From, now(),
|
||||
p1_sha:sha(term_to_binary([From, now(),
|
||||
randoms:get_string()]))}.
|
||||
|
||||
get_nick(ServerHost, Host, From) ->
|
||||
|
@ -190,7 +190,7 @@ process_iq(InitiatorJID,
|
||||
jlib:jid_to_string(jlib:jid_tolower(TargetJID)),
|
||||
Initiator =
|
||||
jlib:jid_to_string(jlib:jid_tolower(InitiatorJID)),
|
||||
SHA1 = sha:sha(<<SID/binary, Initiator/binary, Target/binary>>),
|
||||
SHA1 = p1_sha:sha(<<SID/binary, Initiator/binary, Target/binary>>),
|
||||
case mod_proxy65_sm:activate_stream(SHA1, InitiatorJID,
|
||||
TargetJID, ServerHost)
|
||||
of
|
||||
|
@ -147,7 +147,7 @@ process_local_iq(From, To, #iq{type = Type} = IQ) ->
|
||||
end.
|
||||
|
||||
roster_hash(Items) ->
|
||||
sha:sha(term_to_binary(lists:sort([R#roster{groups =
|
||||
p1_sha:sha(term_to_binary(lists:sort([R#roster{groups =
|
||||
lists:sort(Grs)}
|
||||
|| R = #roster{groups = Grs}
|
||||
<- Items]))).
|
||||
@ -211,7 +211,7 @@ write_roster_version_t(LUser, LServer) ->
|
||||
write_roster_version(LUser, LServer, true).
|
||||
|
||||
write_roster_version(LUser, LServer, InTransaction) ->
|
||||
Ver = sha:sha(term_to_binary(now())),
|
||||
Ver = p1_sha:sha(term_to_binary(now())),
|
||||
write_roster_version(LUser, LServer, InTransaction, Ver,
|
||||
gen_mod:db_type(LServer, ?MODULE)),
|
||||
Ver.
|
||||
|
@ -70,7 +70,7 @@ vcard_set(LUser, LServer, VCARD) ->
|
||||
<<>> -> remove_xupdate(LUser, LServer);
|
||||
BinVal ->
|
||||
add_xupdate(LUser, LServer,
|
||||
sha:sha(jlib:decode_base64(BinVal)))
|
||||
p1_sha:sha(jlib:decode_base64(BinVal)))
|
||||
end,
|
||||
ejabberd_sm:force_update_presence(US).
|
||||
|
||||
|
@ -1096,7 +1096,7 @@ sasl_new(<<"DIGEST-MD5">>, User, Server, Password) ->
|
||||
end}.
|
||||
|
||||
hex(S) ->
|
||||
sha:to_hexlist(S).
|
||||
p1_sha:to_hexlist(S).
|
||||
|
||||
response(User, Passwd, Nonce, AuthzId, Realm, CNonce,
|
||||
DigestURI, NC, QOP, A2Prefix) ->
|
||||
@ -1188,7 +1188,7 @@ make_iq_result(#iq{from = From} = IQ) ->
|
||||
|
||||
socks5_connect(#streamhost{host = Host, port = Port},
|
||||
{SID, JID1, JID2}) ->
|
||||
Hash = sha:sha([SID, jlib:jid_to_string(JID1), jlib:jid_to_string(JID2)]),
|
||||
Hash = p1_sha:sha([SID, jlib:jid_to_string(JID1), jlib:jid_to_string(JID2)]),
|
||||
{ok, Sock} = gen_tcp:connect(binary_to_list(Host), Port,
|
||||
[binary, {active, false}]),
|
||||
Init = <<?VERSION_5, 1, ?AUTH_ANONYMOUS>>,
|
||||
|
Loading…
Reference in New Issue
Block a user