2018-12-12 01:55:30 +00:00
|
|
|
#include <router_contact.hpp>
|
2018-07-24 03:40:34 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
#include <cxxopts.hpp>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2018-08-17 10:40:40 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
bool dumpRc(const std::vector<std::string>& files)
|
2018-05-21 12:51:10 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
for(const auto& file : files)
|
2018-05-22 18:41:38 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
llarp::RouterContact rc;
|
|
|
|
const bool ret = rc.Read(file.c_str());
|
|
|
|
|
|
|
|
if (ret)
|
2018-07-08 13:29:29 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
std::cout << "file = " << file << "\n";
|
|
|
|
std::cout << rc << "\n\n";
|
2018-07-08 13:29:29 +00:00
|
|
|
}
|
2019-08-12 21:47:30 +00:00
|
|
|
else
|
2018-07-08 13:29:29 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
std::cerr << "file = " << file << " was not a valid rc file\n";
|
2018-07-08 13:29:29 +00:00
|
|
|
}
|
2018-05-21 12:51:10 +00:00
|
|
|
}
|
2018-09-19 12:22:34 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-09-19 12:22:34 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2019-03-03 15:01:05 +00:00
|
|
|
#ifdef LOKINET_DEBUG
|
|
|
|
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kAbort);
|
|
|
|
#endif
|
|
|
|
|
2019-08-12 21:47:30 +00: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"
|
|
|
|
);
|
2018-08-24 16:07:17 +00:00
|
|
|
|
2019-08-12 21:47:30 +00: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 12:46:54 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
try {
|
|
|
|
const auto result = options.parse(argc, argv);
|
2018-08-24 16:07:17 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
if(result.count("verbose") > 0)
|
|
|
|
{
|
|
|
|
SetLogLevel(llarp::eLogDebug);
|
|
|
|
llarp::LogDebug("debug logging activated");
|
|
|
|
}
|
2018-08-24 16:07:17 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
if(result.count("help") > 0)
|
2018-08-31 12:46:54 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
std::cout << options.help() << std::endl;
|
|
|
|
return 0;
|
2018-08-31 12:46:54 +00:00
|
|
|
}
|
2018-08-24 16:07:17 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
if(result.count("dump") > 0)
|
2018-08-24 16:07:17 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
if (!dumpRc(result["dump"].as<std::vector<std::string>>()))
|
2018-08-31 12:46:54 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
return 1;
|
2018-08-31 12:46:54 +00:00
|
|
|
}
|
2018-08-24 16:07:17 +00:00
|
|
|
}
|
2018-05-21 12:51:10 +00:00
|
|
|
}
|
2019-08-12 21:47:30 +00:00
|
|
|
catch(const cxxopts::OptionParseException &ex)
|
2018-09-27 18:08:42 +00:00
|
|
|
{
|
2019-08-12 21:47:30 +00:00
|
|
|
std::cerr << ex.what() << std::endl;
|
|
|
|
std::cout << options.help() << std::endl;
|
2018-09-27 18:08:42 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2018-08-02 23:30:34 +00:00
|
|
|
|
2019-08-12 21:47:30 +00:00
|
|
|
return 0;
|
2018-05-21 12:51:10 +00:00
|
|
|
}
|