Add DNS Cache size and TTL value settings

This commit is contained in:
sbwml 2022-04-08 21:45:24 +08:00
parent a1c4763640
commit 5b434631f2
4 changed files with 44 additions and 2 deletions

View File

@ -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:value("208.67.220.220", "208.67.220.220 (Open DNS)")
dnsforward:depends( "configfile", "./def_config.yaml") 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 = s:option(Flag, "redirect", translate("Enable DNS Redirect"))
redirect:depends( "configfile", "./def_config.yaml") redirect:depends( "configfile", "./def_config.yaml")
redirect.default = true redirect.default = true

View File

@ -108,3 +108,12 @@ msgstr "MosDNS 日志文件"
msgid "Remote DNS" msgid "Remote DNS"
msgstr "远程 DNS" msgstr "远程 DNS"
msgid "DNS Cache Size"
msgstr "DNS 缓存大小"
msgid "Minimum TTL"
msgstr "覆盖最小 TTL 值"
msgid "Maximum TTL"
msgstr "覆盖最大 TTL 值"

View File

@ -11,5 +11,9 @@ config mosdns 'mosdns'
option adblock '0' option adblock '0'
option configfile './def_config.yaml' option configfile './def_config.yaml'
option loglv 'error' option loglv 'error'
option logfile '/dev/null' option logfile '/tmp/mosdns.log'
option dns_forward 'tls://8.8.4.4' option dns_forward 'tls://8.8.4.4'
option cache_size '1024'
option minimal_ttl '300'
option maximum_ttl '3600'

View File

@ -34,6 +34,9 @@ plugin:
exec: exec:
- _block_with_nxdomain - _block_with_nxdomain
- _return - _return
- mem_cache
- if: - if:
- query_is_non_local_domain - query_is_non_local_domain
exec: exec:
@ -50,6 +53,19 @@ plugin:
fast_fallback: 150 fast_fallback: 150
always_standby: true 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 - tag: forward_local
type: fast_forward type: fast_forward
args: args: