From 204f04be655c4589a2513600199a4fa0f25caf8d Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Wed, 27 Apr 2022 19:51:00 +0800 Subject: [PATCH] fix: handshake_timeout is ranch option not socket options --- apps/emqx_dashboard/src/emqx_dashboard.erl | 27 ++++++---------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/apps/emqx_dashboard/src/emqx_dashboard.erl b/apps/emqx_dashboard/src/emqx_dashboard.erl index af96bb15a..36daed7db 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard.erl @@ -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 =