From 8958be14e876e28cad09ea1ed988c93b9f54fe16 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 15 Nov 2014 17:55:30 +0100 Subject: 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". --- src/status.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)); } -- cgit v1.2.3