24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-02 21:17:12 +02:00

Add support for ciphers and protocol_options in ejabberd_http

This commit is contained in:
Alexey Shchepin 2015-03-24 18:13:55 +03:00
parent 8f46ca48c1
commit 736710cc9c

View File

@ -94,14 +94,24 @@ start_link(SockData, Opts) ->
init({SockMod, Socket}, Opts) -> init({SockMod, Socket}, Opts) ->
TLSEnabled = proplists:get_bool(tls, Opts), TLSEnabled = proplists:get_bool(tls, Opts),
TLSOpts1 = lists:filter(fun ({certfile, _}) -> true; TLSOpts1 = lists:filter(fun ({certfile, _}) -> true;
({ciphers, _}) -> true;
(_) -> false (_) -> false
end, end,
Opts), Opts),
TLSOpts2 = case proplists:get_bool(tls_compression, Opts) of TLSOpts2 = case lists:keysearch(protocol_options, 1, Opts) of
false -> [compression_none | TLSOpts1]; {value, {_, O}} ->
true -> TLSOpts1 [_|ProtocolOptions] = lists:foldl(
fun(X, Acc) -> X ++ Acc end, [],
[["|" | binary_to_list(Opt)] || Opt <- O, is_binary(Opt)]
),
[{protocol_options, iolist_to_binary(ProtocolOptions)} | TLSOpts1];
_ -> TLSOpts1
end, end,
TLSOpts = [verify_none | TLSOpts2], TLSOpts3 = case proplists:get_bool(tls_compression, Opts) of
false -> [compression_none | TLSOpts2];
true -> TLSOpts2
end,
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} = p1_tls:tcp_to_tls(Socket,