feat(dashboard): add listener enable/disable config toggle
This commit is contained in:
parent
2dded74584
commit
974380a3d4
|
@ -132,6 +132,16 @@ Note: `sample_interval` should be a divisor of 60."""
|
|||
zh: "HTTPS"
|
||||
}
|
||||
}
|
||||
listener_enable {
|
||||
desc {
|
||||
en: "Ignore or enable this listener"
|
||||
zh: "忽略或启用该监听器配置"
|
||||
}
|
||||
label {
|
||||
en: "Enable"
|
||||
zh: "启用"
|
||||
}
|
||||
}
|
||||
bind {
|
||||
desc {
|
||||
en: "Port without IP(18083) or port with specified IP(127.0.0.1:18083)."
|
||||
|
|
|
@ -153,10 +153,13 @@ apps() ->
|
|||
].
|
||||
|
||||
listeners(Listeners) ->
|
||||
lists:map(
|
||||
lists:filtermap(
|
||||
fun({Protocol, Conf}) ->
|
||||
maps:get(enable, Conf) andalso
|
||||
begin
|
||||
{Conf1, Bind} = ip_port(Conf),
|
||||
{listener_name(Protocol, Conf1), Protocol, Bind, ranch_opts(Conf1)}
|
||||
{true, {listener_name(Protocol, Conf1), Protocol, Bind, ranch_opts(Conf1)}}
|
||||
end
|
||||
end,
|
||||
maps:to_list(Listeners)
|
||||
).
|
||||
|
|
|
@ -76,6 +76,44 @@ fields("listeners") ->
|
|||
)}
|
||||
];
|
||||
fields("http") ->
|
||||
[
|
||||
{"enable",
|
||||
sc(
|
||||
boolean(),
|
||||
#{
|
||||
default => true,
|
||||
desc => ?DESC(listener_enable)
|
||||
}
|
||||
)}
|
||||
| common_listener_fields()
|
||||
];
|
||||
fields("https") ->
|
||||
[
|
||||
{"enable",
|
||||
sc(
|
||||
boolean(),
|
||||
#{
|
||||
default => false,
|
||||
desc => ?DESC(listener_enable)
|
||||
}
|
||||
)}
|
||||
| common_listener_fields() ++
|
||||
exclude_fields(
|
||||
["enable", "fail_if_no_peer_cert"],
|
||||
emqx_schema:server_ssl_opts_schema(#{}, true)
|
||||
)
|
||||
].
|
||||
|
||||
exclude_fields([], Fields) ->
|
||||
Fields;
|
||||
exclude_fields([FieldName | Rest], Fields) ->
|
||||
%% assert field exists
|
||||
case lists:keytake(FieldName, 1, Fields) of
|
||||
{value, _, New} -> exclude_fields(Rest, New);
|
||||
false -> error({FieldName, Fields})
|
||||
end.
|
||||
|
||||
common_listener_fields() ->
|
||||
[
|
||||
{"bind", fun bind/1},
|
||||
{"num_acceptors",
|
||||
|
@ -126,19 +164,18 @@ fields("http") ->
|
|||
desc => ?DESC(ipv6_v6only)
|
||||
}
|
||||
)}
|
||||
];
|
||||
fields("https") ->
|
||||
fields("http") ++
|
||||
proplists:delete(
|
||||
"fail_if_no_peer_cert",
|
||||
emqx_schema:server_ssl_opts_schema(#{}, true)
|
||||
).
|
||||
].
|
||||
|
||||
desc("dashboard") -> ?DESC(desc_dashboard);
|
||||
desc("listeners") -> ?DESC(desc_listeners);
|
||||
desc("http") -> ?DESC(desc_http);
|
||||
desc("https") -> ?DESC(desc_https);
|
||||
desc(_) -> undefined.
|
||||
desc("dashboard") ->
|
||||
?DESC(desc_dashboard);
|
||||
desc("listeners") ->
|
||||
?DESC(desc_listeners);
|
||||
desc("http") ->
|
||||
?DESC(desc_http);
|
||||
desc("https") ->
|
||||
?DESC(desc_https);
|
||||
desc(_) ->
|
||||
undefined.
|
||||
|
||||
bind(type) -> hoconsc:union([non_neg_integer(), emqx_schema:ip_port()]);
|
||||
bind(default) -> 18083;
|
||||
|
|
Loading…
Reference in New Issue