IrineSistiana / mosdns

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

[Bug] 下层 sequence accept 后,上级 sequence 会继续执行 #665

Closed wutea7 closed 1 year ago

wutea7 commented 1 year ago

在提交之前,请确认

mosdns 版本

v5.1.3-0-gac99eb1

操作系统

macOS Ventura 13.3.1

Bug 描述和复现步骤

从 main_sequence 进入 local_sequence 后,如果 has_resp 的话 accept。

按照文档 accept 后所有 sequence 都不再继续执行后续规则,但是日志打印显示还是回到 main_sequence 中继续执行了。

使用的配置文件

plugins:
  - tag: local_forward
    type: forward
    args:
      concurrent: 1
      upstreams:
        - addr: https://1.12.12.12/dns-query

  - tag: local_sequence
    type: sequence
    args:
      - exec: debug_print AAAAAAAAAAAAAAAAAAAA
      - exec: $local_forward
      - matches: has_resp
        exec: debug_print BBBBBBBBBBBBBBBBBBBB
      - matches: has_resp
        exec: accept

  - tag: main_sequence
    type: sequence
    args:
      - exec: prefer_ipv4
      - matches: qname &./Loyalsoldier/direct-list.txt
        exec: $local_sequence
      - exec: debug_print CCCCCCCCCCCCCCCCCCCC

  - tag:
    type: udp_server
    args:
      entry: main_sequence
      listen: :53

mosdns 的 log 记录

2023-04-22T20:51:40.894+0800    INFO    main config loaded  {"file": "/Users/wutea7/Downloads/mosdns/config.yaml"}
2023-04-22T20:51:40.895+0800    INFO    loading plugin  {"tag": "local_forward", "type": "forward"}
2023-04-22T20:51:40.896+0800    INFO    loading plugin  {"tag": "local_sequence", "type": "sequence"}
2023-04-22T20:51:40.896+0800    INFO    loading plugin  {"tag": "main_sequence", "type": "sequence"}
2023-04-22T20:51:40.927+0800    INFO    loading plugin  {"tag": "anonymouse_udp_server_4", "type": "udp_server"}
2023-04-22T20:51:40.928+0800    INFO    all plugins are loaded
2023-04-22T20:51:42.022+0800    INFO    local_sequence.r0   AAAAAAAAAAAAAAAAAAAA    {"query": ";; opcode: QUERY, status: NOERROR, id: 7000\n;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0\n\n;; QUESTION SECTION:\n;baidu.com.\tIN\t A\n"}
2023-04-22T20:51:42.110+0800    INFO    local_sequence.r2   BBBBBBBBBBBBBBBBBBBB    {"query": ";; opcode: QUERY, status: NOERROR, id: 7000\n;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0\n\n;; QUESTION SECTION:\n;baidu.com.\tIN\t A\n"}
2023-04-22T20:51:42.110+0800    INFO    local_sequence.r2   BBBBBBBBBBBBBBBBBBBB    {"response": ";; opcode: QUERY, status: NOERROR, id: 7000\n;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version 0; flags:; udp: 512\n; PADDING: 000......000\n\n;; QUESTION SECTION:\n;baidu.com.\tIN\t A\n\n;; ANSWER SECTION:\nbaidu.com.\t19\tIN\tA\t39.156.66.10\nbaidu.com.\t19\tIN\tA\t110.242.68.66\n"}
2023-04-22T20:51:42.110+0800    INFO    main_sequence.r2    CCCCCCCCCCCCCCCCCCCC    {"query": ";; opcode: QUERY, status: NOERROR, id: 7000\n;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0\n\n;; QUESTION SECTION:\n;baidu.com.\tIN\t A\n"}
2023-04-22T20:51:42.110+0800    INFO    main_sequence.r2    CCCCCCCCCCCCCCCCCCCC    {"response": ";; opcode: QUERY, status: NOERROR, id: 7000\n;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1\n\n;; OPT PSEUDOSECTION:\n; EDNS: version 0; flags:; udp: 512\n; PADDING: 000......000\n\n;; QUESTION SECTION:\n;baidu.com.\tIN\t A\n\n;; ANSWER SECTION:\nbaidu.com.\t19\tIN\tA\t39.156.66.10\nbaidu.com.\t19\tIN\tA\t110.242.68.66\n"}
wutea7 commented 1 year ago

exec: $local_sequence 改为 exec: jump local_sequence 解决