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

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

Open
choyri opened this issue Jun 23, 2024 · 1 comment
Open

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

choyri opened this issue Jun 23, 2024 · 1 comment

Comments

@choyri
Copy link

choyri commented Jun 23, 2024

问题现象

在源码中看到这么几行:

smartdns/src/dns_conf.c

Lines 999 to 1002 in 07c1382

/* if server is defined in a group, exclude from default group */
if (group_name && group_name[0] != '\0') {
server_flag |= SERVER_FLAG_EXCLUDE_DEFAULT;
}

我觉得它的意思是,如果一个 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
Copy link
Contributor

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

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