@@ -454,22 +454,38 @@ func formatAndPrintConnectionsList(tunnelInfo Info, showRecentlyDisconnected boo
454454 writer := tabWriter ()
455455 defer writer .Flush ()
456456
457+ // Print the general tunnel info table
457458 _ , _ = fmt .Fprintf (writer , "NAME: %s\n ID: %s\n CREATED: %s\n \n " , tunnelInfo .Name , tunnelInfo .ID , tunnelInfo .CreatedAt )
458459
460+ // Determine whether to print the connector table
461+ shouldDisplayTable := false
462+ for _ , c := range tunnelInfo .Connectors {
463+ conns := fmtConnections (c .Connections , showRecentlyDisconnected )
464+ if len (conns ) > 0 {
465+ shouldDisplayTable = true
466+ }
467+ }
468+ if ! shouldDisplayTable {
469+ fmt .Println ("This tunnel has no active connectors." )
470+ return
471+ }
472+
473+ // Print the connector table
459474 _ , _ = fmt .Fprintln (writer , "CONNECTOR ID\t CREATED\t ARCHITECTURE\t VERSION\t ORIGIN IP\t EDGE\t " )
460475 for _ , c := range tunnelInfo .Connectors {
461- var originIp = ""
462- if len (c . Connections ) > 0 {
463- originIp = c . Connections [ 0 ]. OriginIP . String ()
476+ conns := fmtConnections ( c . Connections , showRecentlyDisconnected )
477+ if len (conns ) == 0 {
478+ continue
464479 }
480+ originIp := c .Connections [0 ].OriginIP .String ()
465481 formattedStr := fmt .Sprintf (
466482 "%s\t %s\t %s\t %s\t %s\t %s\t " ,
467483 c .ID ,
468484 c .RunAt .Format (time .RFC3339 ),
469485 c .Arch ,
470486 c .Version ,
471487 originIp ,
472- fmtConnections ( c . Connections , showRecentlyDisconnected ) ,
488+ conns ,
473489 )
474490 _ , _ = fmt .Fprintln (writer , formattedStr )
475491 }
0 commit comments