I was wandering if it’s possible for a peer to programmatically discover its peers. in libzt it seems that support for this basic task is missing. In libzerotiercore there is a specific function instead, ZT_PeerList *ZT_Node_peers(ZT_Node *node);
I really would like to use libzt instead of libzerotiercore since the latter is not documented at all (besides its include file there are no examples of usage). In my scenario, several peers start concurrently, and I need each of them to be able to find their peers and to send/receive messages to/from them. Note that for the exchange of messages, I do not want to setup the peers as a client and a server.
Right now, it seems to me that the only way to discover peers in libzt is through the setup of an event handler through which I should be able to recover “paths” to the other peers. But the corresponding code, that can be downloaded from my website, does not work as expected. Even if I launch only two peers, they do not discover the other peer. Even worse, after un undefined amount of time (but short), they go in segmentation fault. This should not happen: after setting up the peer, it just waits indefinitely in a loop, waiting for events to be delivered and processed by the event handler.
Is the bug due to an incorrect usage of libzt or it is instead a true bug of the SDK?
The experiments have been done on MacOS 12.5.1 using libzt v1.10.1 installed through brew. The code has been compiled with Apple clang version 13.1.6 (clang-13220.127.116.11.5). The network that I have created is private, and I authorize immediately each peer as soon as I see it appearing on my.zerotier.com network administration panel.
My source code is available here for download: https://www.massimocafaro.it/peer-src.zip
Thank you in advance.
With kind regards,