5353 Aliases : []string {"i" },
5454 Usage : "List tunnel by ID" ,
5555 }
56+ showRecentlyDisconnected = & cli.BoolFlag {
57+ Name : "show-recently-disconnected" ,
58+ Aliases : []string {"rd" },
59+ Usage : "Include connections that have recently disconnected in the list" ,
60+ }
5661 outputFormatFlag = & cli.StringFlag {
5762 Name : "output" ,
5863 Aliases : []string {"o" },
@@ -234,7 +239,7 @@ func buildListCommand() *cli.Command {
234239 Usage : "List existing tunnels" ,
235240 ArgsUsage : " " ,
236241 Hidden : hideSubcommands ,
237- Flags : []cli.Flag {outputFormatFlag , showDeletedFlag , listNameFlag , listExistedAtFlag , listIDFlag },
242+ Flags : []cli.Flag {outputFormatFlag , showDeletedFlag , listNameFlag , listExistedAtFlag , listIDFlag , showRecentlyDisconnected },
238243 }
239244}
240245
@@ -281,15 +286,15 @@ func listTunnels(c *cli.Context) error {
281286 }
282287
283288 if len (tunnels ) > 0 {
284- fmtAndPrintTunnelList (tunnels )
289+ fmtAndPrintTunnelList (tunnels , c . Bool ( "show-recently-disconnected" ) )
285290 } else {
286291 fmt .Println ("You have no tunnels, use 'cloudflared tunnel create' to define a new tunnel" )
287292 }
288293
289294 return nil
290295}
291296
292- func fmtAndPrintTunnelList (tunnels []tunnelstore.Tunnel ) {
297+ func fmtAndPrintTunnelList (tunnels []tunnelstore.Tunnel , showRecentlyDisconnected bool ) {
293298 const (
294299 minWidth = 0
295300 tabWidth = 8
@@ -305,20 +310,28 @@ func fmtAndPrintTunnelList(tunnels []tunnelstore.Tunnel) {
305310
306311 // Loop through tunnels, create formatted string for each, and print using tabwriter
307312 for _ , t := range tunnels {
308- formattedStr := fmt .Sprintf ("%s\t %s\t %s\t %s\t " , t .ID , t .Name , t .CreatedAt .Format (time .RFC3339 ), fmtConnections (t .Connections ))
313+ formattedStr := fmt .Sprintf (
314+ "%s\t %s\t %s\t %s\t " ,
315+ t .ID ,
316+ t .Name ,
317+ t .CreatedAt .Format (time .RFC3339 ),
318+ fmtConnections (t .Connections , showRecentlyDisconnected ),
319+ )
309320 fmt .Fprintln (writer , formattedStr )
310321 }
311322
312323 // Write data buffered in tabwriter to output
313324 writer .Flush ()
314325}
315326
316- func fmtConnections (connections []tunnelstore.Connection ) string {
327+ func fmtConnections (connections []tunnelstore.Connection , showRecentlyDisconnected bool ) string {
317328
318329 // Count connections per colo
319330 numConnsPerColo := make (map [string ]uint , len (connections ))
320331 for _ , connection := range connections {
321- numConnsPerColo [connection .ColoName ]++
332+ if ! connection .IsPendingReconnect || showRecentlyDisconnected {
333+ numConnsPerColo [connection .ColoName ]++
334+ }
322335 }
323336
324337 // Get sorted list of colos
0 commit comments