diff options
| author | Felix Fietkau | 2025-04-30 09:03:39 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-04-30 09:04:14 +0000 |
| commit | 1b7c63beaff7efdc123dd27765d171a5bf282bc2 (patch) | |
| tree | 3025e8809f605427c4b57fe305420b0aadf06b99 | |
| parent | 1735da8e4c941501a85a5997125c85fccdcb4831 (diff) | |
| download | openwrt-1b7c63beaff7efdc123dd27765d171a5bf282bc2.tar.gz | |
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>
| -rw-r--r-- | package/network/services/unetd/files/unet.uc | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/package/network/services/unetd/files/unet.uc b/package/network/services/unetd/files/unet.uc index 1b7d021829..01ff05c3b1 100644 --- a/package/network/services/unetd/files/unet.uc +++ b/package/network/services/unetd/files/unet.uc @@ -1296,18 +1296,23 @@ const Unet = { for (let name, host in status.peers) { let cur = []; - data[`Host '${name}'`] = cur; - push(cur, [ "State", host.connected ? "connected" : "disconnected" ]); - if (!host.connected) - continue; - - if (host.endpoint) - push(cur, [ "IP address", host.endpoint ]); - - push(cur, [ "Idle time", time_format(host.idle) ]); - push(cur, [ "Sent bytes", host.tx_bytes ]); - push(cur, [ "Received bytes", host.rx_bytes ]); - push(cur, [ "Last handshake", time_format(host.last_handshake_sec) + " ago" ]); + let key = name; + if (model.cb.opt_pretty_print) { + data[`Host '${name}'`] = cur; + push(cur, [ "State", host.connected ? "connected" : "disconnected" ]); + if (!host.connected) + continue; + + if (host.endpoint) + push(cur, [ "IP address", host.endpoint ]); + + push(cur, [ "Idle time", time_format(host.idle) ]); + push(cur, [ "Sent bytes", host.tx_bytes ]); + push(cur, [ "Received bytes", host.rx_bytes ]); + push(cur, [ "Last handshake", time_format(host.last_handshake_sec) + " ago" ]); + } else { + data[name] = host; + } } return ctx.multi_table("Status of network " + name, data); } |