diff options
| author | Felix Fietkau | 2025-02-28 15:23:07 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-02-28 15:25:15 +0000 |
| commit | edc8fdae463ad7ce9bfb876af0c653ab1da197df (patch) | |
| tree | ec934f676b9d4b32c8dc637bc1246475008f10db | |
| parent | 12e6cf7f63e1aae1bc746f929de4e4c6298d4279 (diff) | |
| download | unetd-edc8fdae463ad7ce9bfb876af0c653ab1da197df.tar.gz | |
ubus: show the local addresses in network status
Show addresses for the local host and for remote peers
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | ubus.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -64,9 +64,15 @@ __network_dump(struct blob_buf *buf, struct network *net) network_get_config(net, buf); blobmsg_close_table(buf, c); - if (local) + if (local) { blobmsg_add_string(buf, "local_host", network_host_name(local)); + str = blobmsg_alloc_string_buffer(buf, "local_address", INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, &local->peer.local_addr.in6, str, INET6_ADDRSTRLEN); + blobmsg_add_string_buffer(buf); + } + + c = blobmsg_open_table(buf, "peers"); vlist_for_each_element(&net->peers, peer, node) { union network_endpoint *ep = &peer->state.endpoint; @@ -74,6 +80,11 @@ __network_dump(struct blob_buf *buf, struct network *net) int len; p = blobmsg_open_table(buf, network_peer_name(peer)); + + str = blobmsg_alloc_string_buffer(buf, "address", INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, &peer->local_addr.in6, str, INET6_ADDRSTRLEN); + blobmsg_add_string_buffer(buf); + blobmsg_add_u8(buf, "connected", peer->state.connected); if (peer->state.connected) { str = blobmsg_alloc_string_buffer(buf, "endpoint", |