luci-app-mosdns: disable cache plugin when cache size is 0 #128

This commit is contained in:
sbwml 2023-09-20 19:05:25 +08:00
parent b8b7d64ba9
commit fe103aed81
3 changed files with 15 additions and 7 deletions

View File

@ -8,7 +8,7 @@ else
end end
m = Map("mosdns") m = Map("mosdns")
m.title = translate("MosDNS") .. " " .. mosdns_version m.title = translate("MosDNS") .. " " .. mosdns_version
m.description = translate("MosDNS is a 'programmable' DNS forwarder.") m.description = translate("MosDNS is a plugin-based DNS forwarder/traffic splitter.")
m:section(SimpleSection).template = "mosdns/mosdns_status" m:section(SimpleSection).template = "mosdns/mosdns_status"
@ -135,12 +135,12 @@ o.rmempty = false
o.default = false o.default = false
o:depends("configfile", "/etc/mosdns/config.yaml") o:depends("configfile", "/etc/mosdns/config.yaml")
o = s:taboption("advanced", Value, "cache_size", translate("DNS Cache Size")) 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.datatype = "and(uinteger,min(0))" o.datatype = "and(uinteger,min(0))"
o.default = "8000" o.default = "8000"
o:depends("configfile", "/etc/mosdns/config.yaml") o:depends("configfile", "/etc/mosdns/config.yaml")
o = s:taboption("advanced", Value, "cache_survival_time", translate("Cache Survival Time")) o = s:taboption("advanced", Value, "cache_survival_time", 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.datatype = "and(uinteger,min(0))"
o.default = "86400" o.default = "86400"
o:depends("configfile", "/etc/mosdns/config.yaml") o:depends("configfile", "/etc/mosdns/config.yaml")

View File

@ -13,7 +13,7 @@ msgstr "Cloudflare 选项"
msgid "API Options" msgid "API Options"
msgstr "API 选项" msgstr "API 选项"
msgid "MosDNS is a 'programmable' DNS forwarder." msgid "MosDNS is a plugin-based DNS forwarder/traffic splitter."
msgstr "MosDNS 是一个插件化的 DNS 转发/分流器。" msgstr "MosDNS 是一个插件化的 DNS 转发/分流器。"
msgid "RUNNING" msgid "RUNNING"
@ -230,10 +230,16 @@ msgid "Enable this option fallback policy forces forwarding to remote DNS"
msgstr "启用此选项 fallback 策略会强制转发到远程 DNS" msgstr "启用此选项 fallback 策略会强制转发到远程 DNS"
msgid "DNS Cache Size" msgid "DNS Cache Size"
msgstr "DNS 缓存大小(条)" msgstr "DNS 缓存大小"
msgid "Cache Survival Time" msgid "DNS cache size (in piece). To disable caching, please set to 0."
msgstr "缓存生存时间(秒)" msgstr "DNS 缓存大小(单位:条),要禁用缓存,请设置为 0"
msgid "Lazy Cache TTL"
msgstr "乐观缓存 TTL"
msgid "Lazy cache survival time (in second). To disable Lazy Cache, please set to 0."
msgstr "乐观缓存生存时间(单位:秒),要禁用乐观缓存,请设置为 0"
msgid "Cache Dump" msgid "Cache Dump"
msgstr "自动保存缓存" msgstr "自动保存缓存"

View File

@ -110,6 +110,8 @@ init_yaml() {
else else
sed -i '/\$cloudflare_cidr\|CLOUDFLARE_IP/d' $CONF sed -i '/\$cloudflare_cidr\|CLOUDFLARE_IP/d' $CONF
fi fi
# disable lazy_cache plugin when cache_size is 0
[ $cache_size -eq 0 ] && sed -i -E ':l;N;/exec: \$lazy_cache/s/(\n[^\n]*){6}$//;bl' $CONF
rm -rf $TMPDIR rm -rf $TMPDIR
} }