fix: ip_port schema type crash
This commit is contained in:
parent
af7b7ebf7c
commit
45963b6a95
|
@ -1758,7 +1758,7 @@ base_listener(Bind) ->
|
|||
)},
|
||||
{"bind",
|
||||
sc(
|
||||
hoconsc:union([ip_port(), integer()]),
|
||||
ip_port(),
|
||||
#{
|
||||
default => Bind,
|
||||
required => true,
|
||||
|
@ -2525,9 +2525,9 @@ to_ip_port(Str) ->
|
|||
case split_ip_port(Str) of
|
||||
{"", Port} ->
|
||||
%% this is a local address
|
||||
{ok, list_to_integer(Port)};
|
||||
{ok, parse_port(Port)};
|
||||
{MaybeIp, Port} ->
|
||||
PortVal = list_to_integer(Port),
|
||||
PortVal = parse_port(Port),
|
||||
case inet:parse_address(MaybeIp) of
|
||||
{ok, IpTuple} ->
|
||||
{ok, {IpTuple, PortVal}};
|
||||
|
@ -2543,18 +2543,11 @@ split_ip_port(Str0) ->
|
|||
case lists:split(string:rchr(Str, $:), Str) of
|
||||
%% no colon
|
||||
{[], Str} ->
|
||||
try
|
||||
%% if it's just a port number, then return as-is
|
||||
_ = list_to_integer(Str),
|
||||
{"", Str}
|
||||
catch
|
||||
_:_ ->
|
||||
error
|
||||
end;
|
||||
{"", Str};
|
||||
{IpPlusColon, PortString} ->
|
||||
IpStr0 = lists:droplast(IpPlusColon),
|
||||
case IpStr0 of
|
||||
%% dropp head/tail brackets
|
||||
%% drop head/tail brackets
|
||||
[$[ | S] ->
|
||||
case lists:last(S) of
|
||||
$] -> {lists:droplast(S), PortString};
|
||||
|
|
|
@ -195,7 +195,7 @@ enable(Bool) ->
|
|||
bind(Port) ->
|
||||
{"bind",
|
||||
?HOCON(
|
||||
?UNION([non_neg_integer(), emqx_schema:ip_port()]),
|
||||
emqx_schema:ip_port(),
|
||||
#{
|
||||
default => 0,
|
||||
required => false,
|
||||
|
|
|
@ -261,7 +261,7 @@ common_listener_opts() ->
|
|||
)},
|
||||
{bind,
|
||||
sc(
|
||||
hoconsc:union([ip_port(), integer()]),
|
||||
ip_port(),
|
||||
#{desc => ?DESC(gateway_common_listener_bind)}
|
||||
)},
|
||||
{max_connections,
|
||||
|
|
|
@ -56,7 +56,7 @@ fields(exproto_grpc_server) ->
|
|||
[
|
||||
{bind,
|
||||
sc(
|
||||
hoconsc:union([ip_port(), integer()]),
|
||||
ip_port(),
|
||||
#{
|
||||
required => true,
|
||||
desc => ?DESC(exproto_grpc_server_bind)
|
||||
|
|
Loading…
Reference in New Issue