From 8f6f6497031ac1fb79f97324abed360a95319a15 Mon Sep 17 00:00:00 2001 From: William Yang Date: Wed, 24 Mar 2021 16:09:07 +0100 Subject: [PATCH] fix(cuttlefish-schema): parse IP addr for SSL listeners. Convert IP addr str to tuple to please ranch. Other types of listeners seem me to be happy with the tuple format as well. Closes: #4426 --- priv/emqx.schema | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/priv/emqx.schema b/priv/emqx.schema index 2e1248c50..28ee95782 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -2006,19 +2006,18 @@ end}. {honor_cipher_order, cuttlefish:conf_get(Prefix ++ ".honor_cipher_order", Conf, undefined)}]) end, + Listen_fix = fun({Ip, Port}) -> case inet:parse_address(Ip) of + {ok, R} -> {R, Port}; + _ -> {Ip, Port} + end; + (Other) -> Other + end, + TcpListeners = fun(Type, Name) -> Prefix = string:join(["listener", Type, Name], "."), ListenOnN = case cuttlefish:conf_get(Prefix, Conf, undefined) of undefined -> []; - ListenOn -> - case ListenOn of - {Ip, Port} -> - case inet:parse_address(Ip) of - {ok ,R} -> {R, Port}; - _ -> {Ip, Port} - end; - Other -> Other - end + ListenOn -> Listen_fix(ListenOn) end, [#{ proto => Atom(Type) , name => Name @@ -2038,7 +2037,7 @@ end}. ListenOn -> [#{ proto => Atom(Type) , name => Name - , listen_on => ListenOn + , listen_on => Listen_fix(ListenOn) , opts => [ {deflate_options, DeflateOpts(Prefix)} , {tcp_options, TcpOpts(Prefix)} , {ssl_options, SslOpts(Prefix)}