Skip to content

Commit ec1f66c

Browse files
Loïc Hoguinmergify-bot
authored andcommitted
Use the new function ranch_proxy_header:to_connection_info/1
(cherry picked from commit 0a2bde4)
1 parent 49b4717 commit ec1f66c

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

deps/rabbit_common/src/rabbit_net.erl

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,12 @@ ssl_info(_Sock) ->
100100
nossl.
101101

102102
proxy_ssl_info(Sock, {rabbit_proxy_socket, _, ProxyInfo}) ->
103-
case ProxyInfo of
104-
#{ssl := #{version := Version, cipher := Cipher}} ->
105-
Proto = case Version of
106-
<<"SSL3">> -> 'ssl3';
107-
<<"TLSv1">> -> 'tlsv1';
108-
<<"TLSv1.1">> -> 'tlsv1.1';
109-
<<"TLSv1.2">> -> 'tlsv1.2';
110-
<<"TLSv1.3">> -> 'tlsv1.3';
111-
_ -> nossl
112-
end,
113-
CipherSuite = case ssl:str_to_suite(binary_to_list(Cipher)) of
114-
#{} = CS -> CS;
115-
_ -> nossl
116-
end,
117-
case {Proto, CipherSuite} of
118-
{nossl, _} -> ssl_info(Sock);
119-
{_, nossl} -> ssl_info(Sock);
120-
_ -> {ok, [{protocol, Proto}, {selected_cipher_suite, CipherSuite}]}
121-
end;
122-
_ ->
103+
ConnInfo = ranch_proxy_header:to_connection_info(ProxyInfo),
104+
case lists:keymember(protocol, 1, ConnInfo) andalso
105+
lists:keymember(selected_cipher_suite, 1, ConnInfo) of
106+
true ->
107+
{ok, ConnInfo};
108+
false ->
123109
ssl_info(Sock)
124110
end;
125111
proxy_ssl_info(Sock, _) ->

0 commit comments

Comments
 (0)