From dbbe5f5a2a4320c9a129ba8347342f97c2e7c46d Mon Sep 17 00:00:00 2001 From: CPunch Date: Wed, 3 Aug 2022 20:50:55 -0500 Subject: [PATCH] CNC: laikaC_sendPeerList() now uses laikaC_iterPeersNext() --- cnc/src/cpanel.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/cnc/src/cpanel.c b/cnc/src/cpanel.c index d2b92d8..6ade0d9 100644 --- a/cnc/src/cpanel.c +++ b/cnc/src/cpanel.c @@ -5,22 +5,18 @@ #include "lerror.h" #include "lmem.h" -bool sendPanelPeerIter(struct sLaika_peer *peer, void *uData) -{ - struct sLaika_peer *authPeer = (struct sLaika_peer *)uData; - - /* make sure we're not sending connection information to themselves */ - if (peer != authPeer) { - LAIKA_DEBUG("sending peer info %p to auth %p)\n", peer, authPeer); - laikaC_sendNewPeer(authPeer, peer); - } - - return true; -} - void laikaC_sendPeerList(struct sLaika_cnc *cnc, struct sLaika_peer *authPeer) { - laikaC_iterPeers(cnc, sendPanelPeerIter, (void *)authPeer); + struct sLaika_peer *peer; + size_t i = 0; + + /* send authPeer details on each peer that *isn't* itself */ + while (laikaC_iterPeersNext(cnc, &i, &peer)) { + if (peer != authPeer) { + LAIKA_DEBUG("sending peer info %p to auth %p)\n", peer, authPeer); + laikaC_sendNewPeer(authPeer, peer); + } + } } void laikaC_sendNewPeer(struct sLaika_peer *authPeer, struct sLaika_peer *peer)