fix: handshake_timeout is ranch option not socket options

This commit is contained in:
Zhongwen Deng 2022-04-27 19:51:00 +08:00
parent 974380a3d4
commit 204f04be65
1 changed files with 7 additions and 20 deletions

View File

@ -175,34 +175,21 @@ init_i18n() ->
Lang = emqx_conf:get([dashboard, i18n_lang], en),
init_i18n(File, Lang).
ranch_opts(RanchOptions) ->
ranch_opts(Options) ->
Keys = [
{ack_timeout, handshake_timeout},
handshake_timeout,
connection_type,
max_connections,
num_acceptors,
shutdown,
socket
],
{S, R} = lists:foldl(fun key_take/2, {RanchOptions, #{}}, Keys),
R#{socket_opts => maps:fold(fun key_only/3, [], S)}.
RanchOpts = maps:with(Keys, Options),
SocketOpts = maps:fold(fun filter_false/3, [], maps:without([enable | Keys], Options)),
RanchOpts#{socket_opts => SocketOpts}.
key_take(Key, {All, R}) ->
{K, KX} =
case Key of
{K1, K2} -> {K1, K2};
_ -> {Key, Key}
end,
case maps:get(K, All, undefined) of
undefined ->
{All, R};
V ->
{maps:remove(K, All), R#{KX => V}}
end.
key_only(K, true, S) -> [K | S];
key_only(_K, false, S) -> S;
key_only(K, V, S) -> [{K, V} | S].
filter_false(_K, false, S) -> S;
filter_false(K, V, S) -> [{K, V} | S].
listener_name(Protocol, #{port := Port, ip := IP}) ->
Name =