@@ -48,21 +48,40 @@ 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 () + ")"
63
- if port . Exposed . Visibility == supervisor . PortVisibility_public {
70
+ } else {
71
+ if port . Tunneled != nil && port .Tunneled .Visibility == supervisor . TunnelVisiblity ( supervisor . TunnelVisiblity_value [ "network" ]) {
72
+ status = "open on all interfaces"
64
73
statusColor = tablewriter .FgHiGreenColor
65
- } else {
74
+ }
75
+ if port .Tunneled != nil && port .Tunneled .Visibility == supervisor .TunnelVisiblity (supervisor .TunnelVisiblity_value ["host" ]) {
76
+ status = "open on localhost"
77
+ statusColor = tablewriter .FgHiGreenColor
78
+ }
79
+ if port .Exposed != nil && port .Exposed .Visibility == supervisor .PortVisibility_public {
80
+ status = "open (public)"
81
+ statusColor = tablewriter .FgHiGreenColor
82
+ }
83
+ if port .Exposed != nil && port .Exposed .Visibility == supervisor .PortVisibility_private {
84
+ status = "open (private)"
66
85
statusColor = tablewriter .FgHiCyanColor
67
86
}
68
87
}
@@ -82,7 +101,7 @@ var listPortsCmd = &cobra.Command{
82
101
}
83
102
84
103
table .Rich (
85
- []string {fmt .Sprint (port .LocalPort ), status , port . Exposed . Url , nameAndDescription },
104
+ []string {fmt .Sprint (port .LocalPort ), status , exposedUrl , nameAndDescription },
86
105
colors ,
87
106
)
88
107
}
0 commit comments