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