From ab8edc3d2ae42d253da9e461d4e25dbab93e6504 Mon Sep 17 00:00:00 2001 From: Leohearts Date: Mon, 1 May 2023 06:07:38 +0800 Subject: [PATCH] Add an option for query filter prefernce make prefer_ipv4 configurable --- luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua | 7 +++++++ luci-app-mosdns/root/etc/config/mosdns | 1 + luci-app-mosdns/root/etc/init.d/mosdns | 7 +++++++ luci-app-mosdns/root/usr/share/mosdns/default.yaml | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua index f3c0ac8f2..65d6def2e 100644 --- a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua +++ b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua @@ -123,6 +123,13 @@ o.rmempty = false o.default = false o:depends("configfile", "/etc/mosdns/config.yaml") +o = s:taboption("advanced", Value, "prefer_filter", translate("Query Filter Type"), translate("prefer v4: do not block domain AAAA if domain does not have an A record") .. '
' .. translate("prefer v6: do not block domain A if domain does not have an AAAA record") .. '
' .. translate("https://github.com/IrineSistiana/mosdns/blob/main/plugin/executable/dual_selector/dual_selector_test.go")) +o.default = "prefer_ipv4" +o:value("prefer_ipv4", "Prefer ipv4 (Default)") +o:value("prefer_ipv6", "Prefer ipv6") +o:value("disabled", "Disabled") +o:depends("configfile", "/etc/mosdns/config.yaml") + o = s:taboption("advanced", Value, "cache_size", translate("DNS Cache Size")) o.datatype = "and(uinteger,min(0))" o.default = "20000" diff --git a/luci-app-mosdns/root/etc/config/mosdns b/luci-app-mosdns/root/etc/config/mosdns index a7e31a7a1..0486add30 100644 --- a/luci-app-mosdns/root/etc/config/mosdns +++ b/luci-app-mosdns/root/etc/config/mosdns @@ -23,6 +23,7 @@ config mosdns 'config' option insecure_skip_verify '0' option enable_http3 '0' option listen_port_api '9091' + option prefer_filter 'prefer_ipv4' option bootstrap_dns '119.29.29.29' list remote_dns 'tls://8.8.8.8' list remote_dns 'tls://1.1.1.1' diff --git a/luci-app-mosdns/root/etc/init.d/mosdns b/luci-app-mosdns/root/etc/init.d/mosdns index 5025aa9c0..19498139a 100755 --- a/luci-app-mosdns/root/etc/init.d/mosdns +++ b/luci-app-mosdns/root/etc/init.d/mosdns @@ -59,6 +59,7 @@ get_config() { config_get idle_timeout $1 idle_timeout 30 config_get enable_http3 $1 enable_http3 0 config_get enable_ecs_remote $1 enable_ecs_remote 0 + config_get prefer_filter $1 prefer_filter 'prefer_ipv4' } init_yaml() { @@ -90,6 +91,12 @@ init_yaml() { else sed -i "/ecs_remote/d;" $CONF fi + + if [ "$prefer_filter" = 'disabled' ]; then + sed -i "/option_prefer_filter/d;" $CONF + else + sed -i "s,option_prefer_filter,$prefer_filter,g" $CONF + fi rm -rf $TMPDIR } diff --git a/luci-app-mosdns/root/usr/share/mosdns/default.yaml b/luci-app-mosdns/root/usr/share/mosdns/default.yaml index db2543afe..06d1713b7 100644 --- a/luci-app-mosdns/root/usr/share/mosdns/default.yaml +++ b/luci-app-mosdns/root/usr/share/mosdns/default.yaml @@ -112,7 +112,7 @@ plugins: - tag: remote_sequence type: sequence args: - - exec: prefer_ipv4 + - exec: option_prefer_filter - exec: ecs_remote - exec: $forward_remote