chore: more detailed about dashboard inet6 option

This commit is contained in:
Zhongwen Deng 2022-04-27 22:24:32 +08:00
parent b06747d961
commit 5c08c4ff4e
2 changed files with 18 additions and 5 deletions

View File

@ -74,8 +74,8 @@ Note: `sample_interval` should be a divisor of 60."""
} }
inet6 { inet6 {
desc { desc {
en: "Enable IPv6 support." en: "Enable IPv6 support, default is false, which means IPv4 only."
zh: "启用IPv6" zh: "启用IPv6 如果机器不支持IPv6请关闭此选项否则会导致仪表盘无法使用。"
} }
label { label {
en: "IPv6" en: "IPv6"
@ -85,7 +85,7 @@ Note: `sample_interval` should be a divisor of 60."""
ipv6_v6only { ipv6_v6only {
desc { desc {
en: "Disable IPv4-to-IPv6 mapping for the listener." en: "Disable IPv4-to-IPv6 mapping for the listener."
zh: "禁用IPv4-to-IPv6映射" zh: "当开启 inet6 功能的同时禁用 IPv4-to-IPv6 映射。该配置仅在 inet6 功能开启时有效。"
} }
label { label {
en: "IPv6 only" en: "IPv6 only"

View File

@ -185,8 +185,21 @@ ranch_opts(Options) ->
socket socket
], ],
RanchOpts = maps:with(Keys, Options), RanchOpts = maps:with(Keys, Options),
SocketOpts = maps:fold(fun filter_false/3, [], maps:without([enable | Keys], Options)), SocketOpts = maps:fold(
RanchOpts#{socket_opts => SocketOpts}. fun filter_false/3,
[],
maps:without([enable, inet6, ipv6_v6only | Keys], Options)
),
InetOpts =
case Options of
#{inet6 := true, ipv6_v6only := true} ->
[inet6, {ipv6_v6only, true}];
#{inet6 := true, ipv6_v6only := false} ->
[inet6];
_ ->
[inet]
end,
RanchOpts#{socket_opts => InetOpts ++ SocketOpts}.
filter_false(_K, false, S) -> S; filter_false(_K, false, S) -> S;
filter_false(K, V, S) -> [{K, V} | S]. filter_false(K, V, S) -> [{K, V} | S].