mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-24 02:31:48 +01:00
This adds a new node capability 'dns-subdomain-resolve' that signals that all of hosts' subdomains should resolve to the same IP address. It allows wildcard matching on any node marked with this capability. This change also includes an util/dnsname utility function that lets us access the parent of a full qualified domain name. MagicDNS takes this function and recursively searchs for a matching real node name. One important thing to observe is that, in this context, a subdomain can have multiple sub labels. This means that for a given node named machine, both my.machine and be.my.machine will be a positive match. Updates #1196 Signed-off-by: Fernando Serboncini <fserb@tailscale.com>
78 lines
2.0 KiB
Go
78 lines
2.0 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Code generated by tailscale.com/cmd/cloner; DO NOT EDIT.
|
|
|
|
package dns
|
|
|
|
import (
|
|
"maps"
|
|
"net/netip"
|
|
|
|
"tailscale.com/types/dnstype"
|
|
"tailscale.com/util/dnsname"
|
|
)
|
|
|
|
// Clone makes a deep copy of Config.
|
|
// The result aliases no memory with the original.
|
|
func (src *Config) Clone() *Config {
|
|
if src == nil {
|
|
return nil
|
|
}
|
|
dst := new(Config)
|
|
*dst = *src
|
|
if src.DefaultResolvers != nil {
|
|
dst.DefaultResolvers = make([]*dnstype.Resolver, len(src.DefaultResolvers))
|
|
for i := range dst.DefaultResolvers {
|
|
if src.DefaultResolvers[i] == nil {
|
|
dst.DefaultResolvers[i] = nil
|
|
} else {
|
|
dst.DefaultResolvers[i] = src.DefaultResolvers[i].Clone()
|
|
}
|
|
}
|
|
}
|
|
if dst.Routes != nil {
|
|
dst.Routes = map[dnsname.FQDN][]*dnstype.Resolver{}
|
|
for k := range src.Routes {
|
|
dst.Routes[k] = append([]*dnstype.Resolver{}, src.Routes[k]...)
|
|
}
|
|
}
|
|
dst.SearchDomains = append(src.SearchDomains[:0:0], src.SearchDomains...)
|
|
if dst.Hosts != nil {
|
|
dst.Hosts = map[dnsname.FQDN][]netip.Addr{}
|
|
for k := range src.Hosts {
|
|
dst.Hosts[k] = append([]netip.Addr{}, src.Hosts[k]...)
|
|
}
|
|
}
|
|
dst.SubdomainHosts = maps.Clone(src.SubdomainHosts)
|
|
return dst
|
|
}
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
|
var _ConfigCloneNeedsRegeneration = Config(struct {
|
|
DefaultResolvers []*dnstype.Resolver
|
|
Routes map[dnsname.FQDN][]*dnstype.Resolver
|
|
SearchDomains []dnsname.FQDN
|
|
Hosts map[dnsname.FQDN][]netip.Addr
|
|
SubdomainHosts map[dnsname.FQDN]bool
|
|
OnlyIPv6 bool
|
|
}{})
|
|
|
|
// Clone duplicates src into dst and reports whether it succeeded.
|
|
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
|
|
// where T is one of Config.
|
|
func Clone(dst, src any) bool {
|
|
switch src := src.(type) {
|
|
case *Config:
|
|
switch dst := dst.(type) {
|
|
case *Config:
|
|
*dst = *src.Clone()
|
|
return true
|
|
case **Config:
|
|
*dst = src.Clone()
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|