diff --git a/luci-app-mosdns/Makefile b/luci-app-mosdns/Makefile index bb832df..892e28b 100644 --- a/luci-app-mosdns/Makefile +++ b/luci-app-mosdns/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-mosdns -PKG_VERSION:=1.5.22 +PKG_VERSION:=1.5.23 PKG_RELEASE:=1 LUCI_TITLE:=LuCI Support for mosdns diff --git a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua index 5d6d76d..dcd8f48 100644 --- a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua +++ b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua @@ -150,20 +150,25 @@ o.rmempty = false o.default = false o:depends("configfile", "/var/etc/mosdns.json") -o = s:taboption("advanced", Value, "cache_size", translate("DNS Cache Size"), translate("DNS cache size (in piece). To disable caching, please set to 0.")) +o = s:taboption("advanced", Flag, "cache", translate("Enable DNS Cache")) +o.rmempty = false +o.default = false +o:depends("configfile", "/var/etc/mosdns.json") + +o = s:taboption("advanced", Value, "cache_size", translate("DNS Cache Size"), translate("DNS cache size (in piece).")) o.datatype = "and(uinteger,min(0))" o.default = "8000" -o:depends("configfile", "/var/etc/mosdns.json") +o:depends("cache", "1") o = s:taboption("advanced", Value, "lazy_cache_ttl", translate("Lazy Cache TTL"), translate("Lazy cache survival time (in second). To disable Lazy Cache, please set to 0.")) o.datatype = "and(uinteger,min(0))" o.default = "86400" -o:depends("configfile", "/var/etc/mosdns.json") +o:depends("cache", "1") o = s:taboption("advanced", Flag, "dump_file", translate("Cache Dump"), translate("Save the cache locally and reload the cache dump on the next startup")) o.rmempty = false o.default = false -o:depends("configfile", "/var/etc/mosdns.json") +o:depends("cache", "1") o = s:taboption("advanced", Value, "dump_interval", translate("Auto Save Cache Interval")) o.datatype = "and(uinteger,min(0))" diff --git a/luci-app-mosdns/po/zh-cn/mosdns.po b/luci-app-mosdns/po/zh-cn/mosdns.po index 15989d5..d604054 100644 --- a/luci-app-mosdns/po/zh-cn/mosdns.po +++ b/luci-app-mosdns/po/zh-cn/mosdns.po @@ -292,11 +292,14 @@ msgstr "防止 DNS 泄漏" msgid "Enable this option fallback policy forces forwarding to remote DNS" msgstr "启用此选项 fallback 策略会强制转发到远程 DNS" +msgid "Enable DNS Cache" +msgstr "启用 DNS 缓存" + msgid "DNS Cache Size" msgstr "DNS 缓存大小" -msgid "DNS cache size (in piece). To disable caching, please set to 0." -msgstr "DNS 缓存大小(单位:条),要禁用缓存,请设置为 0" +msgid "DNS cache size (in piece)." +msgstr "DNS 缓存大小(单位:条)" msgid "Lazy Cache TTL" msgstr "乐观缓存 TTL" diff --git a/luci-app-mosdns/root/etc/config/mosdns b/luci-app-mosdns/root/etc/config/mosdns index a15981f..11e2e84 100644 --- a/luci-app-mosdns/root/etc/config/mosdns +++ b/luci-app-mosdns/root/etc/config/mosdns @@ -11,9 +11,7 @@ config mosdns 'config' option configfile '/var/etc/mosdns.json' option log_level 'info' option log_file '/var/log/mosdns.log' - option cache_size '8000' - option lazy_cache_ttl '86400' - option dump_file '0' + option cache '0' option concurrent '1' option idle_timeout '30' option minimal_ttl '0' diff --git a/luci-app-mosdns/root/etc/init.d/mosdns b/luci-app-mosdns/root/etc/init.d/mosdns index aa16291..b4ddc15 100755 --- a/luci-app-mosdns/root/etc/init.d/mosdns +++ b/luci-app-mosdns/root/etc/init.d/mosdns @@ -33,6 +33,7 @@ get_config() { config_get enabled $1 enabled 0 config_get adblock $1 adblock 0 config_get ad_source $1 ad_source "" + config_get cache $1 cache 0 config_get cache_size $1 cache_size 8000 config_get lazy_cache_ttl $1 lazy_cache_ttl 86400 config_get dump_file $1 dump_file 0 @@ -231,18 +232,20 @@ generate_config() { json_close_object json_close_object # plugin: lazy_cache - json_add_object - json_add_string "tag" "lazy_cache" - json_add_string "type" "cache" - json_add_object "args" - json_add_int "size" "$cache_size" - json_add_int "lazy_cache_ttl" "$lazy_cache_ttl" - [ "$dump_file" -eq 1 ] && { - json_add_string "dump_file" "/etc/mosdns/cache.dump" - json_add_int "dump_interval" "$dump_interval" + [ "$cache" -eq 1 ] && { + json_add_object + json_add_string "tag" "lazy_cache" + json_add_string "type" "cache" + json_add_object "args" + json_add_int "size" "$cache_size" + json_add_int "lazy_cache_ttl" "$lazy_cache_ttl" + [ "$dump_file" -eq 1 ] && { + json_add_string "dump_file" "/etc/mosdns/cache.dump" + json_add_int "dump_interval" "$dump_interval" + } + json_close_object + json_close_object } - json_close_object - json_close_object # plugin: forward_xinfeng_udp json_add_object json_add_string "tag" "forward_xinfeng_udp" @@ -573,15 +576,17 @@ generate_config() { json_add_object json_add_string "exec" "jump has_resp_sequence" json_close_object - json_add_object - json_add_array "matches" - json_add_string "" "!qname \$ddnslist" - json_add_string "" "!qname \$blocklist" - json_add_string "" "!qname \$adlist" - json_add_string "" "!qname \$local_ptr" - json_close_array - json_add_string "exec" "\$lazy_cache" - json_close_object + [ "$cache" -eq 1 ] && { + json_add_object + json_add_array "matches" + json_add_string "" "!qname \$ddnslist" + json_add_string "" "!qname \$blocklist" + json_add_string "" "!qname \$adlist" + json_add_string "" "!qname \$local_ptr" + json_close_array + json_add_string "exec" "\$lazy_cache" + json_close_object + } json_add_object json_add_string "exec" "\$redirect" json_close_object