@@ -43,23 +43,43 @@ var listPortsCmd = &cobra.Command{
43
43
table .SetCenterSeparator ("|" )
44
44
45
45
for _ , port := range ports {
46
- status := "not served "
46
+ status := ""
47
47
statusColor := tablewriter .FgHiBlackColor
48
- if port .Exposed == nil && port .Tunneled == nil {
48
+ accessible := port .Exposed != nil || port .Tunneled != nil
49
+
50
+ exposedUrl := ""
51
+ if port .Exposed != nil {
52
+ exposedUrl = port .Exposed .Url
53
+ }
54
+
55
+ if ! port .Served {
56
+ status = "not served"
57
+ } else if ! accessible {
49
58
if port .AutoExposure == supervisor .PortAutoExposure_failed {
50
59
status = "failed to expose"
51
60
statusColor = tablewriter .FgRedColor
52
61
} else {
53
62
status = "detecting..."
54
63
statusColor = tablewriter .FgYellowColor
55
64
}
56
- } else if port .Served {
57
- status = "open (" + port .Exposed .Visibility .String () + ")"
65
+ } else if port .Exposed != nil {
58
66
if port .Exposed .Visibility == supervisor .PortVisibility_public {
67
+ status = "open (public)"
59
68
statusColor = tablewriter .FgHiGreenColor
60
- } else {
69
+ }
70
+ if port .Exposed .Visibility == supervisor .PortVisibility_private {
71
+ status = "open (private)"
61
72
statusColor = tablewriter .FgHiCyanColor
62
73
}
74
+ } else if port .Tunneled != nil {
75
+ if port .Tunneled .Visibility == supervisor .TunnelVisiblity (supervisor .TunnelVisiblity_value ["network" ]) {
76
+ status = "open on all interfaces"
77
+ statusColor = tablewriter .FgHiGreenColor
78
+ }
79
+ if port .Tunneled .Visibility == supervisor .TunnelVisiblity (supervisor .TunnelVisiblity_value ["host" ]) {
80
+ status = "open on localhost"
81
+ statusColor = tablewriter .FgHiGreenColor
82
+ }
63
83
}
64
84
65
85
nameAndDescription := port .Name
@@ -77,7 +97,7 @@ var listPortsCmd = &cobra.Command{
77
97
}
78
98
79
99
table .Rich (
80
- []string {fmt .Sprint (port .LocalPort ), status , port . Exposed . Url , nameAndDescription },
100
+ []string {fmt .Sprint (port .LocalPort ), status , exposedUrl , nameAndDescription },
81
101
colors ,
82
102
)
83
103
}
0 commit comments