unetd: cli: allow skipping pretty printing of status data
Makes it more useful for services built around the CLI API Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
1735da8e4c
commit
1b7c63beaf
1 changed files with 15 additions and 10 deletions
|
@ -1296,6 +1296,8 @@ const Unet = {
|
||||||
for (let name, host in status.peers) {
|
for (let name, host in status.peers) {
|
||||||
let cur = [];
|
let cur = [];
|
||||||
|
|
||||||
|
let key = name;
|
||||||
|
if (model.cb.opt_pretty_print) {
|
||||||
data[`Host '${name}'`] = cur;
|
data[`Host '${name}'`] = cur;
|
||||||
push(cur, [ "State", host.connected ? "connected" : "disconnected" ]);
|
push(cur, [ "State", host.connected ? "connected" : "disconnected" ]);
|
||||||
if (!host.connected)
|
if (!host.connected)
|
||||||
|
@ -1308,6 +1310,9 @@ const Unet = {
|
||||||
push(cur, [ "Sent bytes", host.tx_bytes ]);
|
push(cur, [ "Sent bytes", host.tx_bytes ]);
|
||||||
push(cur, [ "Received bytes", host.rx_bytes ]);
|
push(cur, [ "Received bytes", host.rx_bytes ]);
|
||||||
push(cur, [ "Last handshake", time_format(host.last_handshake_sec) + " ago" ]);
|
push(cur, [ "Last handshake", time_format(host.last_handshake_sec) + " ago" ]);
|
||||||
|
} else {
|
||||||
|
data[name] = host;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ctx.multi_table("Status of network " + name, data);
|
return ctx.multi_table("Status of network " + name, data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue