25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Switch to fast_tls and update app names

This commit is contained in:
Mickael Remond 2016-02-03 16:13:16 +01:00
parent 9ae1371c6e
commit 71ee0d56fa
12 changed files with 46 additions and 47 deletions

View File

@ -35,8 +35,8 @@
headers = [] :: [{atom() | binary(), binary()}]}).
-record(ws,
{socket :: inet:socket() | p1_tls:tls_socket(),
sockmod = gen_tcp :: gen_tcp | p1_tls,
{socket :: inet:socket() | fast_tls:tls_socket(),
sockmod = gen_tcp :: gen_tcp | fast_tls,
ip :: {inet:ip_address(), inet:port_number()},
host = <<"">> :: binary(),
port = 5280 :: inet:port_number(),

View File

@ -25,9 +25,9 @@ defmodule Ejabberd.Mixfile do
[mod: {:ejabberd_app, []},
applications: [:ssl],
included_applications: [:lager, :mnesia, :p1_utils, :cache_tab,
:p1_tls, :stringprep, :p1_xml,
:stun, :yaml, :ezlib, :iconv,
:esip, :jiffy, :oauth2, :xmlrpc, :eredis,
:fast_tls, :stringprep, :p1_xml,
:stun, :fast_yaml, :ezlib, :iconv,
:esip, :jiffy, :p1_oauth2, :p1_xmlrpc, :eredis,
:p1_mysql, :p1_pgsql, :sqlite3]]
end
@ -43,7 +43,7 @@ defmodule Ejabberd.Mixfile do
{:cache_tab, "~> 1.0"},
{:stringprep, "~> 1.0"},
{:fast_yaml, "~> 1.0"},
{:p1_tls, git: "https://github.com/processone/tls", tag: "1.0.0"},
{:fast_tls, "~> 1.0"},
{:p1_xml, git: "https://github.com/processone/xml", tag: "1.1.2"},
{:stun, "~> 1.0"},
{:esip, "~> 1.0"},

View File

@ -15,7 +15,6 @@
"p1_mysql": {:hex, :p1_mysql, "1.0.1"},
"p1_oauth2": {:hex, :p1_oauth2, "0.6.1"},
"p1_pgsql": {:hex, :p1_pgsql, "1.0.1"},
"p1_tls": {:git, "https://github.com/processone/tls", "f19e1f701e0a3980ffc70b3917c4aa85e68d8520", [tag: "1.0.0"]},
"p1_utils": {:hex, :p1_utils, "1.0.3"},
"p1_xml": {:git, "https://github.com/processone/xml", "79c6d54e56bf991f1ec70ceb5e255afcb8dbf53f", [tag: "1.1.2"]},
"p1_xmlrpc": {:hex, :p1_xmlrpc, "1.15.1"},

View File

@ -10,7 +10,7 @@
{deps, [{lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.0.2"}}},
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}},
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.2"}}},
{p1_tls, ".*", {git, "https://github.com/processone/tls", {tag, "1.0.0"}}},
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.1"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.2"}}},
{p1_xml, ".*", {git, "https://github.com/processone/xml", {tag, "1.1.2"}}},
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.1"}}},
@ -37,12 +37,12 @@
{if_var_true, latest_deps,
{floating_deps, [p1_logger,
cache_tab,
p1_tls,
fast_tls,
stringprep,
p1_xml,
esip,
luerl,
p1_stun,
stun,
fast_yaml,
p1_utils,
p1_mysql,
@ -94,7 +94,7 @@
{eunit_compile_opts, [{i, "tools"}]}.
{post_hook_configure, [{"p1_tls", []},
{post_hook_configure, [{"fast_tls", []},
{"stringprep", []},
{"fast_yaml", []},
{"esip", []},

View File

@ -253,7 +253,7 @@ start_apps() ->
ejabberd:start_app(sasl),
ejabberd:start_app(ssl),
ejabberd:start_app(fast_yaml),
ejabberd:start_app(p1_tls),
ejabberd:start_app(fast_tls),
ejabberd:start_app(p1_xml),
ejabberd:start_app(stringprep),
ejabberd:start_app(ezlib),

View File

@ -408,7 +408,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
(StateData#state.sockmod):get_sockmod(StateData#state.socket),
Zlib = StateData#state.zlib,
CompressFeature = case Zlib andalso
((SockMod == gen_tcp) orelse (SockMod == p1_tls)) of
((SockMod == gen_tcp) orelse (SockMod == fast_tls)) of
true ->
[#xmlel{name = <<"compression">>,
attrs = [{<<"xmlns">>, ?NS_FEATURE_COMPRESS}],
@ -813,7 +813,7 @@ wait_for_feature_request({xmlstreamelement, El},
tls_enabled = true});
{?NS_COMPRESS, <<"compress">>}
when Zlib == true,
(SockMod == gen_tcp) or (SockMod == p1_tls) ->
(SockMod == gen_tcp) or (SockMod == fast_tls) ->
case xml:get_subtag(El, <<"method">>) of
false ->
send_element(StateData,
@ -1955,11 +1955,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;
p1_tls -> c2s_tls;
fast_tls -> c2s_tls;
ezlib ->
case ezlib:get_sockmod((StateData#state.socket)#socket_state.socket) of
gen_tcp -> c2s_compressed;
p1_tls -> c2s_compressed_tls
fast_tls -> c2s_compressed_tls
end;
ejabberd_http_bind -> http_bind;
ejabberd_http_ws -> websocket;

View File

@ -148,20 +148,20 @@ init([Module, SockMod, Socket, Opts, Receiver]) ->
receiver = Receiver}}.
handle_call({starttls, TLSOpts}, _From, State) ->
{ok, TLSSocket} = p1_tls:tcp_to_tls(State#state.socket, TLSOpts),
{ok, TLSSocket} = fast_tls:tcp_to_tls(State#state.socket, TLSOpts),
ejabberd_receiver:starttls(State#state.receiver, TLSSocket),
Reply = ok,
{reply, Reply, State#state{socket = TLSSocket, sockmod = p1_tls},
{reply, Reply, State#state{socket = TLSSocket, sockmod = fast_tls},
?HIBERNATE_TIMEOUT};
handle_call({starttls, TLSOpts, Data}, _From, State) ->
{ok, TLSSocket} = p1_tls:tcp_to_tls(State#state.socket, TLSOpts),
{ok, TLSSocket} = fast_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 = p1_tls},
State#state{socket = TLSSocket, sockmod = fast_tls},
?HIBERNATE_TIMEOUT};
handle_call({compress, Data}, _From, State) ->
{ok, ZlibSocket} =
@ -187,10 +187,10 @@ handle_call(get_sockmod, _From, State) ->
Reply = State#state.sockmod,
{reply, Reply, State, ?HIBERNATE_TIMEOUT};
handle_call(get_peer_certificate, _From, State) ->
Reply = p1_tls:get_peer_certificate(State#state.socket),
Reply = fast_tls:get_peer_certificate(State#state.socket),
{reply, Reply, State, ?HIBERNATE_TIMEOUT};
handle_call(get_verify_result, _From, State) ->
Reply = p1_tls:get_verify_result(State#state.socket),
Reply = fast_tls:get_verify_result(State#state.socket),
{reply, Reply, State, ?HIBERNATE_TIMEOUT};
handle_call(close, _From, State) ->
ejabberd_receiver:close(State#state.receiver),
@ -236,9 +236,9 @@ check_starttls(SockMod, Socket, Receiver, Opts) ->
(_) -> false
end, Opts),
if TLSEnabled ->
{ok, TLSSocket} = p1_tls:tcp_to_tls(Socket, TLSOpts),
{ok, TLSSocket} = fast_tls:tcp_to_tls(Socket, TLSOpts),
ejabberd_receiver:starttls(Receiver, TLSSocket),
{p1_tls, TLSSocket};
{fast_tls, TLSSocket};
true ->
{SockMod, Socket}
end.

View File

@ -117,9 +117,9 @@ init({SockMod, Socket}, Opts) ->
TLSOpts = [verify_none | TLSOpts3],
{SockMod1, Socket1} = if TLSEnabled ->
inet:setopts(Socket, [{recbuf, 8192}]),
{ok, TLSSocket} = p1_tls:tcp_to_tls(Socket,
{ok, TLSSocket} = fast_tls:tcp_to_tls(Socket,
TLSOpts),
{p1_tls, TLSSocket};
{fast_tls, TLSSocket};
true -> {SockMod, Socket}
end,
Captcha = case proplists:get_bool(captcha, Opts) of
@ -328,8 +328,8 @@ get_transfer_protocol(SockMod, HostPort) ->
{gen_tcp, []} -> {Host, 80, http};
{gen_tcp, [Port]} ->
{Host, jlib:binary_to_integer(Port), http};
{p1_tls, []} -> {Host, 443, https};
{p1_tls, [Port]} ->
{fast_tls, []} -> {Host, 443, https};
{fast_tls, [Port]} ->
{Host, jlib:binary_to_integer(Port), https}
end.

View File

@ -48,8 +48,8 @@
-include("logger.hrl").
-record(state,
{socket :: inet:socket() | p1_tls:tls_socket() | ezlib:zlib_socket(),
sock_mod = gen_tcp :: gen_tcp | p1_tls | ezlib,
{socket :: inet:socket() | fast_tls:tls_socket() | ezlib:zlib_socket(),
sock_mod = gen_tcp :: gen_tcp | fast_tls | ezlib,
shaper_state = none :: shaper:shaper(),
c2s_pid :: pid(),
max_stanza_size = infinity :: non_neg_integer() | infinity,
@ -89,7 +89,7 @@ change_shaper(Pid, Shaper) ->
reset_stream(Pid) -> do_call(Pid, reset_stream).
-spec starttls(pid(), p1_tls:tls_socket()) -> ok.
-spec starttls(pid(), fast_tls:tls_socket()) -> ok.
starttls(Pid, TLSSocket) ->
do_call(Pid, {starttls, TLSSocket}).
@ -129,8 +129,8 @@ init([Socket, SockMod, Shaper, MaxStanzaSize]) ->
handle_call({starttls, TLSSocket}, _From, State) ->
State1 = reset_parser(State),
NewState = State1#state{socket = TLSSocket,
sock_mod = p1_tls},
case p1_tls:recv_data(TLSSocket, <<"">>) of
sock_mod = fast_tls},
case fast_tls:recv_data(TLSSocket, <<"">>) of
{ok, TLSData} ->
{reply, ok,
process_data(TLSData, NewState), ?HIBERNATE_TIMEOUT};
@ -182,8 +182,8 @@ handle_info({Tag, _TCPSocket, Data},
when (Tag == tcp) or (Tag == ssl) or
(Tag == ejabberd_xml) ->
case SockMod of
p1_tls ->
case p1_tls:recv_data(Socket, Data) of
fast_tls ->
case fast_tls:recv_data(Socket, Data) of
{ok, TLSData} ->
{noreply, process_data(TLSData, State),
?HIBERNATE_TIMEOUT};

View File

@ -214,7 +214,7 @@ check_peer_certificate(SockMod, Sock, Peer) ->
end
end;
VerifyRes ->
{error, p1_tls:get_cert_verify_string(VerifyRes, Cert)}
{error, fast_tls:get_cert_verify_string(VerifyRes, Cert)}
end;
{error, _Reason} ->
{error, <<"Cannot get peer certificate">>};

View File

@ -52,10 +52,10 @@
-type sockmod() :: ejabberd_http_bind |
ejabberd_http_ws |
gen_tcp | p1_tls | ezlib.
gen_tcp | fast_tls | ezlib.
-type receiver() :: pid () | atom().
-type socket() :: pid() | inet:socket() |
p1_tls:tls_socket() |
fast_tls:tls_socket() |
ezlib:zlib_socket() |
ejabberd_http_bind:bind_socket().
@ -145,15 +145,15 @@ connect(Addr, Port, Opts, Timeout) ->
end.
starttls(SocketData, TLSOpts) ->
{ok, TLSSocket} = p1_tls:tcp_to_tls(SocketData#socket_state.socket, TLSOpts),
{ok, TLSSocket} = fast_tls:tcp_to_tls(SocketData#socket_state.socket, TLSOpts),
ejabberd_receiver:starttls(SocketData#socket_state.receiver, TLSSocket),
SocketData#socket_state{socket = TLSSocket, sockmod = p1_tls}.
SocketData#socket_state{socket = TLSSocket, sockmod = fast_tls}.
starttls(SocketData, TLSOpts, Data) ->
{ok, TLSSocket} = p1_tls:tcp_to_tls(SocketData#socket_state.socket, TLSOpts),
{ok, TLSSocket} = fast_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 = p1_tls}.
SocketData#socket_state{socket = TLSSocket, sockmod = fast_tls}.
compress(SocketData) -> compress(SocketData, undefined).
@ -216,10 +216,10 @@ get_sockmod(SocketData) ->
SocketData#socket_state.sockmod.
get_peer_certificate(SocketData) ->
p1_tls:get_peer_certificate(SocketData#socket_state.socket).
fast_tls:get_peer_certificate(SocketData#socket_state.socket).
get_verify_result(SocketData) ->
p1_tls:get_verify_result(SocketData#socket_state.socket).
fast_tls:get_verify_result(SocketData#socket_state.socket).
close(SocketData) ->
ejabberd_receiver:close(SocketData#socket_state.receiver).

View File

@ -373,10 +373,10 @@ process_frame(#frame_info{unprocessed =
process_frame(FrameInfo#frame_info{unprocessed = <<>>},
<<UnprocessedPre/binary, Data/binary>>).
handle_data(tcp, FrameInfo, Data, Socket, WsHandleLoopPid, p1_tls) ->
case p1_tls:recv_data(Socket, Data) of
handle_data(tcp, FrameInfo, Data, Socket, WsHandleLoopPid, fast_tls) ->
case fast_tls:recv_data(Socket, Data) of
{ok, NewData} ->
handle_data_int(FrameInfo, NewData, Socket, WsHandleLoopPid, p1_tls);
handle_data_int(FrameInfo, NewData, Socket, WsHandleLoopPid, fast_tls);
{error, Error} ->
{error, Error}
end;