serve: fix hostname for custom http ports

When using a custom http port like 8080, this was resulting in a
constructed hostname of `host.tailnet.ts.net:8080.tailnet.ts.net` when
looking up the serve handler. Instead, strip off the port before adding
the MagicDNS suffix.

Also use the actual hostname in `serve status` rather than the literal
string "host".

Fixes #8635

Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
Will Norris
2023-07-17 16:50:58 -07:00
committed by Will Norris
parent c19b5bfbc3
commit f8b0caa8c2
2 changed files with 4 additions and 1 deletions

View File

@@ -699,7 +699,7 @@ func (e *serveEnv) printWebStatusTree(sc *ipn.ServeConfig, hp ipn.HostPort) erro
portPart = ""
}
if scheme == "http" {
hostname, _, _ := strings.Cut("host", ".")
hostname, _, _ := strings.Cut(host, ".")
printf("%s://%s%s (%s)\n", scheme, hostname, portPart, fStatus)
}
printf("%s://%s%s (%s)\n", scheme, host, portPart, fStatus)