pymumu / smartdns

A local DNS server to obtain the fastest website IP for the best Internet experience, support DoT, DoH. 一个本地DNS服务器,获取最快的网站IP,获得最佳上网体验,支持DoH,DoT。
https://pymumu.github.io/smartdns/
GNU General Public License v3.0
8.46k stars 1.08k forks source link

定义了组名的服务器没有从默认组中排除 #1762

Open choyri opened 4 months ago

choyri commented 4 months ago

问题现象

在源码中看到这么几行:

https://github.com/pymumu/smartdns/blob/07c13827bb523519a638214ed7ad76180f71a40a/src/dns_conf.c#L999-L1002

我觉得它的意思是,如果一个 server 配置了 group,就将它从默认组中排除;然而实际上没有。

运行环境

  1. 固件型号:N/A

  2. 运营商:N/A

  3. smartdns来源以及版本:Link

  4. 涉及的配置(注意去除个人相关信息)

bind [::]:5555 -no-cache

server-tls 223.5.5.5
server 0.0.0.0:6666 -group test # dummy dns, just test
# server 0.0.0.0:6666 -group test -exclude-default-group

log-console yes
log-level debug

domain-rules /dl.google.com/ -nameserver default
domain-rules /google.com/ -nameserver test

重现步骤

  1. 上游DNS配置:N/A

  2. 访问的域名

dig @localhost -p 5555 dl.google.com

信息收集

使用上述配置时,查询 dl.google.com 可以看到同时往 test 组进行了查询,与我想象的不一样:

[2024-06-23 11:17:22,984][DEBUG][     dns_server.c:7155] recv query packet from 127.0.0.1, len = 54, type = 0
[2024-06-23 11:17:22,984][DEBUG][            dns.c:2160] opt type 10
[2024-06-23 11:17:22,984][DEBUG][     dns_server.c:7171] request qdcount = 1, ancount = 0, nscount = 0, nrcount = 0, len = 54, id = 33750, tc = 0, rd = 1, ra = 0, rcode = 0
[2024-06-23 11:17:22,984][DEBUG][     dns_server.c:7196] query dl.google.com from 127.0.0.1, qtype: 1, id: 33750, query-num: 1
[2024-06-23 11:17:22,984][ INFO][     dns_server.c:5264] RULE-MATCH, type: 8, domain: dl.google.com, rule: dl.google.com.
[2024-06-23 11:17:22,984][DEBUG][     dns_client.c:3855] send query to server 0.0.0.0:6666
[2024-06-23 11:17:22,984][DEBUG][     dns_client.c:3855] send query to server 223.5.5.5:853
[2024-06-23 11:17:22,984][DEBUG][     dns_client.c:2582] recvfrom 0.0.0.0 failed, Connection refused
[2024-06-23 11:17:22,984][DEBUG][     dns_client.c:2376] tls server 223.5.5.5 connecting.
[2024-06-23 11:17:22,984][ INFO][     dns_client.c:4252] request: dl.google.com, qtype: 1, id: 31023, group: default
[2024-06-23 11:17:22,984][DEBUG][     dns_client.c:1324] server 0.0.0.0 closed.
[2024-06-23 11:17:23,062][DEBUG][     dns_client.c:3325] tls server 223.5.5.5 connected.

如果改成 server 0.0.0.0:6666 -group test -exclude-default-group,查询就符合预期了:

[2024-06-23 11:17:44,738][DEBUG][     dns_server.c:7155] recv query packet from 127.0.0.1, len = 54, type = 0
[2024-06-23 11:17:44,738][DEBUG][            dns.c:2160] opt type 10
[2024-06-23 11:17:44,738][DEBUG][     dns_server.c:7171] request qdcount = 1, ancount = 0, nscount = 0, nrcount = 0, len = 54, id = 56299, tc = 0, rd = 1, ra = 0, rcode = 0
[2024-06-23 11:17:44,738][DEBUG][     dns_server.c:7196] query dl.google.com from 127.0.0.1, qtype: 1, id: 56299, query-num: 1
[2024-06-23 11:17:44,738][ INFO][     dns_server.c:5264] RULE-MATCH, type: 8, domain: dl.google.com, rule: dl.google.com.
[2024-06-23 11:17:44,738][DEBUG][     dns_client.c:3855] send query to server 223.5.5.5:853
[2024-06-23 11:17:44,738][DEBUG][     dns_client.c:2376] tls server 223.5.5.5 connecting.
[2024-06-23 11:17:44,738][ INFO][     dns_client.c:4252] request: dl.google.com, qtype: 1, id: 43367, group: default
[2024-06-23 11:17:44,815][DEBUG][     dns_client.c:3325] tls server 223.5.5.5 connected.
PikuZheng commented 4 months ago

就我所理解这个group是指配置组,不是上游服务器组