luci-app-mosdns: update mosdns v4.x support
This commit is contained in:
parent
4ec1be84de
commit
6ebb46c873
@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-mosdns
|
PKG_NAME:=luci-app-mosdns
|
||||||
PKG_VERSION:=1.3
|
PKG_VERSION:=1.4
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI Support for mosdns
|
LUCI_TITLE:=LuCI Support for mosdns
|
||||||
|
@ -60,15 +60,20 @@ cache_size.datatype = "and(uinteger,min(0))"
|
|||||||
cache_size.default = "200000"
|
cache_size.default = "200000"
|
||||||
cache_size:depends( "configfile", "/etc/mosdns/config.yaml")
|
cache_size:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
|
cache_size = s:option(Value, "cache_survival_time", translate("Cache Survival Time"))
|
||||||
|
cache_size.datatype = "and(uinteger,min(0))"
|
||||||
|
cache_size.default = "259200"
|
||||||
|
cache_size:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
minimal_ttl = s:option(Value, "minimal_ttl", translate("Minimum TTL"))
|
minimal_ttl = s:option(Value, "minimal_ttl", translate("Minimum TTL"))
|
||||||
minimal_ttl.datatype = "and(uinteger,min(1))"
|
minimal_ttl.datatype = "and(uinteger,min(0))"
|
||||||
minimal_ttl.datatype = "and(uinteger,max(3600))"
|
minimal_ttl.datatype = "and(uinteger,max(3600))"
|
||||||
minimal_ttl.default = "300"
|
minimal_ttl.default = "0"
|
||||||
minimal_ttl:depends( "configfile", "/etc/mosdns/config.yaml")
|
minimal_ttl:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
maximum_ttl = s:option(Value, "maximum_ttl", translate("Maximum TTL"))
|
maximum_ttl = s:option(Value, "maximum_ttl", translate("Maximum TTL"))
|
||||||
maximum_ttl.datatype = "and(uinteger,min(1))"
|
maximum_ttl.datatype = "and(uinteger,min(0))"
|
||||||
maximum_ttl.default = "3600"
|
maximum_ttl.default = "0"
|
||||||
maximum_ttl:depends( "configfile", "/etc/mosdns/config.yaml")
|
maximum_ttl:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
redirect = s:option(Flag, "redirect", translate("Enable DNS Forward"), translate("Forward Dnsmasq Domain Name resolution requests to MosDNS"))
|
redirect = s:option(Flag, "redirect", translate("Enable DNS Forward"), translate("Forward Dnsmasq Domain Name resolution requests to MosDNS"))
|
||||||
@ -77,7 +82,7 @@ redirect.default = true
|
|||||||
|
|
||||||
adblock = s:option(Flag, "adblock", translate("Enable DNS ADblock"))
|
adblock = s:option(Flag, "adblock", translate("Enable DNS ADblock"))
|
||||||
adblock:depends( "configfile", "/etc/mosdns/config.yaml")
|
adblock:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
adblock.default = true
|
adblock.default = false
|
||||||
|
|
||||||
config = s:option(TextValue, "manual-config")
|
config = s:option(TextValue, "manual-config")
|
||||||
config.description = translate("<font color=\"ff0000\"><strong>View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need.</strong></font>")
|
config.description = translate("<font color=\"ff0000\"><strong>View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need.</strong></font>")
|
||||||
|
@ -92,13 +92,16 @@ msgid "Remote DNS"
|
|||||||
msgstr "远程 DNS"
|
msgstr "远程 DNS"
|
||||||
|
|
||||||
msgid "DNS Cache Size"
|
msgid "DNS Cache Size"
|
||||||
msgstr "DNS 缓存大小"
|
msgstr "DNS 缓存大小(条)"
|
||||||
|
|
||||||
|
msgid "Cache Survival Time"
|
||||||
|
msgstr "缓存生存时间(秒)"
|
||||||
|
|
||||||
msgid "Minimum TTL"
|
msgid "Minimum TTL"
|
||||||
msgstr "覆盖最小 TTL 值"
|
msgstr "覆盖最小 TTL 值(禁用:0)"
|
||||||
|
|
||||||
msgid "Maximum TTL"
|
msgid "Maximum TTL"
|
||||||
msgstr "覆盖最大 TTL 值"
|
msgstr "覆盖最大 TTL 值(禁用:0)"
|
||||||
|
|
||||||
msgid "Logs"
|
msgid "Logs"
|
||||||
msgstr "日志"
|
msgstr "日志"
|
||||||
|
@ -8,11 +8,12 @@ config mosdns 'mosdns'
|
|||||||
option redirect '1'
|
option redirect '1'
|
||||||
option adblock '0'
|
option adblock '0'
|
||||||
option configfile '/etc/mosdns/config.yaml'
|
option configfile '/etc/mosdns/config.yaml'
|
||||||
option log_level 'error'
|
option log_level 'info'
|
||||||
option logfile '/tmp/mosdns.log'
|
option logfile '/tmp/mosdns.log'
|
||||||
option remote_dns1 'tls://8.8.8.8'
|
option remote_dns1 'tls://8.8.8.8'
|
||||||
option remote_dns2 'tls://1.1.1.1'
|
option remote_dns2 'tls://1.1.1.1'
|
||||||
option cache_size '200000'
|
option cache_size '200000'
|
||||||
option minimal_ttl '300'
|
option cache_survival_time '259200'
|
||||||
option maximum_ttl '3600'
|
option minimal_ttl '0'
|
||||||
|
option maximum_ttl '0'
|
||||||
|
|
||||||
|
@ -14,6 +14,22 @@ inital_conf() {
|
|||||||
config_get "enabled" "mosdns" "enabled" "0"
|
config_get "enabled" "mosdns" "enabled" "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_yaml() {
|
||||||
|
log_level=$(uci -q get mosdns.mosdns.log_level)
|
||||||
|
log_file=$(uci -q get mosdns.mosdns.logfile)
|
||||||
|
listen_port=$(uci -q get mosdns.mosdns.listen_port)
|
||||||
|
cache_size=$(uci -q get mosdns.mosdns.cache_size)
|
||||||
|
cache_survival_time=$(uci -q get mosdns.mosdns.cache_survival_time)
|
||||||
|
minimal_ttl_custom=$(uci -q get mosdns.mosdns.minimal_ttl)
|
||||||
|
maximum_ttl_custom=$(uci -q get mosdns.mosdns.maximum_ttl)
|
||||||
|
local_dns1=$(/usr/share/mosdns/dns.sh 0)
|
||||||
|
local_dns2=$(/usr/share/mosdns/dns.sh 1)
|
||||||
|
remote_dns1=$(uci -q get mosdns.mosdns.remote_dns1)
|
||||||
|
remote_dns2=$(uci -q get mosdns.mosdns.remote_dns2)
|
||||||
|
adblock=$(/usr/share/mosdns/ad_domain.sh)
|
||||||
|
sed "s,log_level,$log_level,g;s,log_file,$log_file,g;s,listen_port,$listen_port,g;s,cache_size,$cache_size,g;s,cache_survival_time,$cache_survival_time,g;s,minimal_ttl_custom,$minimal_ttl_custom,g;s,maximum_ttl_custom,$maximum_ttl_custom,g;s,local_dns1,$local_dns1,g;s,local_dns2,$local_dns2,g;s,remote_dns1,$remote_dns1,g;s,remote_dns2,$remote_dns2,g;s,adblock,$adblock,g" /usr/share/mosdns/default.yaml > /etc/mosdns/config.yaml
|
||||||
|
}
|
||||||
|
|
||||||
service_triggers() {
|
service_triggers() {
|
||||||
procd_add_reload_trigger "mosdns"
|
procd_add_reload_trigger "mosdns"
|
||||||
}
|
}
|
||||||
@ -64,9 +80,10 @@ start_service() {
|
|||||||
[ $enabled != 1 ] && return 1
|
[ $enabled != 1 ] && return 1
|
||||||
delcron
|
delcron
|
||||||
setcron
|
setcron
|
||||||
|
init_yaml
|
||||||
cat /dev/null > $(uci -q get mosdns.mosdns.logfile)
|
cat /dev/null > $(uci -q get mosdns.mosdns.logfile)
|
||||||
procd_open_instance mosdns
|
procd_open_instance mosdns
|
||||||
procd_set_param command $PROG -c "$CONF"
|
procd_set_param command $PROG start -c "$CONF"
|
||||||
procd_set_param user root
|
procd_set_param user root
|
||||||
procd_set_param stdout 1
|
procd_set_param stdout 1
|
||||||
procd_set_param stderr 1
|
procd_set_param stderr 1
|
||||||
|
@ -1,136 +0,0 @@
|
|||||||
log:
|
|
||||||
level: ${{ uci -q get mosdns.mosdns.log_level }}
|
|
||||||
file: ${{ uci -q get mosdns.mosdns.logfile }}
|
|
||||||
|
|
||||||
plugin:
|
|
||||||
- tag: main_server
|
|
||||||
type: server
|
|
||||||
args:
|
|
||||||
entry:
|
|
||||||
- _single_flight
|
|
||||||
- main_sequence
|
|
||||||
server:
|
|
||||||
- protocol: udp
|
|
||||||
addr: ":${{ uci -q get mosdns.mosdns.listen_port }}"
|
|
||||||
- protocol: tcp
|
|
||||||
addr: ":${{ uci -q get mosdns.mosdns.listen_port }}"
|
|
||||||
|
|
||||||
- tag: main_sequence
|
|
||||||
type: sequence
|
|
||||||
args:
|
|
||||||
exec:
|
|
||||||
- query_is_hosts_domain
|
|
||||||
- query_is_redirect_domain
|
|
||||||
- if:
|
|
||||||
- query_is_whitelist_domain
|
|
||||||
exec:
|
|
||||||
- forward_local
|
|
||||||
- _return
|
|
||||||
- if:
|
|
||||||
- query_is_blocklist_domain
|
|
||||||
- query_is_ad_domain
|
|
||||||
exec:
|
|
||||||
- _block_with_nxdomain
|
|
||||||
- _return
|
|
||||||
|
|
||||||
- mem_cache
|
|
||||||
|
|
||||||
- if:
|
|
||||||
- query_is_local_domain
|
|
||||||
- "!_query_is_common"
|
|
||||||
exec:
|
|
||||||
- forward_local
|
|
||||||
- _return
|
|
||||||
- if:
|
|
||||||
- query_is_non_local_domain
|
|
||||||
exec:
|
|
||||||
- _prefer_ipv4
|
|
||||||
- forward_remote
|
|
||||||
- _return
|
|
||||||
- primary:
|
|
||||||
- forward_local
|
|
||||||
- if:
|
|
||||||
- "!response_has_local_ip"
|
|
||||||
exec:
|
|
||||||
- _drop_response
|
|
||||||
secondary:
|
|
||||||
- _prefer_ipv4
|
|
||||||
- forward_remote
|
|
||||||
fast_fallback: 200
|
|
||||||
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:
|
|
||||||
upstream:
|
|
||||||
- addr: ${{ /usr/share/mosdns/dns.sh 0 }}
|
|
||||||
- addr: ${{ /usr/share/mosdns/dns.sh 1 }}
|
|
||||||
|
|
||||||
- tag: forward_remote
|
|
||||||
type: fast_forward
|
|
||||||
args:
|
|
||||||
upstream:
|
|
||||||
- addr: ${{ uci -q get mosdns.mosdns.remote_dns1 }}
|
|
||||||
- addr: ${{ uci -q get mosdns.mosdns.remote_dns2 }}
|
|
||||||
|
|
||||||
- tag: query_is_whitelist_domain
|
|
||||||
type: query_matcher
|
|
||||||
args:
|
|
||||||
domain:
|
|
||||||
- "ext:/etc/mosdns/rule/whitelist.txt"
|
|
||||||
|
|
||||||
- tag: query_is_blocklist_domain
|
|
||||||
type: query_matcher
|
|
||||||
args:
|
|
||||||
domain:
|
|
||||||
- "ext:/etc/mosdns/rule/blocklist.txt"
|
|
||||||
|
|
||||||
- tag: query_is_hosts_domain
|
|
||||||
type: hosts
|
|
||||||
args:
|
|
||||||
hosts:
|
|
||||||
- "ext:/etc/mosdns/rule/hosts.txt"
|
|
||||||
|
|
||||||
- tag: query_is_redirect_domain
|
|
||||||
type: redirect
|
|
||||||
args:
|
|
||||||
rule:
|
|
||||||
- "ext:/etc/mosdns/rule/redirect.txt"
|
|
||||||
|
|
||||||
- tag: query_is_local_domain
|
|
||||||
type: query_matcher
|
|
||||||
args:
|
|
||||||
domain:
|
|
||||||
- "ext:/usr/share/v2ray/geosite.dat:cn"
|
|
||||||
- "ext:/usr/share/v2ray/geosite.dat:apple-cn"
|
|
||||||
|
|
||||||
- tag: query_is_non_local_domain
|
|
||||||
type: query_matcher
|
|
||||||
args:
|
|
||||||
domain:
|
|
||||||
- "ext:/usr/share/v2ray/geosite.dat:geolocation-!cn"
|
|
||||||
|
|
||||||
- tag: response_has_local_ip
|
|
||||||
type: response_matcher
|
|
||||||
args:
|
|
||||||
ip:
|
|
||||||
- "ext:/usr/share/v2ray/geoip.dat:cn"
|
|
||||||
|
|
||||||
- tag: query_is_ad_domain
|
|
||||||
type: query_matcher
|
|
||||||
args:
|
|
||||||
domain:
|
|
||||||
- ${{ /usr/share/mosdns/ad_domain.sh }}
|
|
@ -1,96 +1,156 @@
|
|||||||
log:
|
log:
|
||||||
level: error
|
level: info
|
||||||
file: ""
|
file: "/tmp/mosdns.log"
|
||||||
|
|
||||||
plugin:
|
include: []
|
||||||
- tag: main_server
|
|
||||||
type: server
|
|
||||||
args:
|
|
||||||
entry:
|
|
||||||
- _no_ecs
|
|
||||||
- lazy_cache
|
|
||||||
- _prefer_ipv4
|
|
||||||
- _single_flight
|
|
||||||
- main_sequence
|
|
||||||
server:
|
|
||||||
- protocol: udp
|
|
||||||
addr: "127.0.0.1:5335"
|
|
||||||
- protocol: tcp
|
|
||||||
addr: "127.0.0.1:5335"
|
|
||||||
|
|
||||||
- tag: main_sequence
|
data_providers:
|
||||||
type: sequence
|
- tag: geoip
|
||||||
args:
|
file: "/usr/share/v2ray/geoip.dat"
|
||||||
exec:
|
auto_reload: true
|
||||||
- if:
|
|
||||||
- query_is_ad_domain
|
|
||||||
exec:
|
|
||||||
- _block_with_nxdomain
|
|
||||||
- _return
|
|
||||||
- if:
|
|
||||||
- query_is_local_domain
|
|
||||||
- "!_query_is_common"
|
|
||||||
exec:
|
|
||||||
- forward_local
|
|
||||||
- _return
|
|
||||||
- if:
|
|
||||||
- query_is_non_local_domain
|
|
||||||
exec:
|
|
||||||
- forward_remote
|
|
||||||
- _return
|
|
||||||
- primary:
|
|
||||||
- forward_local
|
|
||||||
- if:
|
|
||||||
- "!response_has_local_ip"
|
|
||||||
exec:
|
|
||||||
- _drop_response
|
|
||||||
secondary:
|
|
||||||
- forward_remote
|
|
||||||
fast_fallback: 150
|
|
||||||
always_standby: true
|
|
||||||
|
|
||||||
- tag: forward_local
|
- tag: geosite
|
||||||
type: fast_forward
|
file: "/usr/share/v2ray/geosite.dat"
|
||||||
args:
|
auto_reload: true
|
||||||
upstream:
|
|
||||||
- addr: ${{ /usr/share/mosdns/dns.sh 0 }}
|
|
||||||
- addr: ${{ /usr/share/mosdns/dns.sh 1 }}
|
|
||||||
|
|
||||||
- tag: forward_remote
|
- tag: whitelist
|
||||||
type: fast_forward
|
file: "/etc/mosdns/rule/whitelist.txt"
|
||||||
args:
|
auto_reload: true
|
||||||
upstream:
|
|
||||||
- addr: "tls://8.8.4.4"
|
|
||||||
idle_timeout: 10
|
|
||||||
- addr: "tls://9.9.9.9"
|
|
||||||
idle_timeout: 10
|
|
||||||
|
|
||||||
|
- tag: blocklist
|
||||||
|
file: "/etc/mosdns/rule/blocklist.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: hosts
|
||||||
|
file: "/etc/mosdns/rule/hosts.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: redirect
|
||||||
|
file: "/etc/mosdns/rule/redirect.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
plugins:
|
||||||
- tag: lazy_cache
|
- tag: lazy_cache
|
||||||
type: cache
|
type: cache
|
||||||
args:
|
args:
|
||||||
size: 512000
|
size: 200000
|
||||||
lazy_cache_ttl: 259200
|
lazy_cache_ttl: 259200
|
||||||
|
|
||||||
|
- tag: modify_ttl
|
||||||
|
type: ttl
|
||||||
|
args:
|
||||||
|
minimal_ttl: 0
|
||||||
|
maximum_ttl: 0
|
||||||
|
|
||||||
|
- tag: "forward_local"
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: 119.29.29.29
|
||||||
|
- addr: 114.114.114.114
|
||||||
|
|
||||||
|
- tag: "forward_remote"
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: tls://8.8.8.8
|
||||||
|
- addr: tls://1.1.1.1
|
||||||
|
|
||||||
|
- tag: query_is_whitelist_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "provider:whitelist"
|
||||||
|
|
||||||
|
- tag: query_is_blocklist_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "provider:blocklist"
|
||||||
|
|
||||||
|
- tag: query_is_hosts_domain
|
||||||
|
type: hosts
|
||||||
|
args:
|
||||||
|
hosts:
|
||||||
|
- "provider:hosts"
|
||||||
|
|
||||||
|
- tag: query_is_redirect_domain
|
||||||
|
type: redirect
|
||||||
|
args:
|
||||||
|
rule:
|
||||||
|
- "provider:redirect"
|
||||||
|
|
||||||
- tag: query_is_local_domain
|
- tag: query_is_local_domain
|
||||||
type: query_matcher
|
type: query_matcher
|
||||||
args:
|
args:
|
||||||
domain:
|
domain:
|
||||||
- "ext:/usr/share/v2ray/geosite.dat:cn"
|
- "provider:geosite:cn"
|
||||||
|
|
||||||
- tag: query_is_non_local_domain
|
- tag: query_is_non_local_domain
|
||||||
type: query_matcher
|
type: query_matcher
|
||||||
args:
|
args:
|
||||||
domain:
|
domain:
|
||||||
- "ext:/usr/share/v2ray/geosite.dat:geolocation-!cn"
|
- "provider:geosite:geolocation-!cn"
|
||||||
|
|
||||||
- tag: response_has_local_ip
|
- tag: response_has_local_ip
|
||||||
type: response_matcher
|
type: response_matcher
|
||||||
args:
|
args:
|
||||||
ip:
|
ip:
|
||||||
- "ext:/usr/share/v2ray/geoip.dat:cn"
|
- "provider:geoip:cn"
|
||||||
|
|
||||||
- tag: query_is_ad_domain
|
- tag: query_is_ad_domain
|
||||||
type: query_matcher
|
type: query_matcher
|
||||||
args:
|
args:
|
||||||
domain:
|
domain:
|
||||||
- "ext:/usr/share/v2ray/geosite.dat:category-ads-all"
|
- "provider:geosite:category-ads-all"
|
||||||
|
|
||||||
|
- tag: "main_sequence"
|
||||||
|
type: "sequence"
|
||||||
|
args:
|
||||||
|
exec:
|
||||||
|
- query_is_hosts_domain
|
||||||
|
- query_is_redirect_domain
|
||||||
|
|
||||||
|
- if: query_is_whitelist_domain
|
||||||
|
exec:
|
||||||
|
- forward_local
|
||||||
|
- modify_ttl
|
||||||
|
- _return
|
||||||
|
|
||||||
|
- if: "query_is_blocklist_domain || query_is_ad_domain"
|
||||||
|
exec:
|
||||||
|
- _new_nxdomain_response
|
||||||
|
- _return
|
||||||
|
|
||||||
|
- lazy_cache
|
||||||
|
|
||||||
|
- if: query_is_local_domain
|
||||||
|
exec:
|
||||||
|
- forward_local
|
||||||
|
- modify_ttl
|
||||||
|
- _return
|
||||||
|
|
||||||
|
- if: query_is_non_local_domain
|
||||||
|
exec:
|
||||||
|
- _prefer_ipv4
|
||||||
|
- forward_remote
|
||||||
|
- modify_ttl
|
||||||
|
- _return
|
||||||
|
- primary:
|
||||||
|
- forward_local
|
||||||
|
- if: "(! response_has_local_ip) && [_response_valid_answer]"
|
||||||
|
exec:
|
||||||
|
- _drop_response
|
||||||
|
secondary:
|
||||||
|
- _prefer_ipv4
|
||||||
|
- forward_remote
|
||||||
|
- modify_ttl
|
||||||
|
fast_fallback: 200
|
||||||
|
|
||||||
|
servers:
|
||||||
|
- exec: main_sequence
|
||||||
|
listeners:
|
||||||
|
- protocol: udp
|
||||||
|
addr: ":5335"
|
||||||
|
- protocol: tcp
|
||||||
|
addr: ":5335"
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
adblock=$(uci -q get mosdns.mosdns.adblock)
|
adblock=$(uci -q get mosdns.mosdns.adblock)
|
||||||
if [ "$adblock" -eq 1 ];then
|
if [ "$adblock" -eq 1 ];then
|
||||||
echo "ext:/usr/share/v2ray/geosite.dat:category-ads-all"
|
echo "provider:geosite:category-ads-all"
|
||||||
fi
|
fi
|
||||||
|
156
luci-app-mosdns/root/usr/share/mosdns/default.yaml
Normal file
156
luci-app-mosdns/root/usr/share/mosdns/default.yaml
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
log:
|
||||||
|
level: log_level
|
||||||
|
file: "log_file"
|
||||||
|
|
||||||
|
include: []
|
||||||
|
|
||||||
|
data_providers:
|
||||||
|
- tag: geoip
|
||||||
|
file: "/usr/share/v2ray/geoip.dat"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: geosite
|
||||||
|
file: "/usr/share/v2ray/geosite.dat"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: whitelist
|
||||||
|
file: "/etc/mosdns/rule/whitelist.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: blocklist
|
||||||
|
file: "/etc/mosdns/rule/blocklist.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: hosts
|
||||||
|
file: "/etc/mosdns/rule/hosts.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
- tag: redirect
|
||||||
|
file: "/etc/mosdns/rule/redirect.txt"
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- tag: lazy_cache
|
||||||
|
type: cache
|
||||||
|
args:
|
||||||
|
size: cache_size
|
||||||
|
lazy_cache_ttl: cache_survival_time
|
||||||
|
|
||||||
|
- tag: modify_ttl
|
||||||
|
type: ttl
|
||||||
|
args:
|
||||||
|
minimal_ttl: minimal_ttl_custom
|
||||||
|
maximum_ttl: maximum_ttl_custom
|
||||||
|
|
||||||
|
- tag: "forward_local"
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: local_dns1
|
||||||
|
- addr: local_dns2
|
||||||
|
|
||||||
|
- tag: "forward_remote"
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: remote_dns1
|
||||||
|
- addr: remote_dns2
|
||||||
|
|
||||||
|
- tag: query_is_whitelist_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "provider:whitelist"
|
||||||
|
|
||||||
|
- tag: query_is_blocklist_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "provider:blocklist"
|
||||||
|
|
||||||
|
- tag: query_is_hosts_domain
|
||||||
|
type: hosts
|
||||||
|
args:
|
||||||
|
hosts:
|
||||||
|
- "provider:hosts"
|
||||||
|
|
||||||
|
- tag: query_is_redirect_domain
|
||||||
|
type: redirect
|
||||||
|
args:
|
||||||
|
rule:
|
||||||
|
- "provider:redirect"
|
||||||
|
|
||||||
|
- tag: query_is_local_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "provider:geosite:cn"
|
||||||
|
|
||||||
|
- tag: query_is_non_local_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "provider:geosite:geolocation-!cn"
|
||||||
|
|
||||||
|
- tag: response_has_local_ip
|
||||||
|
type: response_matcher
|
||||||
|
args:
|
||||||
|
ip:
|
||||||
|
- "provider:geoip:cn"
|
||||||
|
|
||||||
|
- tag: query_is_ad_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "adblock"
|
||||||
|
|
||||||
|
- tag: "main_sequence"
|
||||||
|
type: "sequence"
|
||||||
|
args:
|
||||||
|
exec:
|
||||||
|
- query_is_hosts_domain
|
||||||
|
- query_is_redirect_domain
|
||||||
|
|
||||||
|
- if: query_is_whitelist_domain
|
||||||
|
exec:
|
||||||
|
- forward_local
|
||||||
|
- modify_ttl
|
||||||
|
- _return
|
||||||
|
|
||||||
|
- if: "query_is_blocklist_domain || query_is_ad_domain"
|
||||||
|
exec:
|
||||||
|
- _new_nxdomain_response
|
||||||
|
- _return
|
||||||
|
|
||||||
|
- lazy_cache
|
||||||
|
|
||||||
|
- if: query_is_local_domain
|
||||||
|
exec:
|
||||||
|
- forward_local
|
||||||
|
- modify_ttl
|
||||||
|
- _return
|
||||||
|
|
||||||
|
- if: query_is_non_local_domain
|
||||||
|
exec:
|
||||||
|
- _prefer_ipv4
|
||||||
|
- forward_remote
|
||||||
|
- modify_ttl
|
||||||
|
- _return
|
||||||
|
- primary:
|
||||||
|
- forward_local
|
||||||
|
- if: "(! response_has_local_ip) && [_response_valid_answer]"
|
||||||
|
exec:
|
||||||
|
- _drop_response
|
||||||
|
secondary:
|
||||||
|
- _prefer_ipv4
|
||||||
|
- forward_remote
|
||||||
|
- modify_ttl
|
||||||
|
fast_fallback: 200
|
||||||
|
|
||||||
|
servers:
|
||||||
|
- exec: main_sequence
|
||||||
|
listeners:
|
||||||
|
- protocol: udp
|
||||||
|
addr: ":listen_port"
|
||||||
|
- protocol: tcp
|
||||||
|
addr: ":listen_port"
|
Loading…
Reference in New Issue
Block a user