From 98a0844f561932a75431becda63a865862e747c6 Mon Sep 17 00:00:00 2001 From: Nuno Diegues Date: Thu, 27 May 2021 16:25:37 +0100 Subject: [PATCH] TUN-4461: Log resulting DNS hostname if one is received from Cloudflare API --- tunnelstore/client.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tunnelstore/client.go b/tunnelstore/client.go index c5230cc8..764cfd3b 100644 --- a/tunnelstore/client.go +++ b/tunnelstore/client.go @@ -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 {