Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 升级到 v0.22.1 后除 hosts 内写死的域名外所有的查询都无返回结果 #27

Closed
IceCodeNew opened this issue Jan 1, 2021 · 5 comments

Comments

@IceCodeNew
Copy link

出现了什么问题

升级到 v0.22.1 后除 hosts 内写死的域名外所有的查询都无返回结果。

Log

time="2021-01-01T17:22:13+08:00" level=info msg="received signal: interrupt, bye" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.Run.func1 file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:38"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin my_server" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin main_pipeline" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin main_sequence" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin cloak_hosts" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin set_ecs" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin with_fallback_cn_dns_serv" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin plain_req_pku_and_tuna" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin forward_ali_and_tx" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin forward_quad9" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin query_is_local_domain" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin query_is_non_local_domain" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin query_is_ad_domain" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin match_aaaa" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="loading plugin response_has_local_cdn" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.loadConfig file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:74"
time="2021-01-01T17:22:14+08:00" level=info msg="all plugins are successfully loaded" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.Run file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:47"
time="2021-01-01T17:22:14+08:00" level=debug msg="loaded plugins: [_qtype_A_AAAA main_pipeline main_sequence with_fallback_cn_dns_serv plain_req_pku_and_tuna forward_ali_and_tx forward_quad9 query_is_local_domain _default_cache _no_ecs _query_is_common _response_rcode_success my_logger my_server query_is_ad_domain match_aaaa _drop_response _block_with_servfail _block_with_nxdomain _end cloak_hosts set_ecs query_is_non_local_domain response_has_local_cdn]" func=github.com/IrineSistiana/mosdns/dispatcher/coremain.Run file="github.com/IrineSistiana/mosdns/dispatcher/coremain/run.go:48"
time="2021-01-01T17:22:29+08:00" level=debug msg="HeapObjects: 756735 NumGC: 7 PauseTotalNs: 0, NumGoroutine: 10" func=github.com/IrineSistiana/mosdns/dispatcher/plugin/logger.configLogger.func1 file="github.com/IrineSistiana/mosdns/dispatcher/plugin/logger/logger.go:117"
time="2021-01-01T17:22:44+08:00" level=debug msg="HeapObjects: 756763 NumGC: 7 PauseTotalNs: 0, NumGoroutine: 10" func=github.com/IrineSistiana/mosdns/dispatcher/plugin/logger.configLogger.func1 file="github.com/IrineSistiana/mosdns/dispatcher/plugin/logger/logger.go:117"
time="2021-01-01T17:22:59+08:00" level=debug msg="HeapObjects: 756791 NumGC: 7 PauseTotalNs: 0, NumGoroutine: 10" func=github.com/IrineSistiana/mosdns/dispatcher/plugin/logger.configLogger.func1 file="github.com/IrineSistiana/mosdns/dispatcher/plugin/logger/logger.go:117"
time="2021-01-01T17:23:14+08:00" level=debug msg="HeapObjects: 756828 NumGC: 7 PauseTotalNs: 0, NumGoroutine: 10" func=github.com/IrineSistiana/mosdns/dispatcher/plugin/logger.configLogger.func1 file="github.com/IrineSistiana/mosdns/dispatcher/plugin/logger/logger.go:117"

如何重现

mosdns 的版本号(mosdns -v):
v0.22.1-0-g8c1d997

使用的启动参数或启动方式:
使用发行时压缩包内包含的 winsw XML 配置将 mosdns 安装为系统服务并启动。

操作系统和平台:
WSL

进行了什么操作导致了问题的出现:
dig +nocookie example.com @127.0.0.1

使用的配置文件:

