1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/daemon/rcutil.cpp

79 lines
1.7 KiB
C++
Raw Normal View History

2018-12-12 02:55:30 +01:00
#include <router_contact.hpp>
2018-07-24 05:40:34 +02:00
2019-08-12 23:47:30 +02:00
#include <cxxopts.hpp>
#include <string>
#include <vector>
2019-08-12 23:47:30 +02:00
bool dumpRc(const std::vector<std::string>& files)
2018-05-21 14:51:10 +02:00
{
2019-08-12 23:47:30 +02:00
for(const auto& file : files)
{
2019-08-12 23:47:30 +02:00
llarp::RouterContact rc;
const bool ret = rc.Read(file.c_str());
if (ret)
{
2019-08-12 23:47:30 +02:00
std::cout << "file = " << file << "\n";
std::cout << rc << "\n\n";
}
2019-08-12 23:47:30 +02:00
else
{
2019-08-12 23:47:30 +02:00
std::cerr << "file = " << file << " was not a valid rc file\n";
}
2018-05-21 14:51:10 +02:00
}
2019-08-12 23:47:30 +02:00
return true;
}
2019-08-12 23:47:30 +02:00
int
main(int argc, char *argv[])
{
#ifdef LOKINET_DEBUG
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kAbort);
#endif
2019-08-12 23:47:30 +02:00
// clang-format off
cxxopts::Options options(
"lokinet-rcutil",
"LokiNET is a free, open source, private, decentralized, \"market based sybil resistant\" and IP based onion routing network"
);
2019-08-12 23:47:30 +02:00
options.add_options()
("v,verbose", "Verbose", cxxopts::value<bool>())
("h,help", "help", cxxopts::value<bool>())
("dump", "dump rc file", cxxopts::value<std::vector<std::string>>(), "FILE");
// clang-format on
2018-08-31 14:46:54 +02:00
2019-08-12 23:47:30 +02:00
try {
const auto result = options.parse(argc, argv);
2019-08-12 23:47:30 +02:00
if(result.count("verbose") > 0)
{
SetLogLevel(llarp::eLogDebug);
llarp::LogDebug("debug logging activated");
}
2019-08-12 23:47:30 +02:00
if(result.count("help") > 0)
2018-08-31 14:46:54 +02:00
{
2019-08-12 23:47:30 +02:00
std::cout << options.help() << std::endl;
return 0;
2018-08-31 14:46:54 +02:00
}
2019-08-12 23:47:30 +02:00
if(result.count("dump") > 0)
{
2019-08-12 23:47:30 +02:00
if (!dumpRc(result["dump"].as<std::vector<std::string>>()))
2018-08-31 14:46:54 +02:00
{
2019-08-12 23:47:30 +02:00
return 1;
2018-08-31 14:46:54 +02:00
}
}
2018-05-21 14:51:10 +02:00
}
2019-08-12 23:47:30 +02:00
catch(const cxxopts::OptionParseException &ex)
{
2019-08-12 23:47:30 +02:00
std::cerr << ex.what() << std::endl;
std::cout << options.help() << std::endl;
return 1;
}
2018-08-03 01:30:34 +02:00
2019-08-12 23:47:30 +02:00
return 0;
2018-05-21 14:51:10 +02:00
}