mirror of https://github.com/oxen-io/lokinet
make format
This commit is contained in:
parent
de21a2f687
commit
0a1620aff2
|
@ -6,40 +6,41 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
bool dumpRc(const std::vector<std::string>& files, bool json)
|
||||
bool
|
||||
dumpRc(const std::vector< std::string >& files, bool json)
|
||||
{
|
||||
nlohmann::json result;
|
||||
for(const auto& file : files)
|
||||
nlohmann::json result;
|
||||
for(const auto& file : files)
|
||||
{
|
||||
llarp::RouterContact rc;
|
||||
const bool ret = rc.Read(file.c_str());
|
||||
|
||||
if(ret)
|
||||
{
|
||||
llarp::RouterContact rc;
|
||||
const bool ret = rc.Read(file.c_str());
|
||||
|
||||
if (ret)
|
||||
{
|
||||
if (json)
|
||||
{
|
||||
result[file] = rc.ToJson();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "file = " << file << "\n";
|
||||
std::cout << rc << "\n\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "file = " << file << " was not a valid rc file\n";
|
||||
}
|
||||
if(json)
|
||||
{
|
||||
result[file] = rc.ToJson();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "file = " << file << "\n";
|
||||
std::cout << rc << "\n\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "file = " << file << " was not a valid rc file\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (json)
|
||||
std::cout << result << "\n";
|
||||
if(json)
|
||||
std::cout << result << "\n";
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef LOKINET_DEBUG
|
||||
absl::SetMutexDeadlockDetectionMode(absl::OnDeadlockCycle::kAbort);
|
||||
|
@ -55,18 +56,20 @@ main(int argc, char *argv[])
|
|||
("v,verbose", "Verbose", cxxopts::value<bool>())
|
||||
("h,help", "help", cxxopts::value<bool>())
|
||||
("j,json", "output in json", cxxopts::value<bool>())
|
||||
("dump", "dump rc file", cxxopts::value<std::vector<std::string>>(), "FILE");
|
||||
("dump", "dump rc file", cxxopts::value<std::vector<std::string> >(), "FILE");
|
||||
// clang-format on
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
const auto result = options.parse(argc, argv);
|
||||
|
||||
const bool json = result["json"].as<bool>();
|
||||
const bool json = result["json"].as< bool >();
|
||||
|
||||
if(result.count("verbose") > 0)
|
||||
{
|
||||
SetLogLevel(llarp::eLogDebug);
|
||||
llarp::LogContext::Instance().logStream = std::make_unique<llarp::OStreamLogStream>(std::cerr);
|
||||
llarp::LogContext::Instance().logStream =
|
||||
std::make_unique< llarp::OStreamLogStream >(std::cerr);
|
||||
llarp::LogDebug("debug logging activated");
|
||||
}
|
||||
|
||||
|
@ -78,13 +81,13 @@ main(int argc, char *argv[])
|
|||
|
||||
if(result.count("dump") > 0)
|
||||
{
|
||||
if (!dumpRc(result["dump"].as<std::vector<std::string>>(), json))
|
||||
if(!dumpRc(result["dump"].as< std::vector< std::string > >(), json))
|
||||
{
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const cxxopts::OptionParseException &ex)
|
||||
catch(const cxxopts::OptionParseException& ex)
|
||||
{
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cout << options.help() << std::endl;
|
||||
|
|
|
@ -633,17 +633,16 @@ namespace libuv
|
|||
Loop::CloseAll()
|
||||
{
|
||||
llarp::LogInfo("Closing all handles");
|
||||
uv_walk(
|
||||
m_Impl.get(),
|
||||
[](uv_handle_t* h, void*) {
|
||||
if(uv_is_closing(h))
|
||||
return;
|
||||
if(h->data && uv_is_active(h))
|
||||
{
|
||||
static_cast< glue* >(h->data)->Close();
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
uv_walk(m_Impl.get(),
|
||||
[](uv_handle_t* h, void*) {
|
||||
if(uv_is_closing(h))
|
||||
return;
|
||||
if(h->data && uv_is_active(h))
|
||||
{
|
||||
static_cast< glue* >(h->data)->Close();
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -164,15 +164,14 @@ namespace llarp
|
|||
HopHandler_ptr
|
||||
PathContext::GetByUpstream(const RouterID& remote, const PathID_t& id)
|
||||
{
|
||||
auto own = MapGet(
|
||||
m_OurPaths, id,
|
||||
[](const PathSet_ptr) -> bool {
|
||||
// TODO: is this right?
|
||||
return true;
|
||||
},
|
||||
[remote, id](PathSet_ptr p) -> HopHandler_ptr {
|
||||
return p->GetByUpstream(remote, id);
|
||||
});
|
||||
auto own = MapGet(m_OurPaths, id,
|
||||
[](const PathSet_ptr) -> bool {
|
||||
// TODO: is this right?
|
||||
return true;
|
||||
},
|
||||
[remote, id](PathSet_ptr p) -> HopHandler_ptr {
|
||||
return p->GetByUpstream(remote, id);
|
||||
});
|
||||
if(own)
|
||||
return own;
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace llarp
|
|||
nlohmann::json
|
||||
ToJson() const
|
||||
{
|
||||
return ExtractStatus().get();
|
||||
return ExtractStatus().get();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in New Issue