diff options
author | Midori | 2022-06-27 12:02:44 +0900 |
---|---|---|
committer | Midori | 2022-06-27 12:02:44 +0900 |
commit | fda9b353dd5113e0b4a207a3feee4fe7a93f5291 (patch) | |
tree | ce04ca37a699f95e1e92f42d8dc212b93f3e2135 | |
parent | 24d55e4572fb51c21475a6cf1968a60bb69d6792 (diff) | |
download | aur-fda9b353dd5113e0b4a207a3feee4fe7a93f5291.tar.gz |
v4.0.0
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 10 | ||||
-rw-r--r-- | config.yaml | 160 | ||||
-rw-r--r-- | service | 4 |
4 files changed, 97 insertions, 81 deletions
@@ -1,7 +1,7 @@ pkgbase = mosdns-bin pkgdesc = Plug-in configured DNS forwarder/server - pkgver = 3.9.0 - pkgrel = 2 + pkgver = 4.0.0 + pkgrel = 1 url = https://github.com/IrineSistiana/mosdns/ arch = x86_64 license = GPL3 @@ -1,8 +1,8 @@ # Maintainer: suienzan <suienzan at gmail dot com> _pkgname=mosdns pkgname=${_pkgname}-bin -pkgver=3.9.0 -pkgrel=2 +pkgver=4.0.0 +pkgrel=1 pkgdesc="Plug-in configured DNS forwarder/server" arch=('x86_64') url="https://github.com/IrineSistiana/mosdns/" @@ -14,9 +14,9 @@ backup=('etc/mosdns/config.yaml') provides=('mosdns') conflicts=('mosdns' 'mosdns-git') source=("$pkgname-$pkgver.zip::https://github.com/IrineSistiana/mosdns/releases/download/v${pkgver}/mosdns-linux-amd64.zip" "service" "config.yaml") -sha256sums=('ddcdb7eb7d8d4783edfd7c9e60b719837407b2cf8abdc292413d03f6a7718652' - 'b73feace50f17752d7a8f3012e546a6d05bfb13ba4946c93b82d511af974719a' - 'cd7f17517edead1f49b297b60ae510a7608607ea9293bbc5ecb8521163268116') +sha256sums=('68e5fa78a95b6f244610e09befb2c564ee4326e04e98a6f067f6ca2186253476' + 'b85dd6e5522e558bb1282734bbb684ceee019047d7597bdbde4dc07a8d59317e' + '5ff706ed3d6e5e8624e6f8b276ed1e476be8ebc4747043e63999c8a9f9324ea8') package() { install -Dm755 mosdns "$pkgdir"/usr/bin/mosdns diff --git a/config.yaml b/config.yaml index 31d60e90b459..d35a2fc256eb 100644 --- a/config.yaml +++ b/config.yaml @@ -1,103 +1,119 @@ log: - level: info + level: debug 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:53 - - protocol: tcp - addr: 127.0.0.1:53 - - protocol: udp - addr: "[::1]:53" - - protocol: tcp - addr: "[::1]:53" + size: 1024 - ################# 可执行插件 ################ - - # 包含分流的逻辑的插件 - - tag: main_sequence - type: sequence - args: - exec: - - if: - - query_is_ad_domain # 已知的广告域名 - exec: - - _block_with_nxdomain # 用 NXDOMAIN 屏蔽 - - _return - - - if: - - query_is_local_domain # 已知的本地域名 - - "!_query_is_common" # 和不常见的请求类型 - exec: - - forward_local # 用本地服务器 - - _return - - - if: - - query_is_non_local_domain # 已知的非本地域名 - exec: - - forward_remote # 用远程服务器 - - _return - - # 剩下的未知域名用 IP 分流。以下是"顺序 IP 分流"方案。先转发至本地服务器,然后 - # 判断应答 IP 再决定是否转发至远程服务器。没有竞争,很稳定,不易出错。 - # <高级> 如果想用"并发 IP 分流"方案,从下文的 <并发 IP 分流示例> 里选择一个方案, - # 然后将下面几行替换掉。复制时注意缩进。 - # 并发分流会同时请求本地和远程服务器,延时稍低些,但存在竞争,可能出现非期望的分流结果。 - - forward_local # 先请求转发至本地服务器 - - if: - - response_has_local_ip # 如果(本地)应答包含本地 IP - exec: - - _return # 就直接采用结果 - - forward_remote # 否则去请求远程服务器的结果 - - # 转发请求至本地服务器的插件 + # 转发至本地服务器的插件 - tag: forward_local - type: "fast_forward" + type: fast_forward args: upstream: - - addr: https://223.5.5.5/dns-query + - addr: https://1.12.12.12/dns-query - # 转发请求至远程服务器的插件 + # 转发至远程服务器的插件 - tag: forward_remote - type: "fast_forward" + type: fast_forward args: upstream: - addr: https://45.11.45.11/dns-query - ################ 匹配器插件 ################# - - - tag: query_is_local_domain # 匹配本地域名的插件 + # 匹配本地域名的插件 + - tag: query_is_local_domain type: query_matcher args: 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 args: domain: - - ext:/usr/share/v2ray/geosite.dat:geolocation-!cn + - 'provider:geosite:geolocation-!cn' - - tag: query_is_ad_domain # 匹配广告域名的插件 + # 匹配广告域名的插件 + - tag: query_is_ad_domain type: query_matcher args: domain: - - ext:/usr/share/v2ray/geosite.dat:category-ads-all + - 'provider:geosite:category-ads-all' - - tag: response_has_local_ip # 匹配本地 IP的插件 + # 匹配本地 IP 的插件 + - tag: response_has_local_ip type: response_matcher args: ip: - - ext:/usr/share/v2ray/geoip.dat:cn + - 'provider:geoip:cn' + + # 主要的运行逻辑插件 + # sequence 插件中调用的插件 tag 必须在 sequence 前定义, + # 否则 sequence 找不到对应插件。 + - tag: main_sequence + type: sequence + args: + exec: + # 缓存 + - cache + + # 屏蔽广告域名 + - if: query_is_ad_domain + exec: + - _new_nxdomain_response + - _return + + # 已知的本地域名用本地服务器解析 + - if: query_is_local_domain + exec: + - forward_local + - _return + + # 已知的非本地域名用远程服务器解析 + - if: query_is_non_local_domain + exec: + - forward_remote + - _return + + # 剩下的未知域名用 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 -include: [] +servers: + - exec: main_sequence + listeners: + - protocol: udp + addr: 127.0.0.1:53 + - protocol: tcp + addr: 127.0.0.1:53 + - protocol: udp + addr: "[::1]:53" + - protocol: tcp + addr: "[::1]:53"
\ No newline at end of file @@ -1,11 +1,11 @@ [Unit] Description=mosdns Service -Documentation=https://github.com/IrineSistiana/mosdns/wiki +Documentation=https://irine-sistiana.gitbook.io/mosdns-wiki/ After=network.target [Service] NoNewPrivileges=true -ExecStart=/usr/bin/mosdns -c /etc/mosdns/config.yaml -dir /etc/mosdns/ +ExecStart=/usr/bin/mosdns start -c /etc/mosdns/config.yaml -d /etc/mosdns/ Restart=on-failure [Install] |