tailcfg,ipn,appc: add c2n endpoint for appc domain routes

This change introduces a c2n endpoint that returns a map of domains to a
slice of resolved IP addresses for the domain.

Fixes tailscale/corp#15657

Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@tailscale.com>
This commit is contained in:
Charlotte Brandhorst-Satzkorn
2023-11-07 13:34:52 -08:00
committed by Charlotte Brandhorst-Satzkorn
parent 63062abadc
commit f937cb6794
3 changed files with 54 additions and 0 deletions

View File

@ -81,6 +81,20 @@ func (e *AppConnector) Domains() views.Slice[string] {
return views.SliceOf(xmaps.Keys(e.domains))
}
// DomainRoutes returns a map of domains to resolved IP
// addresses.
func (e *AppConnector) DomainRoutes() map[string][]netip.Addr {
e.mu.Lock()
defer e.mu.Unlock()
drCopy := make(map[string][]netip.Addr)
for k, v := range e.domains {
copy(drCopy[k], v)
}
return drCopy
}
// ObserveDNSResponse is a callback invoked by the DNS resolver when a DNS
// response is being returned over the PeerAPI. The response is parsed and
// matched against the configured domains, if matched the routeAdvertiser is