luci: support bind device option
This commit is contained in:
@@ -25,6 +25,12 @@ msgstr "自动设置Dnsmasq"
|
||||
msgid "Automatically set as upstream of dnsmasq when port changes."
|
||||
msgstr "自动设置为Dnsmasq的上游服务器"
|
||||
|
||||
msgid "Bind Device"
|
||||
msgstr "绑定到设备"
|
||||
|
||||
msgid "Bind Device Name"
|
||||
msgstr "绑定的设备名称"
|
||||
|
||||
msgid "Cache Size"
|
||||
msgstr "缓存大小"
|
||||
|
||||
@@ -227,6 +233,9 @@ msgstr "包含配置文件,路径为/etc/smartdns/conf.d,或自定义配置
|
||||
msgid "List of files to download."
|
||||
msgstr "下载的文件列表。"
|
||||
|
||||
msgid "Listen only on the specified interfaces."
|
||||
msgstr "监听在指定的设备上,避免非网络的DNS查询请求。"
|
||||
|
||||
msgid "Local Port"
|
||||
msgstr "本地端口"
|
||||
|
||||
@@ -242,6 +251,9 @@ msgstr "所有域名的最大 TTL 值。"
|
||||
msgid "Minimum TTL for all domain result."
|
||||
msgstr "所有域名的最小 TTL 值。"
|
||||
|
||||
msgid "Name of device name listen on."
|
||||
msgstr "绑定的设备名称。"
|
||||
|
||||
msgid "NFTset Name"
|
||||
msgstr "NFTSet名称"
|
||||
|
||||
|
||||
@@ -117,6 +117,20 @@ o.cfgvalue = function(...)
|
||||
return Flag.cfgvalue(...) or "1"
|
||||
end
|
||||
|
||||
---- bind to device;
|
||||
o = s:taboption("advanced", Flag, "bind_device", translate("Bind Device"), translate("Listen only on the specified interfaces."))
|
||||
o.rmempty = false
|
||||
o.default = o.enabled
|
||||
o.cfgvalue = function(...)
|
||||
return Flag.cfgvalue(...) or "1"
|
||||
end
|
||||
|
||||
---- bind device name;
|
||||
o = s:taboption("advanced", Value, "bind_device_name", translate("Bind Device Name"), translate("Name of device name listen on."))
|
||||
o.placeholder = "default"
|
||||
o.rempty = true
|
||||
o.datatype = "string"
|
||||
|
||||
---- Support DualStack ip selection
|
||||
o = s:taboption("advanced", Flag, "dualstack_ip_selection", translate("Dual-stack IP Selection"), translate("Enable IP selection between IPV4 and IPV6"))
|
||||
o.rmempty = false
|
||||
|
||||
@@ -25,6 +25,12 @@ msgstr "自动设置Dnsmasq"
|
||||
msgid "Automatically set as upstream of dnsmasq when port changes."
|
||||
msgstr "端口更改时自动设为 dnsmasq 的上游。"
|
||||
|
||||
msgid "Bind Device"
|
||||
msgstr "绑定到设备"
|
||||
|
||||
msgid "Bind Device Name"
|
||||
msgstr "绑定的设备名称"
|
||||
|
||||
msgid "Block domain"
|
||||
msgstr "屏蔽域名"
|
||||
|
||||
@@ -253,6 +259,9 @@ msgstr ""
|
||||
msgid "List of files to download."
|
||||
msgstr "下载文件列表"
|
||||
|
||||
msgid "Listen only on the specified interfaces."
|
||||
msgstr "监听在指定的设备上,避免非网络的DNS查询请求。"
|
||||
|
||||
msgid "Local Port"
|
||||
msgstr "本地端口"
|
||||
|
||||
@@ -268,6 +277,9 @@ msgstr "所有域名的最大 TTL 值。"
|
||||
msgid "Minimum TTL for all domain result."
|
||||
msgstr "所有域名的最小 TTL 值。"
|
||||
|
||||
msgid "Name of device name listen on."
|
||||
msgstr "绑定的设备名称。"
|
||||
|
||||
msgid "NFTset Name"
|
||||
msgstr "NFTSet名称"
|
||||
|
||||
|
||||
@@ -208,6 +208,17 @@ return view.extend({
|
||||
o.rmempty = false;
|
||||
o.default = o.enabled;
|
||||
|
||||
// bind to device;
|
||||
o = s.taboption("advanced", form.Flag, "bind_device", _("Bind Device"), _("Listen only on the specified interfaces."));
|
||||
o.rmempty = false;
|
||||
o.default = o.enabled;
|
||||
|
||||
// bind device name;
|
||||
o = s.taboption("advanced", form.Value, "bind_device_name", _("Bind Device Name"), _("Name of device name listen on."));
|
||||
o.placeholder = "default";
|
||||
o.rempty = true;
|
||||
o.datatype = "string";
|
||||
|
||||
// Support DualStack ip selection;
|
||||
o = s.taboption("advanced", form.Flag, "dualstack_ip_selection", _("Dual-stack IP Selection"),
|
||||
_("Enable IP selection between IPV4 and IPV6"));
|
||||
|
||||
@@ -353,6 +353,7 @@ load_second_server()
|
||||
local section="$1"
|
||||
local ARGS=""
|
||||
local ADDR=""
|
||||
local device=""
|
||||
|
||||
config_get_bool seconddns_enabled "$section" "seconddns_enabled" "0"
|
||||
[ "$seconddns_enabled" = "0" ] && return
|
||||
@@ -386,6 +387,10 @@ load_second_server()
|
||||
config_get_bool seconddns_force_aaaa_soa "$section" "seconddns_force_aaaa_soa" "0"
|
||||
[ "$seconddns_force_aaaa_soa" = "1" ] && ARGS="$ARGS -force-aaaa-soa"
|
||||
|
||||
config_get_bool bind_device "$section" "bind_device" "0"
|
||||
config_get bind_device_name "$section" "bind_device_name" "${lan_device}"
|
||||
[ ! -z "$bind_device_name" ] && [ "$bind_device" = "1" ] && device="@${bind_device_name}"
|
||||
|
||||
config_get ipv6_server "$section" "ipv6_server" "1"
|
||||
if [ "$ipv6_server" = "1" ]; then
|
||||
ADDR="[::]"
|
||||
@@ -393,9 +398,11 @@ load_second_server()
|
||||
ADDR=""
|
||||
fi
|
||||
|
||||
conf_append "bind" "$ADDR:$seconddns_port $ARGS"
|
||||
conf_append "bind" "$ADDR:$seconddns_port$device $ARGS"
|
||||
[ ! -z "$device" ] && conf_append "bind" "$ADDR:$seconddns_port@lo $ARGS"
|
||||
config_get_bool "seconddns_tcp_server" "$section" "seconddns_tcp_server" "1"
|
||||
[ "$seconddns_tcp_server" = "1" ] && conf_append "bind-tcp" "$ADDR:$seconddns_port $ARGS"
|
||||
[ "$seconddns_tcp_server" = "1" ] && conf_append "bind-tcp" "$ADDR:$seconddns_port$device $ARGS"
|
||||
[ "$seconddns_tcp_server" = "1" ] && [ ! -z "$device" ] && conf_append "bind-tcp" "$ADDR:$seconddns_port@lo $ARGS"
|
||||
}
|
||||
|
||||
conf_append_conf_files()
|
||||
@@ -417,9 +424,12 @@ load_service()
|
||||
{
|
||||
local section="$1"
|
||||
args=""
|
||||
local device=""
|
||||
dnsmasq_lease_file="$(uci -q get dhcp.@dnsmasq[0].leasefile)"
|
||||
dnsmasq_port="$(uci -q get dhcp.@dnsmasq[0].port)"
|
||||
resolve_file="$(uci -q get dhcp.@dnsmasq[0].resolvfile)"
|
||||
lan_device="$(uci -q get network.lan.device)"
|
||||
|
||||
[ -z "$dnsmasq_lease_file" ] && dnsmasq_lease_file="/tmp/dhcp.leases"
|
||||
[ -z "$dnsmasq_port" ] && dnsmasq_port="53"
|
||||
[ -z "$resolve_file" ] && resolve_file="/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
@@ -493,6 +503,10 @@ load_service()
|
||||
|
||||
config_get_bool enable_auto_update "$section" "enable_auto_update" "0"
|
||||
[ "$enable_auto_update" = "1" ] && enable_auto_update || disable_auto_update
|
||||
|
||||
config_get_bool bind_device "$section" "bind_device" "0"
|
||||
config_get bind_device_name "$section" "bind_device_name" "${lan_device}"
|
||||
[ ! -z "$bind_device_name" ] && [ "$bind_device" = "1" ] && device="@${bind_device_name}"
|
||||
|
||||
config_get redirect "$section" "redirect" ""
|
||||
config_get old_port "$section" "old_port" "0"
|
||||
@@ -561,16 +575,20 @@ load_service()
|
||||
}
|
||||
|
||||
if [ "$ipv6_server" = "1" ]; then
|
||||
conf_append "bind" "[::]:$port"
|
||||
conf_append "bind" "[::]:$port$device"
|
||||
[ ! -z "$device" ] && conf_append "bind" "[::]:$port@lo"
|
||||
else
|
||||
conf_append "bind" ":$port"
|
||||
conf_append "bind" ":$port$device"
|
||||
[ ! -z "$device" ] && conf_append "bind" ":$port@lo"
|
||||
fi
|
||||
|
||||
[ "$tcp_server" = "1" ] && {
|
||||
if [ "$ipv6_server" = "1" ]; then
|
||||
conf_append "bind-tcp" "[::]:$port"
|
||||
conf_append "bind-tcp" "[::]:$port$device"
|
||||
[ ! -z "$device" ] && conf_append "bind-tcp" "[::]:$port@lo"
|
||||
else
|
||||
conf_append "bind-tcp" ":$port"
|
||||
conf_append "bind-tcp" ":$port$device"
|
||||
[ ! -z "$device" ] && conf_append "bind-tcp" ":$port@lo"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user