mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-20 01:47:33 +00:00
net/dns: replace resolver IPs with type for DoH
We currently plumb full URLs for DNS resolvers from the control server down to the client. But when we pass the values into the net/dns package, we throw away any URL that isn't a bare IP. This commit continues the plumbing, and gets the URL all the way to the built in forwarder. (It stops before plumbing URLs into the OS configurations that can handle them.) For #2596 Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:

committed by
David Crawshaw

parent
7bfd4f521d
commit
9502b515f1
@@ -37,6 +37,7 @@ import (
|
||||
"tailscale.com/net/tstun"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tstime/mono"
|
||||
"tailscale.com/types/dnstype"
|
||||
"tailscale.com/types/ipproto"
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/logger"
|
||||
@@ -1503,9 +1504,16 @@ func ipInPrefixes(ip netaddr.IP, pp []netaddr.IPPrefix) bool {
|
||||
func dnsIPsOverTailscale(dnsCfg *dns.Config, routerCfg *router.Config) (ret []netaddr.IPPrefix) {
|
||||
m := map[netaddr.IP]bool{}
|
||||
|
||||
add := func(resolvers []netaddr.IPPort) {
|
||||
for _, resolver := range resolvers {
|
||||
ip := resolver.IP()
|
||||
add := func(resolvers []dnstype.Resolver) {
|
||||
for _, r := range resolvers {
|
||||
ip, err := netaddr.ParseIP(r.Addr)
|
||||
if err != nil {
|
||||
if ipp, err := netaddr.ParseIPPort(r.Addr); err == nil {
|
||||
ip = ipp.IP()
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if ipInPrefixes(ip, routerCfg.Routes) && !ipInPrefixes(ip, routerCfg.LocalRoutes) {
|
||||
m[ip] = true
|
||||
}
|
||||
|
Reference in New Issue
Block a user