mirror of
https://github.com/tailscale/tailscale.git
synced 2025-07-30 07:43:42 +00:00
fix the out put error caused by shortend host
Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
This commit is contained in:
parent
b6b135f0c1
commit
d8eeceabf8
@ -549,7 +549,9 @@ func (e *serveEnv) messageForPort(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN
|
|||||||
var tcpHandler *ipn.TCPPortHandler
|
var tcpHandler *ipn.TCPPortHandler
|
||||||
ips := st.TailscaleIPs
|
ips := st.TailscaleIPs
|
||||||
host := dnsName
|
host := dnsName
|
||||||
|
displayedHost := dnsName
|
||||||
if forService {
|
if forService {
|
||||||
|
displayedHost = strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".")
|
||||||
host = svcName.WithoutPrefix()
|
host = svcName.WithoutPrefix()
|
||||||
}
|
}
|
||||||
hp = ipn.HostPort(net.JoinHostPort(host, strconv.Itoa(int(srvPort))))
|
hp = ipn.HostPort(net.JoinHostPort(host, strconv.Itoa(int(srvPort))))
|
||||||
@ -590,7 +592,7 @@ func (e *serveEnv) messageForPort(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN
|
|||||||
output.WriteString("\n\n")
|
output.WriteString("\n\n")
|
||||||
svc := sc.Services[svcName]
|
svc := sc.Services[svcName]
|
||||||
if srvType == serveTypeTun && svc.Tun {
|
if srvType == serveTypeTun && svc.Tun {
|
||||||
output.WriteString(fmt.Sprintf(msgRunningTunService, host))
|
output.WriteString(fmt.Sprintf(msgRunningTunService, displayedHost))
|
||||||
output.WriteString("\n")
|
output.WriteString("\n")
|
||||||
output.WriteString(fmt.Sprintf(msgDisableServiceTun, dnsName))
|
output.WriteString(fmt.Sprintf(msgDisableServiceTun, dnsName))
|
||||||
output.WriteString("\n")
|
output.WriteString("\n")
|
||||||
@ -617,14 +619,10 @@ func (e *serveEnv) messageForPort(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN
|
|||||||
sort.Slice(mounts, func(i, j int) bool {
|
sort.Slice(mounts, func(i, j int) bool {
|
||||||
return len(mounts[i]) < len(mounts[j])
|
return len(mounts[i]) < len(mounts[j])
|
||||||
})
|
})
|
||||||
hostName := host
|
|
||||||
if forService {
|
|
||||||
hostName = strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".")
|
|
||||||
}
|
|
||||||
for _, m := range mounts {
|
for _, m := range mounts {
|
||||||
h := webConfig.Handlers[m]
|
h := webConfig.Handlers[m]
|
||||||
t, d := srvTypeAndDesc(h)
|
t, d := srvTypeAndDesc(h)
|
||||||
output.WriteString(fmt.Sprintf("%s://%s%s%s\n", scheme, hostName, portPart, m))
|
output.WriteString(fmt.Sprintf("%s://%s%s%s\n", scheme, displayedHost, portPart, m))
|
||||||
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 {
|
||||||
@ -635,7 +633,7 @@ func (e *serveEnv) messageForPort(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN
|
|||||||
tlsStatus = "TLS terminated"
|
tlsStatus = "TLS terminated"
|
||||||
}
|
}
|
||||||
|
|
||||||
output.WriteString(fmt.Sprintf("|-- tcp://%s (%s)\n", hp, tlsStatus))
|
output.WriteString(fmt.Sprintf("|-- tcp://%s:%d (%s)\n", displayedHost, srvPort, tlsStatus))
|
||||||
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))
|
||||||
|
@ -1321,7 +1321,7 @@ func TestMessageForPort(t *testing.T) {
|
|||||||
80: {HTTP: true},
|
80: {HTTP: true},
|
||||||
},
|
},
|
||||||
Web: map[ipn.HostPort]*ipn.WebServerConfig{
|
Web: map[ipn.HostPort]*ipn.WebServerConfig{
|
||||||
"foo.test.ts.net:80": {
|
"foo:80": {
|
||||||
Handlers: map[string]*ipn.HTTPHandler{
|
Handlers: map[string]*ipn.HTTPHandler{
|
||||||
"/": {Proxy: "http://localhost:3000"},
|
"/": {Proxy: "http://localhost:3000"},
|
||||||
},
|
},
|
||||||
@ -1365,7 +1365,7 @@ func TestMessageForPort(t *testing.T) {
|
|||||||
80: {HTTP: true},
|
80: {HTTP: true},
|
||||||
},
|
},
|
||||||
Web: map[ipn.HostPort]*ipn.WebServerConfig{
|
Web: map[ipn.HostPort]*ipn.WebServerConfig{
|
||||||
"bar.test.ts.net:80": {
|
"bar:80": {
|
||||||
Handlers: map[string]*ipn.HTTPHandler{
|
Handlers: map[string]*ipn.HTTPHandler{
|
||||||
"/": {Proxy: "http://localhost:3000"},
|
"/": {Proxy: "http://localhost:3000"},
|
||||||
},
|
},
|
||||||
@ -1409,7 +1409,7 @@ func TestMessageForPort(t *testing.T) {
|
|||||||
2200: {HTTPS: true},
|
2200: {HTTPS: true},
|
||||||
},
|
},
|
||||||
Web: map[ipn.HostPort]*ipn.WebServerConfig{
|
Web: map[ipn.HostPort]*ipn.WebServerConfig{
|
||||||
"foo.test.ts.net:2200": {
|
"foo:2200": {
|
||||||
Handlers: map[string]*ipn.HTTPHandler{
|
Handlers: map[string]*ipn.HTTPHandler{
|
||||||
"/": {Proxy: "http://localhost:3000"},
|
"/": {Proxy: "http://localhost:3000"},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user