Christmas update: GNUnet++
Two weeks ago I announced GNUnet++, my C++ wrapper for common GNUnet functions. It's christmas time and I'm happy to share that I've made progress.
Coroutine support
The last version of GNUnet++ purely runs on callbacks. Which makes advanced usage cumbersome. Now there's full support for coroutines. This means that you can write code like this:
auto gns = std::make_shared<gnunetpp::GNS>(cfg);
auto result = co_await gns->lookup("gnunet.org");
And this which would be a nightmare in previous callback APIs. (Well, we can just use an anonymous identity, but you get the point)
auto identity = std::make_shared<gnunetpp::IdentityService>(cfg);
auto throwaway = co_await identity->createIdentity("test");
// ... do something with the identity ...
co_await identity->deleteIdentity("test");
CADET support
Yes! I got CADET working!! P2P messaging have not been easier. Took me much effort to bend the system enbough. You can now write code like this:
(client side)
auto cadet = std::make_shared<CADET>(cfg);
// Connect to a peer and specify the message type we are willing to receive
auto channel = co_await cadet->connect("peerid", "port-name", {GNUNET_MESSAGE_TYPE_CADET_CLI});
channel->onReceive([](const std::string_view data, uint16_t type) {
// Do something with the data
});
channel->send("Hello world!", GNUNET_MESSAGE_TYPE_CADET_CLI);
The design is heavily inspired by Trantor, a C++14 network library I help maintain. And a massive does of personal preference is added to the mix. For example, server side handlers set to the cadet
object is treaded as the default handler. If you want to override it, you can do so by a per-channel basis. This does not apply to client side handlers.
// set a different handler because.. reasons
cadet->setConnectedCallback([](const CADETChannelPtr& channel) {
// every once in a while, we'll dump the data to stderr
if(rand() % 10 == 0) {
channel->setReceiveCallback([](const std::string_view data, uint16_t type) {
std::cerr << "I'm a bad person" << std::endl;
});
}
});
// This is the default message handler
cadet->setReceiveCallback([](CADETChannel* channel, const std::string_view data, uint16_t type) {
std::cout << data << std::flush;
});
Misc
- Adds support for NSE (Network Size Estimator)
- Improved error handling for all subsystems
- Discovered a few bugs in GNUnet itself
- Ego is handled as an object now for API consistency
Next steps
A few things I want to do next:
- Namestore support (allow administration of GNS records)
- Peerstore
- Peerinfo
Right, I've been goofing on the FS tool a little. You won't believe what I found on there. Literal hentai and dick pics. Classic

Martin Chang
Systems software, HPC, GPGPU and AI. I mostly write stupid C++ code. Sometimes does AI research. Chronic VRChat addict
I run TLGS, a major search engine on Gemini. Used by Buran by default.
- marty1885 \at protonmail.com
- Matrix: @clehaxze:matrix.clehaxze.tw
- Jami: a72b62ac04a958ca57739247aa1ed4fe0d11d2df