mirror of
https://github.com/coolsnowwolf/packages.git
synced 2025-05-01 10:31:21 +08:00
mosdns: Update default config template (#481)
This commit is contained in:
parent
2f55f25728
commit
2dec456561
@ -2,89 +2,118 @@ log:
|
||||
level: error
|
||||
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
|
||||
|
||||
################# 服务插件 ################
|
||||
|
||||
- tag: main_server # 启动服务器
|
||||
type: server
|
||||
plugins:
|
||||
# 缓存
|
||||
- tag: cache
|
||||
type: cache
|
||||
args:
|
||||
entry:
|
||||
- _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'
|
||||
size: 1024
|
||||
|
||||
################# 可执行插件 ################
|
||||
# 转发至本地服务器的插件
|
||||
- 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
|
||||
type: sequence
|
||||
args:
|
||||
exec:
|
||||
- if:
|
||||
- query_is_local_domain # 已知的本地域名
|
||||
- '!_query_is_common' # 和不常见的请求类型
|
||||
# 缓存
|
||||
- cache
|
||||
|
||||
# 屏蔽广告域名
|
||||
- if: query_is_ad_domain
|
||||
exec:
|
||||
- forward_local # 用本地服务器
|
||||
- _end
|
||||
- _new_nxdomain_response
|
||||
- _return
|
||||
|
||||
- if:
|
||||
- query_is_non_local_domain # 已知的非本地域名
|
||||
# 已知的本地域名用本地服务器解析
|
||||
- if: query_is_local_domain
|
||||
exec:
|
||||
- forward_remote # 用远程服务器
|
||||
- _end
|
||||
- forward_local
|
||||
- _return
|
||||
|
||||
# 剩下的未知域名用 IP 分流。以下是"顺序 IP 分流"的逻辑。很稳定,不易出错。
|
||||
# <高级> 如果想用"并发 IP 分流"逻辑,从下文的 <并发 IP 分流示例> 里选择一个方案,
|
||||
# 然后将下面几行替换掉。
|
||||
- forward_local # 先请求转发至本地服务器
|
||||
- if:
|
||||
- response_has_local_ip # 如果(本地)应答包含本地 IP
|
||||
# 已知的非本地域名用远程服务器解析
|
||||
- if: query_is_non_local_domain
|
||||
exec:
|
||||
- _end # 就直接采用结果
|
||||
- forward_remote # 否则去请求远程服务器的结果
|
||||
- forward_remote
|
||||
- _return
|
||||
|
||||
- tag: forward_local # 转发至本地服务器的插件
|
||||
type: forward
|
||||
args:
|
||||
upstream:
|
||||
- addr: 127.0.0.1:6050
|
||||
# 剩下的未知域名用 IP 分流。
|
||||
# 这里借助了 `fallback` 工作机制。分流原理请参考 `fallback`
|
||||
# 的工作流程。
|
||||
# primary 从本地服务器获取应答,丢弃非本地 IP 的结果。
|
||||
- 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 # 转发至远程服务器的插件
|
||||
type: forward
|
||||
args:
|
||||
upstream:
|
||||
- addr: 127.0.0.1:6051
|
||||
|
||||
################ 匹配器插件 #################
|
||||
|
||||
- tag: query_is_local_domain # 匹配本地域名的插件
|
||||
type: query_matcher
|
||||
args:
|
||||
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'
|
||||
servers:
|
||||
- exec: main_sequence
|
||||
listeners:
|
||||
- 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'
|
||||
|
Loading…
Reference in New Issue
Block a user