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