mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
net/dns/resolver: teach the forwarder to do per-domain routing.
Given a DNS route map, the forwarder selects the right set of upstreams for a given name. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
@@ -124,3 +124,12 @@ func SanitizeHostname(hostname string) string {
|
||||
hostname = TrimCommonSuffixes(hostname)
|
||||
return SanitizeLabel(hostname)
|
||||
}
|
||||
|
||||
// NumLabels returns the number of DNS labels in hostname.
|
||||
// If hostname is empty or the top-level name ".", returns 0.
|
||||
func NumLabels(hostname string) int {
|
||||
if hostname == "" || hostname == "." {
|
||||
return 0
|
||||
}
|
||||
return strings.Count(hostname, ".")
|
||||
}
|
||||
|
Reference in New Issue
Block a user