Skip to content

Commit c7c95a2

Browse files
committed
Add network memberships to pilotctl info output
Show joined networks and their addresses in both human-readable and JSON info output. Queries registry for current network list on each info call.
1 parent 14c2514 commit c7c95a2

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

cmd/pilotctl/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3627,6 +3627,15 @@ func cmdInfo() {
36273627
if email, ok := info["email"].(string); ok && email != "" {
36283628
fmt.Printf(" Email: %s\n", email)
36293629
}
3630+
if nets, ok := info["networks"].([]interface{}); ok && len(nets) > 0 {
3631+
fmt.Printf(" Networks: %d\n", len(nets))
3632+
for _, n := range nets {
3633+
nm, _ := n.(map[string]interface{})
3634+
netID := int(nm["network_id"].(float64))
3635+
addr, _ := nm["address"].(string)
3636+
fmt.Printf(" - network %d: %s\n", netID, addr)
3637+
}
3638+
}
36303639
fmt.Printf(" Traffic: %s sent / %s recv\n", formatBytes(bytesSent), formatBytes(bytesRecv))
36313640
fmt.Printf(" Packets: %d sent / %d recv\n", pktsSent, pktsRecv)
36323641

pkg/daemon/daemon.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,11 @@ func (d *Daemon) Addr() protocol.Addr {
11821182
}
11831183

11841184
// DaemonInfo holds status information about the running daemon.
1185+
type NetworkMembership struct {
1186+
NetworkID uint16 `json:"network_id"`
1187+
Address string `json:"address"`
1188+
}
1189+
11851190
type DaemonInfo struct {
11861191
NodeID uint32
11871192
Address string
@@ -1203,6 +1208,7 @@ type DaemonInfo struct {
12031208
EncryptOK uint64
12041209
EncryptFail uint64
12051210
HandshakePendingCount int
1211+
Networks []NetworkMembership
12061212
PeerList []PeerInfo
12071213
ConnList []ConnectionInfo
12081214
}
@@ -1246,6 +1252,19 @@ func (d *Daemon) Info() *DaemonInfo {
12461252
hostname := d.config.Hostname
12471253
d.addrMu.RUnlock()
12481254

1255+
// Collect network memberships from registry
1256+
var networks []NetworkMembership
1257+
for _, netID := range d.nodeNetworks() {
1258+
if netID == 0 {
1259+
continue // backbone is already shown as primary address
1260+
}
1261+
addr := protocol.Addr{Network: netID, Node: nid}
1262+
networks = append(networks, NetworkMembership{
1263+
NetworkID: netID,
1264+
Address: addr.String(),
1265+
})
1266+
}
1267+
12491268
return &DaemonInfo{
12501269
NodeID: nid,
12511270
Address: addrStr,
@@ -1267,6 +1286,7 @@ func (d *Daemon) Info() *DaemonInfo {
12671286
EncryptOK: atomic.LoadUint64(&d.tunnels.EncryptOK),
12681287
EncryptFail: atomic.LoadUint64(&d.tunnels.EncryptFail),
12691288
HandshakePendingCount: d.handshakes.PendingCount(),
1289+
Networks: networks,
12701290
PeerList: peerList,
12711291
ConnList: d.ports.ConnectionList(),
12721292
}

pkg/daemon/ipc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ func (s *IPCServer) handleInfo(conn *ipcConn) {
441441
"tunnel_encryption_success": info.EncryptOK,
442442
"tunnel_encryption_failure": info.EncryptFail,
443443
"handshake_pending_count": info.HandshakePendingCount,
444+
"networks": info.Networks,
444445
"peer_list": peers,
445446
"conn_list": conns,
446447
})

0 commit comments

Comments
 (0)