IrineSistiana / mosdns

一个 DNS 转发器
GNU General Public License v3.0
3.01k stars 340 forks source link

[Bug] AAAA QTYPE 大量出现 context deadline exceeded #768

Open lonecale opened 1 year ago

lonecale commented 1 year ago

在提交之前,请确认

mosdns 版本

v5.3.1

操作系统

OpenWrt

Bug 描述和复现步骤

mosdns 满足条件的转发到 Openclash DNS端口 出现大量 context deadline exceeded 但是单独

使用的配置文件

- tag: forward_openclash
    type: forward
    args:
      concurrent: 1
      upstreams:
        - addr: "127.0.0.1:7874"

  - tag: forward_remote_upstream
    type: sequence
    args:
      - exec: query_summary forward
      - matches:
        - qtype 28
        exec: prefer_ipv4
      - exec: $forward_openclash

mosdns 的 log 记录

2023-11-26 22:35:33 WARN    forward_openclash   upstream error  {"uqid": 1686, "qname": "api.snapkit.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:33 WARN    forward_openclash   upstream error  {"uqid": 1707, "qname": "p16-sg.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:34 WARN    forward_openclash   upstream error  {"uqid": 1718, "qname": "mssdk22-normal-alisg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:34 WARN    forward_openclash   upstream error  {"uqid": 1722, "qname": "libra22-normal-alisg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:35 WARN    forward_openclash   upstream error  {"uqid": 1727, "qname": "api.service.sin2a.g.byteoversea.net.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:35 WARN    forward_openclash   upstream error  {"uqid": 1737, "qname": "p16-useast2a.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:36 WARN    forward_openclash   upstream error  {"uqid": 1742, "qname": "p16-sign-va.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:36 WARN    forward_openclash   upstream error  {"uqid": 1745, "qname": "p16-amd-va.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:36 WARN    forward_openclash   upstream error  {"uqid": 1748, "qname": "pitaya-sg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:37 WARN    forward_openclash   upstream error  {"uqid": 1752, "qname": "frontier.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:37 WARN    forward_openclash   upstream error  {"uqid": 1761, "qname": "oec22-normal-alisg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:37 WARN    forward_openclash   upstream error  {"uqid": 1767, "qname": "v.group.jp.g.byteoversea.net.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:37 WARN    forward_openclash   upstream error  {"uqid": 1769, "qname": "bsync-sg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:38 WARN    forward_openclash   upstream error  {"uqid": 1771, "qname": "sf16-sg.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:38 WARN    forward_openclash   upstream error  {"uqid": 1773, "qname": "webcast22-ws-alisg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:38 WARN    forward_openclash   upstream error  {"uqid": 1778, "qname": "webcast16-ws-alisg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:38 WARN    forward_openclash   upstream error  {"uqid": 1782, "qname": "pitaya-task-sg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:38 WARN    forward_openclash   upstream error  {"uqid": 1786, "qname": "pull-cmaf-f16-gcp01.ttlivecdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:38 WARN    forward_openclash   upstream error  {"uqid": 1787, "qname": "pull-w5-sg01.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:40 WARN    forward_openclash   upstream error  {"uqid": 1805, "qname": "api19-core-c-alisg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:40 WARN    forward_openclash   upstream error  {"uqid": 1808, "qname": "api16-normal-c-useast1a.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:41 WARN    forward_openclash   upstream error  {"uqid": 1811, "qname": "p16-sign.tiktokcdn-us.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:41 WARN    forward_openclash   upstream error  {"uqid": 1814, "qname": "pull-fcdn-base6.s.bytefcdn-oversea.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:41 WARN    forward_openclash   upstream error  {"uqid": 1817, "qname": "pull-cmaf-l10-sg01.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:42 WARN    forward_openclash   upstream error  {"uqid": 1822, "qname": "api19-normal-c-alisg.tiktokv.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:42 WARN    forward_openclash   upstream error  {"uqid": 1827, "qname": "v16.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:43 WARN    forward_openclash   upstream error  {"uqid": 1833, "qname": "push-rtmp-f5-vr-sg01.tiktokcdn.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:46 WARN    forward_openclash   upstream error  {"uqid": 1851, "qname": "api.steampowered.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:46 WARN    forward_openclash   upstream error  {"uqid": 1862, "qname": "avatars.cloudflare.steamstatic.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:47 WARN    forward_openclash   upstream error  {"uqid": 1866, "qname": "store.steampowered.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:35:47 WARN    forward_openclash   upstream error  {"uqid": 1869, "qname": "steamcommunity.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
2023-11-26 22:38:24 WARN    forward_openclash   upstream error  {"uqid": 1930, "qname": "github-cloud.s3.amazonaws.com.", "qclass": 1, "qtype": 28, "upstream": "127.0.0.1:7874", "error": "context deadline exceeded"}
kkkgo commented 1 year ago

这只能说明你的127.0.0.1:7874不会响应AAAA记录。

lonecale commented 1 year ago

这只能说明你的127.0.0.1:7874不会响应AAAA记录。

这些地址我发现大多都是: 响应 AAAA 应答没有期望的ANSWER,只有CNAME记录 响应 A 应答是有期望的 ANSWER

因为forward_openclash 是最后一个工作流程。这样 我无法在forward_openclash后面匹配 has_wanted_ans 判断。 还有一个方式只能 如下

但是这样转给forward_openclash就是应答的ip了 而不是域名了有什么好的处理办法呢 ?希望的效果是如果是双栈 只用ipv4转发forward_openclash 如果是单独IPV4或者IPV6的就直接forward_openclash

这个context deadline exceeded错误 应该就是这样 prefer_ipv4 把目标 同时进行ipv4/6请求到后面的一个forward 如何ipv4/6一方没有返回就出现