如果可用,如何使 go dns 查找强制使用 nscd?
有什么方法可以强制 go 二进制文件执行 dns 查找并从同一主机上的 nscd 缓存获取响应(如果可用)? 我认为如果我使用自定义解析器,它可以被强制,但我想避免这种情况。想知道 netdns=cgo 是否有帮助?
Is there any way i can force a go binary to perform dns lookup's and get response from the nscd cache on the same host if it is available?
I assume it can be forced if i use a custom resolver, but i'd like to avoid that. Wondering if netdns=cgo would help here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,但这取决于您的环境。
您可以通过在终端中输入来使用
cgo
解析器然后您的 go 应用程序将使用 cgo 解析器。
如果您的操作系统是 UNIX,cgo 解析器在解析域名时会使用
getaddrinfo
。如果
nscd
服务正在运行,getaddrinfo
将使用nscd
。参考号
[1] https://pkg.go.dev/net#hdr-Name_Resolution
[2] golang 是否缓存 DNS?
[3] https://revs.runtime-revolution.com/golang-dns-resolving-a56ed59981fe< /a>
Yes but it depends on your environment.
You can use
cgo
resolver by typing to terminalThen your go application will use cgo resolver.
cgo resolver use
getaddrinfo
when resolving domain names if your OS is UNIX.And
getaddrinfo
will usenscd
ifnscd
service is running.ref.
[1] https://pkg.go.dev/net#hdr-Name_Resolution
[2] Is golang caching DNS?
[3] https://revs.runtime-revolution.com/golang-dns-resolving-a56ed59981fe