mirror of
https://github.com/coolsnowwolf/packages.git
synced 2025-05-01 20:49:57 +08:00
mosdns: Update default config template (#481)
This commit is contained in:
parent
2f55f25728
commit
2dec456561
@ -2,89 +2,118 @@ log:
|
|||||||
level: error
|
level: error
|
||||||
file: ''
|
file: ''
|
||||||
|
|
||||||
plugin:
|
data_providers:
|
||||||
|
- tag: geosite
|
||||||
|
file: /usr/share/v2ray/geosite.dat
|
||||||
|
auto_reload: true
|
||||||
|
- tag: geoip
|
||||||
|
file: /usr/share/v2ray/geoip.dat
|
||||||
|
auto_reload: true
|
||||||
|
|
||||||
################# 服务插件 ################
|
plugins:
|
||||||
|
# 缓存
|
||||||
- tag: main_server # 启动服务器
|
- tag: cache
|
||||||
type: server
|
type: cache
|
||||||
args:
|
args:
|
||||||
entry:
|
size: 1024
|
||||||
- _default_cache # 缓存
|
|
||||||
- main_sequence
|
|
||||||
server:
|
|
||||||
- protocol: udp
|
|
||||||
addr: 127.0.0.1:6052
|
|
||||||
- protocol: tcp
|
|
||||||
addr: 127.0.0.1:6052
|
|
||||||
- protocol: udp
|
|
||||||
addr: '[::1]:6052'
|
|
||||||
- protocol: tcp
|
|
||||||
addr: '[::1]:6052'
|
|
||||||
|
|
||||||
################# 可执行插件 ################
|
# 转发至本地服务器的插件
|
||||||
|
- tag: forward_local
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: https://1.12.12.12/dns-query
|
||||||
|
|
||||||
|
# 转发至远程服务器的插件
|
||||||
|
- tag: forward_remote
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: https://8.8.8.8/dns-query
|
||||||
|
|
||||||
|
# 匹配本地域名的插件
|
||||||
|
- 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: query_is_ad_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- 'provider:geosite:category-ads-all'
|
||||||
|
|
||||||
|
# 匹配本地 IP 的插件
|
||||||
|
- tag: response_has_local_ip
|
||||||
|
type: response_matcher
|
||||||
|
args:
|
||||||
|
ip:
|
||||||
|
- 'provider:geoip:cn'
|
||||||
|
|
||||||
|
# 主要的运行逻辑插件
|
||||||
|
# sequence 插件中调用的插件 tag 必须在 sequence 前定义,
|
||||||
|
# 否则 sequence 找不到对应插件。
|
||||||
- tag: main_sequence
|
- tag: main_sequence
|
||||||
type: sequence
|
type: sequence
|
||||||
args:
|
args:
|
||||||
exec:
|
exec:
|
||||||
- if:
|
# 缓存
|
||||||
- query_is_local_domain # 已知的本地域名
|
- cache
|
||||||
- '!_query_is_common' # 和不常见的请求类型
|
|
||||||
|
# 屏蔽广告域名
|
||||||
|
- if: query_is_ad_domain
|
||||||
exec:
|
exec:
|
||||||
- forward_local # 用本地服务器
|
- _new_nxdomain_response
|
||||||
- _end
|
- _return
|
||||||
|
|
||||||
- if:
|
# 已知的本地域名用本地服务器解析
|
||||||
- query_is_non_local_domain # 已知的非本地域名
|
- if: query_is_local_domain
|
||||||
exec:
|
exec:
|
||||||
- forward_remote # 用远程服务器
|
- forward_local
|
||||||
- _end
|
- _return
|
||||||
|
|
||||||
# 剩下的未知域名用 IP 分流。以下是"顺序 IP 分流"的逻辑。很稳定,不易出错。
|
# 已知的非本地域名用远程服务器解析
|
||||||
# <高级> 如果想用"并发 IP 分流"逻辑,从下文的 <并发 IP 分流示例> 里选择一个方案,
|
- if: query_is_non_local_domain
|
||||||
# 然后将下面几行替换掉。
|
|
||||||
- forward_local # 先请求转发至本地服务器
|
|
||||||
- if:
|
|
||||||
- response_has_local_ip # 如果(本地)应答包含本地 IP
|
|
||||||
exec:
|
exec:
|
||||||
- _end # 就直接采用结果
|
- forward_remote
|
||||||
- forward_remote # 否则去请求远程服务器的结果
|
- _return
|
||||||
|
|
||||||
- tag: forward_local # 转发至本地服务器的插件
|
# 剩下的未知域名用 IP 分流。
|
||||||
type: forward
|
# 这里借助了 `fallback` 工作机制。分流原理请参考 `fallback`
|
||||||
args:
|
# 的工作流程。
|
||||||
upstream:
|
# primary 从本地服务器获取应答,丢弃非本地 IP 的结果。
|
||||||
- addr: 127.0.0.1:6050
|
- primary:
|
||||||
|
- forward_local
|
||||||
|
- if: "(! response_has_local_ip) && [_response_valid_answer]"
|
||||||
|
exec:
|
||||||
|
- _drop_response
|
||||||
|
# secondary 从远程服务器获取应答。
|
||||||
|
secondary:
|
||||||
|
- _prefer_ipv4
|
||||||
|
- forward_remote
|
||||||
|
# 这里建议设置成 local 服务器正常延时的 2~5 倍。
|
||||||
|
# 这个延时保证了 local 延时偶尔变高时,其结果不会被 remote 抢答。
|
||||||
|
# 如果 local 超过这个延时还没响应,可以假设 local 出现了问题。
|
||||||
|
# 这时用就采用 remote 的应答。单位: 毫秒。
|
||||||
|
fast_fallback: 200
|
||||||
|
|
||||||
- tag: forward_remote # 转发至远程服务器的插件
|
servers:
|
||||||
type: forward
|
- exec: main_sequence
|
||||||
args:
|
listeners:
|
||||||
upstream:
|
- protocol: udp
|
||||||
- addr: 127.0.0.1:6051
|
addr: 127.0.0.1:6052
|
||||||
|
- protocol: tcp
|
||||||
################ 匹配器插件 #################
|
addr: 127.0.0.1:6052
|
||||||
|
- protocol: udp
|
||||||
- tag: query_is_local_domain # 匹配本地域名的插件
|
addr: '[::1]:6052'
|
||||||
type: query_matcher
|
- protocol: tcp
|
||||||
args:
|
addr: '[::1]:6052'
|
||||||
domain:
|
|
||||||
- 'ext:/usr/share/v2ray/geosite.dat:cn'
|
|
||||||
|
|
||||||
- tag: query_is_non_local_domain # 匹配非本地域名的插件
|
|
||||||
type: query_matcher
|
|
||||||
args:
|
|
||||||
domain:
|
|
||||||
- 'ext:/usr/share/v2ray/geosite.dat:geolocation-!cn'
|
|
||||||
|
|
||||||
- tag: query_is_ad_domain # 匹配广告域名的插件
|
|
||||||
type: query_matcher
|
|
||||||
args:
|
|
||||||
domain:
|
|
||||||
- 'ext:/usr/share/v2ray/geosite.dat:category-ads-all'
|
|
||||||
|
|
||||||
- tag: response_has_local_ip # 匹配本地 IP的插件
|
|
||||||
type: response_matcher
|
|
||||||
args:
|
|
||||||
ip:
|
|
||||||
- 'ext:/usr/share/v2ray/geoip.dat:cn'
|
|
||||||
|
Loading…
Reference in New Issue
Block a user