summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-11-15 17:55:30 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-11-15 17:55:30 +0100
commit8958be14e876e28cad09ea1ed988c93b9f54fe16 (patch)
treea45b2c21df4507ee7f8fba62d312232cb8c56707
parent5f6a7d692e3faa440d94a5fc80ab3ba8bd09003d (diff)
downloadfastd-8958be14e876e28cad09ea1ed988c93b9f54fe16.tar
fastd-8958be14e876e28cad09ea1ed988c93b9f54fe16.zip
Use the peer key instead of the name as keys in the status socket output
This fixes the status socket segfault in a nicer way than the reverted commit "Use peer specifier from log instead of the peer name for the status output".
-rw-r--r--src/status.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/status.c b/src/status.c
index 8e0c427..b9f5f34 100644
--- a/src/status.c
+++ b/src/status.c
@@ -108,6 +108,7 @@ static json_object * dump_peer(const fastd_peer_t *peer) {
char addr_buf[1 + INET6_ADDRSTRLEN + 2 + IFNAMSIZ + 1 + 5 + 1];
fastd_snprint_peer_address(addr_buf, sizeof(addr_buf), &peer->address, NULL, false, false);
+ json_object_object_add(ret, "name", peer->name ? json_object_new_string(peer->name) : NULL);
json_object_object_add(ret, "address", json_object_new_string(addr_buf));
struct json_object *connection = NULL;
@@ -174,7 +175,9 @@ static void dump_status(int fd) {
if (!fastd_peer_is_enabled(peer))
continue;
- json_object_object_add(peers, peer->name, dump_peer(peer));
+ char buf[65];
+ if (conf.protocol->describe_peer(peer, buf, sizeof(buf)))
+ json_object_object_add(peers, buf, dump_peer(peer));
}