plugin:
  - tag: my_logger
    type: logger
    args:
      level: trace
      file: "./mosdns.log"

  - tag: my_server
    type: server
    args:
      entry: main_pipeline
      max_concurrent_queries: 0
      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"

  ################ Executable Plugin (Route) #################

  - tag: main_pipeline
    type: pipeline
    args:
      pipe:
        - cloak_hosts
        - _default_cache
        - set_ecs
        - main_sequence

  - tag: main_sequence
    type: sequence
    args:
      exec:
        - if:
            - query_is_ad_domain
          exec:
            - _block_with_nxdomain
          goto: _end

        - if:
            - query_is_non_local_domain
          exec:
            - forward_quad9
            - if:
                - match_aaaa
              exec:
                - _drop_response
          goto: _end

        - if:
            - query_is_local_domain
          exec:
            - with_fallback_cn_dns_serv
          goto: _end

        - forward_quad9        # 兜底

  ################# Context Plugin ################

  - tag: cloak_hosts
    type: hosts
    args:
      hosts:
        - ./mosdns-hosts.txt

  ################# Executable Plugin (Function) ################

  - tag: set_ecs
    type: ecs
    args:
      auto: false
      force_overwrite: false
      mask4: 24
      mask6: 32
      ipv4: "1.1.1.1"
      ipv6: "8888:8888:8888:8888:8888:8888:8888:8888"

  - tag: with_fallback_cn_dns_serv
    type: fallback
    args:
      primary:
        - _no_ecs
        - plain_req_pku_and_tuna
      secondary:
        - set_ecs
        - forward_ali_and_tx
      stat_length: 8
      threshold: 4

  - tag: plain_req_pku_and_tuna
    type: fast_forward
    args:
      deduplicate: true
      upstream:
        - protocol: tcp
          addr: 101.6.6.6:5353
          trusted: true
          timeout: 5
          idle_timeout: 10
        - protocol: udp
          addr: 101.6.6.6:53
          trusted: true
          timeout: 5
          idle_timeout: 10

  - tag: forward_ali_and_tx
    type: forward
    args:
      upstream:
        - addr: https://223.5.5.5/dns-query
        - addr: tls://223.6.6.6
        - addr: https://doh.pub/dns-query
        - addr: tls://dns.pub
      deduplicate: true
      insecure_skip_verify: false
      timeout: 10
      bootstrap:
        - 119.29.29.29:53
        - 119.28.28.28:53
        - 223.5.5.5:53
        - 223.6.6.6:53

  - tag: forward_quad9
    type: forward
    args:
      upstream:
        - addr: https://9.9.9.11/dns-query
      deduplicate: true
      insecure_skip_verify: false
      timeout: 10

  ################ Matcher Plugin #################

  - tag: query_is_local_domain        # 匹配本地域名的插件
    type: query_matcher
    args:
      qtype: [1, 28]
      domain:                         # 匹配请求域名的域名表
        - "./geosite.dat:cn"
        - "./dnsmasq-china-list.txt"

  - tag: query_is_non_local_domain    # 匹配非本地域名的插件
    type: query_matcher
    args:
      qtype: [1, 28]
      domain:
        - "./geosite.dat:geolocation-!cn"

  - tag: query_is_ad_domain           # 匹配广告域名的插件
    type: query_matcher
    args:
      qtype: [1, 28]
      domain:
        - "./geosite.dat:category-ads-all"

  - tag: match_aaaa
    type: query_matcher
    args:
      qtype: [28]

  - tag: response_has_local_cdn
    type: response_matcher
    args:
      rcode: [0]
      CNAME:                          # 匹配应答 CNAME 记录的域名表
        - ./dnsmasq-china-list.txt
      ## Tips: CNAME 记录有助于识别该域名背后的关联域名,比如 CDN。
@IceCodeNew
Copy link
Author

IceCodeNew commented Jan 1, 2021

查询无返回结果的具体表现:等待查询很久(直到超时),dig 调试可以看到如下的返回:
image


配置里日志级别已经调到 trace 级别了,但还是只能看到插件加载成功的信息和 cache 插件定期 GC 的日志。完全看不到接收查询请求,处理请求的内部逻辑等等……

@IrineSistiana
Copy link
Owner

IrineSistiana commented Jan 1, 2021

要是把 hosts 注释掉会怎么样?

EDIT: 没有日志就很奇怪。我拿你配置本地复现一下。

@IrineSistiana
Copy link
Owner

没有日志应该是 mosdns 压根没有收到请求。这个很迷。我用你的配置复现了一下,能收到请求。你是在 WSL 里用的 dig ? 我印象里 WSL 好像有自己的一个 IP。不是 127.0.0.1


然后发现你的配置有个问题。

匹配器:

逻辑关系: 或。满足任意条件即为 true。

如果你这样写

  - tag: query_is_ad_domain           # 匹配广告域名的插件
    type: query_matcher
    args:
      qtype: [1, 28]  # <——- 会把全部 A AAAA 结果全部匹配进去
      domain:
        - "./geosite.dat:category-ads-all"

@IrineSistiana
Copy link
Owner

这个配置方式感觉更直观。应该加个选项能让 matcher 能变成 与 模式。

@IceCodeNew
Copy link
Author

你是在 WSL 里用的 dig ? 我印象里 WSL 好像有自己的一个 IP。不是 127.0.0.1

你这么一说我也想起来了,确实是这样。谢谢提醒。

匹配器:

逻辑关系: 或。满足任意条件即为 true。

这个配置方式感觉更直观。应该加个选项能让 matcher 能变成 与 模式。

嗯,虽然在我的这个使用场景下其实用不到逻辑与,但是加上这个选项应该会有帮助。
我是看 Wiki 上加了这么多 args,先入为主以为几个条件要同时满足才会匹配上。是我没有仔细看 Wiki hhh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants