cmd/tailscale/cli: fix plain TCP serve status
Do not label plain TCP forwarding as TLS over TCP. Render status annotations only when TLS termination or PROXY protocol is configured. Fixes #20367 Change-Id: I3f6507365ceedc2950451810e9715afb85176fc5 Signed-off-by: coyaSONG <66289470+coyaSONG@users.noreply.github.com>
This commit is contained in:
@@ -1101,16 +1101,19 @@ func (e *serveEnv) messageForPort(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN
|
|||||||
output.WriteString(fmt.Sprintf("%s %-5s %s\n\n", "|--", t, d))
|
output.WriteString(fmt.Sprintf("%s %-5s %s\n\n", "|--", t, d))
|
||||||
}
|
}
|
||||||
} else if tcpHandler != nil {
|
} else if tcpHandler != nil {
|
||||||
|
var annotations []string
|
||||||
tlsStatus := "TLS over TCP"
|
|
||||||
if tcpHandler.TerminateTLS != "" {
|
if tcpHandler.TerminateTLS != "" {
|
||||||
tlsStatus = "TLS terminated"
|
annotations = append(annotations, "TLS terminated")
|
||||||
}
|
}
|
||||||
if ver := tcpHandler.ProxyProtocol; ver != 0 {
|
if ver := tcpHandler.ProxyProtocol; ver != 0 {
|
||||||
tlsStatus = fmt.Sprintf("%s, PROXY protocol v%d", tlsStatus, ver)
|
annotations = append(annotations, fmt.Sprintf("PROXY protocol v%d", ver))
|
||||||
}
|
}
|
||||||
|
|
||||||
output.WriteString(fmt.Sprintf("|-- tcp://%s:%d (%s)\n", host, srvPort, tlsStatus))
|
output.WriteString(fmt.Sprintf("|-- tcp://%s:%d", host, srvPort))
|
||||||
|
if len(annotations) != 0 {
|
||||||
|
output.WriteString(fmt.Sprintf(" (%s)", strings.Join(annotations, ", ")))
|
||||||
|
}
|
||||||
|
output.WriteString("\n")
|
||||||
for _, a := range ips {
|
for _, a := range ips {
|
||||||
ipp := net.JoinHostPort(a.String(), strconv.Itoa(int(srvPort)))
|
ipp := net.JoinHostPort(a.String(), strconv.Itoa(int(srvPort)))
|
||||||
output.WriteString(fmt.Sprintf("|-- tcp://%s\n", ipp))
|
output.WriteString(fmt.Sprintf("|-- tcp://%s\n", ipp))
|
||||||
|
|||||||
@@ -1603,7 +1603,7 @@ func TestMessageForPort(t *testing.T) {
|
|||||||
expected: strings.Join([]string{
|
expected: strings.Join([]string{
|
||||||
msgServeAvailable,
|
msgServeAvailable,
|
||||||
"",
|
"",
|
||||||
"|-- tcp://foo.test.ts.net:2200 (TLS over TCP)",
|
"|-- tcp://foo.test.ts.net:2200",
|
||||||
"|-- tcp://100.101.101.101:2200",
|
"|-- tcp://100.101.101.101:2200",
|
||||||
"|-- tcp://[fd7a:115c:a1e0:ab12:4843:cd96:6565:6565]:2200",
|
"|-- tcp://[fd7a:115c:a1e0:ab12:4843:cd96:6565:6565]:2200",
|
||||||
"|--> tcp://localhost:3000",
|
"|--> tcp://localhost:3000",
|
||||||
|
|||||||
Reference in New Issue
Block a user