Tor++ is a C++20 library for controlling Tor with a bine-style workflow:
- start and stop a Tor process
- authenticate on the control port
- send raw Tor control commands
- manage config and info queries
- create and delete ephemeral onion services
- persist and restore hidden-service identities
- open outbound connections through Tor's SOCKS5 listener
This first cut targets Linux/POSIX systems and keeps the public API close to the practical features bine exposes while still providing a raw control-command escape hatch for the rest of Tor's controller surface.
torpp::Tor::start(...)launches Tor, discovers the control port, and authenticatestorpp::ControlClientexposesPROTOCOLINFO,GETINFO,GETCONF,SETCONF,SAVECONF,SIGNAL,ADD_ONION,DEL_ONION,SETEVENTS, and generic raw commandstorpp::OnionServicewraps ephemeral v3 onion servicestorpp::HiddenServiceIdentitysaves and reloads the private key blob Tor returns fromADD_ONIONtorpp::Dialeropens outbound sockets through Tor's SOCKS5 proxy
cmake -S . -B build
cmake --build build
ctest --test-dir buildTor++ uses OpenSSL's crypto library for SAFECOOKIE authentication and HMAC handling.
#include <torpp/tor.hpp>
#include <iostream>
int main() {
torpp::Tor tor = torpp::Tor::start({});
torpp::OnionServiceConfig config;
config.port_mappings.push_back({80, "127.0.0.1:8080"});
config.wait_for_publication = false;
torpp::OnionService onion = tor.create_onion_service(config);
onion.save_identity("service.key");
std::cout << onion.address() << '\n';
}See examples/basic_onion.cpp for a fuller sample.