diff --git a/luasrc/model/cbi/mosdns/basic.lua b/luasrc/model/cbi/mosdns/basic.lua index 30ddbaf..716838b 100644 --- a/luasrc/model/cbi/mosdns/basic.lua +++ b/luasrc/model/cbi/mosdns/basic.lua @@ -38,6 +38,19 @@ dnsforward:value("208.67.222.222", "208.67.222.222 (Open DNS)") dnsforward:value("208.67.220.220", "208.67.220.220 (Open DNS)") dnsforward:depends( "configfile", "./def_config.yaml") +cache_size = s:option(Value, "cache_size", translate("DNS Cache Size")) +cache_size.datatype = "and(uinteger,min(0))" +cache_size.rmempty = false + +minimal_ttl = s:option(Value, "minimal_ttl", translate("Minimum TTL")) +minimal_ttl.datatype = "and(uinteger,min(1))" +minimal_ttl.datatype = "and(uinteger,max(3600))" +minimal_ttl.rmempty = false + +maximum_ttl = s:option(Value, "maximum_ttl", translate("Maximum TTL")) +maximum_ttl.datatype = "and(uinteger,min(1))" +maximum_ttl.rmempty = false + redirect = s:option(Flag, "redirect", translate("Enable DNS Redirect")) redirect:depends( "configfile", "./def_config.yaml") redirect.default = true diff --git a/po/zh-cn/mosdns.po b/po/zh-cn/mosdns.po index 6c0afd6..b3031a6 100644 --- a/po/zh-cn/mosdns.po +++ b/po/zh-cn/mosdns.po @@ -108,3 +108,12 @@ msgstr "MosDNS 日志文件" msgid "Remote DNS" msgstr "远程 DNS" + +msgid "DNS Cache Size" +msgstr "DNS 缓存大小" + +msgid "Minimum TTL" +msgstr "覆盖最小 TTL 值" + +msgid "Maximum TTL" +msgstr "覆盖最大 TTL 值" diff --git a/root/etc/config/mosdns b/root/etc/config/mosdns index f24ade5..141163e 100644 --- a/root/etc/config/mosdns +++ b/root/etc/config/mosdns @@ -11,5 +11,9 @@ config mosdns 'mosdns' option adblock '0' option configfile './def_config.yaml' option loglv 'error' - option logfile '/dev/null' - option dns_forward 'tls://8.8.4.4' \ No newline at end of file + option logfile '/tmp/mosdns.log' + option dns_forward 'tls://8.8.4.4' + option cache_size '1024' + option minimal_ttl '300' + option maximum_ttl '3600' + diff --git a/root/etc/mosdns/def_config.yaml b/root/etc/mosdns/def_config.yaml index 30b2b2d..66cf4bd 100644 --- a/root/etc/mosdns/def_config.yaml +++ b/root/etc/mosdns/def_config.yaml @@ -34,6 +34,9 @@ plugin: exec: - _block_with_nxdomain - _return + + - mem_cache + - if: - query_is_non_local_domain exec: @@ -50,6 +53,19 @@ plugin: fast_fallback: 150 always_standby: true + - modify_ttl + + - tag: 'mem_cache' + type: 'cache' + args: + size: ${{ uci -q get mosdns.mosdns.cache_size }} + + - tag: 'modify_ttl' + type: 'ttl' + args: + minimal_ttl: ${{ uci -q get mosdns.mosdns.minimal_ttl }} + maximum_ttl: ${{ uci -q get mosdns.mosdns.maximum_ttl }} + - tag: forward_local type: fast_forward args: