ubus: show the local addresses in network status master
authorFelix Fietkau <nbd@nbd.name>
Fri, 28 Feb 2025 15:23:07 +0000 (16:23 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 28 Feb 2025 15:25:15 +0000 (16:25 +0100)
Show addresses for the local host and for remote peers

Signed-off-by: Felix Fietkau <nbd@nbd.name>
ubus.c

diff --git a/ubus.c b/ubus.c
index ba6b3de974afbd7bc382fb2358ad3c996ff08197..915529aec12b3380ce94176a74497a60d3ffef47 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -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",