TUN-4461: Log resulting DNS hostname if one is received from Cloudflare API

This commit is contained in:
Nuno Diegues 2021-05-27 16:25:37 +01:00
parent d6d65d183b
commit 98a0844f56
1 changed files with 11 additions and 1 deletions

View File

@ -88,6 +88,7 @@ type DNSRoute struct {
type DNSRouteResult struct {
route *DNSRoute
CName Change `json:"cname"`
Name string `json:"name"`
}
func NewDNSRoute(userHostname string, overwriteExisting bool) Route {
@ -135,7 +136,16 @@ func (res *DNSRouteResult) SuccessSummary() string {
case ChangeUnchanged:
msgFmt = "%s is already configured to route to your tunnel"
}
return fmt.Sprintf(msgFmt, res.route.userHostname)
return fmt.Sprintf(msgFmt, res.hostname())
}
// hostname yields the resulting name for the DNS route; if that is not available from Cloudflare API, then the
// requested name is returned instead (should not be the common path, it is just a fall-back).
func (res *DNSRouteResult) hostname() string {
if res.Name != "" {
return res.Name
}
return res.route.userHostname
}
type LBRoute struct {