Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: support "ndots:" of 0 in resolv.conf? #15419
I saw the source code of net/dnsconfig_unix.go line 84:
And found that if the value of "ndots:" less than 1, it will be set to 1. But does this make sense? Why can't it be set to 0?
The way how pure Go DNS resolver resolves names caused an error in my program. When I set "ndots:" to 0 and resolved "mysql", I wanted to resolve "mysql." first, but instead, pure Go DNS resolver resolved "mysql.searchdomain." first. As it happened, the domain name"mysql.searchdomain." was valid in my DNS server, so I got a wrong IP of mysql.
When I set "GODEBUG=netdns=cgo" and used the cgo-based resolver, the program worked well.
Allowing ndots to go down to 0 seems okay to me. Package net should handle that correctly, and BIND libresolv allows it.
OpenBSD libc only allows ndots to go down to 1. I don't see any reason for that though, so I'm wondering if it's an off-by-1. (Instead of allowing 0--15 like BIND, OpenBSD allows 1--16.)