25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +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()}]}). headers = [] :: [{atom() | binary(), binary()}]}).
-record(ws, -record(ws,
{socket :: inet:socket() | p1_tls:tls_socket(), {socket :: inet:socket() | fast_tls:tls_socket(),
sockmod = gen_tcp :: gen_tcp | p1_tls, sockmod = gen_tcp :: gen_tcp | fast_tls,
ip :: {inet:ip_address(), inet:port_number()}, ip :: {inet:ip_address(), inet:port_number()},
host = <<"">> :: binary(), host = <<"">> :: binary(),
port = 5280 :: inet:port_number(), port = 5280 :: inet:port_number(),

View File

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

View File

@ -15,7 +15,6 @@
"p1_mysql": {:hex, :p1_mysql, "1.0.1"}, "p1_mysql": {:hex, :p1_mysql, "1.0.1"},
"p1_oauth2": {:hex, :p1_oauth2, "0.6.1"}, "p1_oauth2": {:hex, :p1_oauth2, "0.6.1"},
"p1_pgsql": {:hex, :p1_pgsql, "1.0.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_utils": {:hex, :p1_utils, "1.0.3"},
"p1_xml": {:git, "https://github.com/processone/xml", "79c6d54e56bf991f1ec70ceb5e255afcb8dbf53f", [tag: "1.1.2"]}, "p1_xml": {:git, "https://github.com/processone/xml", "79c6d54e56bf991f1ec70ceb5e255afcb8dbf53f", [tag: "1.1.2"]},
"p1_xmlrpc": {:hex, :p1_xmlrpc, "1.15.1"}, "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"}}}, {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"}}}, {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"}}}, {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"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.2"}}},
{p1_xml, ".*", {git, "https://github.com/processone/xml", {tag, "1.1.2"}}}, {p1_xml, ".*", {git, "https://github.com/processone/xml", {tag, "1.1.2"}}},
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.1"}}}, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.1"}}},
@ -37,12 +37,12 @@
{if_var_true, latest_deps, {if_var_true, latest_deps,
{floating_deps, [p1_logger, {floating_deps, [p1_logger,
cache_tab, cache_tab,
p1_tls, fast_tls,
stringprep, stringprep,
p1_xml, p1_xml,
esip, esip,
luerl, luerl,
p1_stun, stun,
fast_yaml, fast_yaml,
p1_utils, p1_utils,
p1_mysql, p1_mysql,
@ -94,7 +94,7 @@
{eunit_compile_opts, [{i, "tools"}]}. {eunit_compile_opts, [{i, "tools"}]}.
{post_hook_configure, [{"p1_tls", []}, {post_hook_configure, [{"fast_tls", []},
{"stringprep", []}, {"stringprep", []},
{"fast_yaml", []}, {"fast_yaml", []},
{"esip", []}, {"esip", []},

View File

@ -253,7 +253,7 @@ start_apps() ->
ejabberd:start_app(sasl), ejabberd:start_app(sasl),
ejabberd:start_app(ssl), ejabberd:start_app(ssl),
ejabberd:start_app(fast_yaml), ejabberd:start_app(fast_yaml),
ejabberd:start_app(p1_tls), ejabberd:start_app(fast_tls),
ejabberd:start_app(p1_xml), ejabberd:start_app(p1_xml),
ejabberd:start_app(stringprep), ejabberd:start_app(stringprep),
ejabberd:start_app(ezlib), 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), (StateData#state.sockmod):get_sockmod(StateData#state.socket),
Zlib = StateData#state.zlib, Zlib = StateData#state.zlib,
CompressFeature = case Zlib andalso CompressFeature = case Zlib andalso
((SockMod == gen_tcp) orelse (SockMod == p1_tls)) of ((SockMod == gen_tcp) orelse (SockMod == fast_tls)) of
true -> true ->
[#xmlel{name = <<"compression">>, [#xmlel{name = <<"compression">>,
attrs = [{<<"xmlns">>, ?NS_FEATURE_COMPRESS}], attrs = [{<<"xmlns">>, ?NS_FEATURE_COMPRESS}],
@ -813,7 +813,7 @@ wait_for_feature_request({xmlstreamelement, El},
tls_enabled = true}); tls_enabled = true});
{?NS_COMPRESS, <<"compress">>} {?NS_COMPRESS, <<"compress">>}
when Zlib == true, when Zlib == true,
(SockMod == gen_tcp) or (SockMod == p1_tls) -> (SockMod == gen_tcp) or (SockMod == fast_tls) ->
case xml:get_subtag(El, <<"method">>) of case xml:get_subtag(El, <<"method">>) of
false -> false ->
send_element(StateData, send_element(StateData,
@ -1955,11 +1955,11 @@ get_auth_tags([], U, P, D, R) ->
get_conn_type(StateData) -> get_conn_type(StateData) ->
case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of
gen_tcp -> c2s; gen_tcp -> c2s;
p1_tls -> c2s_tls; fast_tls -> c2s_tls;
ezlib -> ezlib ->
case ezlib:get_sockmod((StateData#state.socket)#socket_state.socket) of case ezlib:get_sockmod((StateData#state.socket)#socket_state.socket) of
gen_tcp -> c2s_compressed; gen_tcp -> c2s_compressed;
p1_tls -> c2s_compressed_tls fast_tls -> c2s_compressed_tls
end; end;
ejabberd_http_bind -> http_bind; ejabberd_http_bind -> http_bind;
ejabberd_http_ws -> websocket; ejabberd_http_ws -> websocket;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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