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

Support TCP DNS in dnsmasq #418

Merged
merged 1 commit into from
Sep 12, 2020
Merged

Support TCP DNS in dnsmasq #418

merged 1 commit into from
Sep 12, 2020

Conversation

Yonsm
Copy link
Contributor

@Yonsm Yonsm commented Jun 25, 2020

dnsmasq 支持 TCP DNS:可替代 dns2tcp 功能,要启用此功能可设置如下 server=/google.com/8.8.8.8~53,即原 UDP 的 # 改成 ~

保守稳定起见,我没有更新 dnsmasq 到最新版,在 2.78 的基础上尽量小的改动方案来实现 TCP DNS 功能,对 dnsmasq 的原主链路的入侵影响控制到最小:

  1. 主流程:只切入到 forward udp的一个函数中,向上游 UDP Server 发送请求的时候,不发了,改为我们自己的 TCP DNS 的实现。

TCP DNS 请求成功后,直接向本机发送 UDP 结果,原主链路收到 UDP 结果后的检查 server 的部分需接受本机发送的结果,也有一点小更改。

  1. 配置解析:解析到 TCP DNS 后记录下来。
  2. 日志打印时的相关 #/~ 字符呈现。

本来还实现了 TCP connection 复用,但竟然有问题没有调试成功,暂时先不上了。不复用 TCP 连接的情况下,初次查询耗时为 160 毫秒左右,比 dns2tcp 略好5~10毫秒,就算差不多吧,胜在少了一个进程,少了黄多代码,简单。

@Yonsm Yonsm changed the title Support TCP DNS, e.g. server=/google.com/8.8.8.8~53 Support TCP DNS in dnsmasq Jun 25, 2020
@hanwckf hanwckf merged commit 3fce840 into hanwckf:master Sep 12, 2020
@Yonsm Yonsm deleted the tcpdns branch October 19, 2020 03:59
Yh793 added a commit to Yh793/rt-n56u that referenced this pull request Jan 1, 2023
- Support TCP DNS, e.g. server=/google.com/8.8.8.8~53 (hanwckf#418)
- Support load gfwlist.txt (equals to add with --server and --ipset one by one) (hanwckf#419)
- Fix TCP DNS crash in dnsmasq 2.8 (hanwckf#754)
Yh793 added a commit to Yh793/rt-n56u that referenced this pull request Jan 1, 2023
- Support TCP DNS, e.g. server=/google.com/8.8.8.8~53 (hanwckf#418)
- Support load gfwlist.txt (equals to add with --server and --ipset one by one) (hanwckf#419)
- Fix TCP DNS crash in dnsmasq 2.8 (hanwckf#754)
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

Successfully merging this pull request may close these issues.

2 participants