-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (29 loc) · 885 Bytes
/
Copy pathmain.cpp
File metadata and controls
37 lines (29 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <csignal>
#include <thread>
#include <iostream>
#include <onionpp/Configuration/Configuration.h>
#include <onionpp/Tor/Tor.h>
#include <onionpp/onionpp.h>
bool bRun = true;
void handler(int) {
bRun = false;
}
int main(const int argc, char** argv) {
#ifdef _WIN32
signal(SIGINT, handler);
#else
struct sigaction signalHandler {};
signalHandler.sa_handler = handler;
sigemptyset(&signalHandler.sa_mask);
signalHandler.sa_flags = 0;
sigaction(SIGINT, &signalHandler, nullptr);
#endif
std::cout << "Version: " << onionpp::getVersion() << std::endl;
onionpp::Configuration cfg(argc, argv);
std::cout << "Created tor configuration" << std::endl;
onionpp::Tor tor(std::make_shared<onionpp::Configuration>(cfg));
std::cout << "Tor is running now and can be controlled via the control port." << std::endl;
tor.start(true);
tor.join();
return 0;
}