Reformat with clang-format-11

pull/1568/head
Jason Rhinelander 3 years ago
parent e5aa96ed7c
commit 91d6698a9d

@ -147,10 +147,11 @@ main(int argc, char* argv[])
return 1; return 1;
} }
lokimq::LokiMQ lmq{[](lokimq::LogLevel lvl, const char* file, int line, std::string msg) { lokimq::LokiMQ lmq{
std::cout << lvl << " [" << file << ":" << line << "] " << msg << std::endl; [](lokimq::LogLevel lvl, const char* file, int line, std::string msg) {
}, std::cout << lvl << " [" << file << ":" << line << "] " << msg << std::endl;
logLevel}; },
logLevel};
lmq.start(); lmq.start();

@ -376,8 +376,8 @@ main(int argc, char* argv[])
#ifndef _WIN32 #ifndef _WIN32
return lokinet_main(argc, argv); return lokinet_main(argc, argv);
#else #else
SERVICE_TABLE_ENTRY DispatchTable[] = {{"lokinet", (LPSERVICE_MAIN_FUNCTION)win32_daemon_entry}, SERVICE_TABLE_ENTRY DispatchTable[] = {
{NULL, NULL}}; {"lokinet", (LPSERVICE_MAIN_FUNCTION)win32_daemon_entry}, {NULL, NULL}};
if (lstrcmpi(argv[1], "--win32-daemon") == 0) if (lstrcmpi(argv[1], "--win32-daemon") == 0)
{ {
start_as_daemon = true; start_as_daemon = true;
@ -576,26 +576,27 @@ lokinet_main(int argc, char* argv[])
// do periodic non lokinet related tasks here // do periodic non lokinet related tasks here
if (ctx and ctx->IsUp() and not ctx->LooksAlive()) if (ctx and ctx->IsUp() and not ctx->LooksAlive())
{ {
for (const auto& wtf : {"you have been visited by the mascott of the " for (const auto& wtf :
"deadlocked router.", {"you have been visited by the mascott of the "
"⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠄⠄⠄⠄", "deadlocked router.",
"⠄⠄⠄⠄⠄⢀⣀⣀⡀⠄⠄⠄⡠⢲⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠄⠄", "⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠄⠄⠄⠄",
"⠄⠄⠄⠔⣈⣀⠄⢔⡒⠳⡴⠊⠄⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣧⠄⠄", "⠄⠄⠄⠄⠄⢀⣀⣀⡀⠄⠄⠄⡠⢲⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠄⠄",
"⠄⢜⡴⢑⠖⠊⢐⣤⠞⣩⡇⠄⠄⠄⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠄⠝⠛⠋⠐", "⠄⠄⠄⠔⣈⣀⠄⢔⡒⠳⡴⠊⠄⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣧⠄⠄",
"⢸⠏⣷⠈⠄⣱⠃⠄⢠⠃⠐⡀⠄⠄⠄⠄⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠸⠄⠄⠄⠄", "⠄⢜⡴⢑⠖⠊⢐⣤⠞⣩⡇⠄⠄⠄⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠄⠝⠛⠋⠐",
"⠈⣅⠞⢁⣿⢸⠘⡄⡆⠄⠄⠈⠢⡀⠄⠄⠄⠄⠄⠄⠉⠙⠛⠛⠛⠉⠉⡀⠄⠡⢀⠄⣀", "⢸⠏⣷⠈⠄⣱⠃⠄⢠⠃⠐⡀⠄⠄⠄⠄⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠸⠄⠄⠄⠄",
"⠄⠙⡎⣹⢸⠄⠆⢘⠁⠄⠄⠄⢸⠈⠢⢄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠃⠄⠄⠄⠄⠄", "⠈⣅⠞⢁⣿⢸⠘⡄⡆⠄⠄⠈⠢⡀⠄⠄⠄⠄⠄⠄⠉⠙⠛⠛⠛⠉⠉⡀⠄⠡⢀⠄⣀",
"⠄⠄⠑⢿⠈⢆⠘⢼⠄⠄⠄⠄⠸⢐⢾⠄⡘⡏⠲⠆⠠⣤⢤⢤⡤⠄⣖⡇⠄⠄⠄⠄⠄", "⠄⠙⡎⣹⢸⠄⠆⢘⠁⠄⠄⠄⢸⠈⠢⢄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠃⠄⠄⠄⠄⠄",
"⣴⣶⣿⣿⣣⣈⣢⣸⠄⠄⠄⠄⡾⣷⣾⣮⣤⡏⠁⠘⠊⢠⣷⣾⡛⡟⠈⠄⠄⠄⠄⠄⠄", "⠄⠄⠑⢿⠈⢆⠘⢼⠄⠄⠄⠄⠸⢐⢾⠄⡘⡏⠲⠆⠠⣤⢤⢤⡤⠄⣖⡇⠄⠄⠄⠄⠄",
"⣿⣿⣿⣿⣿⠉⠒⢽⠄⠄⠄⠄⡇⣿⣟⣿⡇⠄⠄⠄⠄⢸⣻⡿⡇⡇⠄⠄⠄⠄⠄⠄⠄", "⣴⣶⣿⣿⣣⣈⣢⣸⠄⠄⠄⠄⡾⣷⣾⣮⣤⡏⠁⠘⠊⢠⣷⣾⡛⡟⠈⠄⠄⠄⠄⠄⠄",
"⠻⣿⣿⣿⣿⣄⠰⢼⠄⠄⠄⡄⠁⢻⣍⣯⠃⠄⠄⠄⠄⠈⢿⣻⠃⠈⡆⡄⠄⠄⠄⠄⠄", "⣿⣿⣿⣿⣿⠉⠒⢽⠄⠄⠄⠄⡇⣿⣟⣿⡇⠄⠄⠄⠄⢸⣻⡿⡇⡇⠄⠄⠄⠄⠄⠄⠄",
"⠄⠙⠿⠿⠛⣿⣶⣤⡇⠄⠄⢣⠄⠄⠈⠄⢠⠂⠄⠁⠄⡀⠄⠄⣀⠔⢁⠃⠄⠄⠄⠄⠄", "⠻⣿⣿⣿⣿⣄⠰⢼⠄⠄⠄⡄⠁⢻⣍⣯⠃⠄⠄⠄⠄⠈⢿⣻⠃⠈⡆⡄⠄⠄⠄⠄⠄",
"⠄⠄⠄⠄⠄⣿⣿⣿⣿⣾⠢⣖⣶⣦⣤⣤⣬⣤⣤⣤⣴⣶⣶⡏⠠⢃⠌⠄⠄⠄⠄⠄⠄", "⠄⠙⠿⠿⠛⣿⣶⣤⡇⠄⠄⢣⠄⠄⠈⠄⢠⠂⠄⠁⠄⡀⠄⠄⣀⠔⢁⠃⠄⠄⠄⠄⠄",
"⠄⠄⠄⠄⠄⠿⠿⠟⠛⡹⠉⠛⠛⠿⠿⣿⣿⣿⣿⣿⡿⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄", "⠄⠄⠄⠄⠄⣿⣿⣿⣿⣾⠢⣖⣶⣦⣤⣤⣬⣤⣤⣤⣴⣶⣶⡏⠠⢃⠌⠄⠄⠄⠄⠄⠄",
"⠠⠤⠤⠄⠄⣀⠄⠄⠄⠑⠠⣤⣀⣀⣀⡘⣿⠿⠙⠻⡍⢀⡈⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄", "⠄⠄⠄⠄⠄⠿⠿⠟⠛⡹⠉⠛⠛⠿⠿⣿⣿⣿⣿⣿⡿⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄",
"⠄⠄⠄⠄⠄⠄⠑⠠⣠⣴⣾⣿⣿⣿⣿⣿⣿⣇⠉⠄⠻⣿⣷⣄⡀⠄⠄⠄⠄⠄⠄⠄⠄", "⠠⠤⠤⠄⠄⣀⠄⠄⠄⠑⠠⣤⣀⣀⣀⡘⣿⠿⠙⠻⡍⢀⡈⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄",
"file a bug report now or be cursed with this " "⠄⠄⠄⠄⠄⠄⠑⠠⣠⣴⣾⣿⣿⣿⣿⣿⣿⣇⠉⠄⠻⣿⣷⣄⡀⠄⠄⠄⠄⠄⠄⠄⠄",
"annoying image in your syslog for all time."}) "file a bug report now or be cursed with this "
"annoying image in your syslog for all time."})
{ {
LogError(wtf); LogError(wtf);
llarp::LogContext::Instance().ImmediateFlush(); llarp::LogContext::Instance().ImmediateFlush();

2
external/uvw vendored

@ -1 +1 @@
Subproject commit 51724bcef0effa361710677a10cb6d7fd58c4616 Subproject commit 36fdf810a6385b9edbf9cbaf14862b8c9a547f15

@ -1006,9 +1006,10 @@ namespace llarp
} }
m_UniqueHopsNetmaskSize = arg; m_UniqueHopsNetmaskSize = arg;
}, },
Comment{"Netmask for router path selection; each router must be from a distinct IP subnet " Comment{
"of the given size.", "Netmask for router path selection; each router must be from a distinct IP subnet "
"E.g. 16 ensures that all routers are using distinct /16 IP addresses."}); "of the given size.",
"E.g. 16 ensures that all routers are using distinct /16 IP addresses."});
#ifdef WITH_GEOIP #ifdef WITH_GEOIP
conf.defineOption<std::string>( conf.defineOption<std::string>(
@ -1019,9 +1020,10 @@ namespace llarp
[=](std::string arg) { [=](std::string arg) {
m_ExcludeCountries.emplace(lowercase_ascii_string(std::move(arg))); m_ExcludeCountries.emplace(lowercase_ascii_string(std::move(arg)));
}, },
Comment{"exclude a country given its 2 letter country code from being used in path builds", Comment{
"e.g. exclude-country=DE", "exclude a country given its 2 letter country code from being used in path builds",
"can be listed multiple times to exclude multiple countries"}); "e.g. exclude-country=DE",
"can be listed multiple times to exclude multiple countries"});
#endif #endif
} }

@ -39,9 +39,9 @@ namespace llarp
LogWarn( LogWarn(
"*** WARNING: The config option ", "*** WARNING: The config option ",
opt, opt,
(deprecated ? " is deprecated" (deprecated ? " is deprecated"
: relay ? " is not valid in service node configuration files" : relay ? " is not valid in service node configuration files"
: " is not valid in client configuration files"), : " is not valid in client configuration files"),
" and has been ignored."); " and has been ignored.");
}); });
} }

@ -435,12 +435,13 @@ namespace llarp
util::StatusObject util::StatusObject
Context::ExtractStatus() const Context::ExtractStatus() const
{ {
util::StatusObject obj{{"pendingRouterLookups", pendingRouterLookups().ExtractStatus()}, util::StatusObject obj{
{"pendingIntrosetLookups", _pendingIntrosetLookups.ExtractStatus()}, {"pendingRouterLookups", pendingRouterLookups().ExtractStatus()},
{"pendingExploreLookups", pendingExploreLookups().ExtractStatus()}, {"pendingIntrosetLookups", _pendingIntrosetLookups.ExtractStatus()},
{"nodes", _nodes->ExtractStatus()}, {"pendingExploreLookups", pendingExploreLookups().ExtractStatus()},
{"services", _services->ExtractStatus()}, {"nodes", _nodes->ExtractStatus()},
{"ourKey", ourKey.ToHex()}}; {"services", _services->ExtractStatus()},
{"ourKey", ourKey.ToHex()}};
return obj; return obj;
} }

@ -16,10 +16,10 @@ namespace llarp::dht
bool bool
FindNameMessage::BEncode(llarp_buffer_t* buf) const FindNameMessage::BEncode(llarp_buffer_t* buf) const
{ {
const auto data = oxenmq::bt_serialize( const auto data = oxenmq::bt_serialize(oxenmq::bt_dict{
oxenmq::bt_dict{{"A", "N"sv}, {"A", "N"sv},
{"H", std::string_view{(char*)NameHash.data(), NameHash.size()}}, {"H", std::string_view{(char*)NameHash.data(), NameHash.size()}},
{"T", TxID}}); {"T", TxID}});
return buf->write(data.begin(), data.end()); return buf->write(data.begin(), data.end());
} }

@ -36,8 +36,8 @@ namespace llarp
util::StatusObject util::StatusObject
ExtractStatus() const ExtractStatus() const
{ {
util::StatusObject obj{{"whoasked", whoasked.ExtractStatus()}, util::StatusObject obj{
{"target", target.ExtractStatus()}}; {"whoasked", whoasked.ExtractStatus()}, {"target", target.ExtractStatus()}};
std::vector<util::StatusObject> foundObjs; std::vector<util::StatusObject> foundObjs;
std::transform( std::transform(
valuesFound.begin(), valuesFound.begin(),

@ -37,8 +37,8 @@ namespace llarp
tx.end(), tx.end(),
std::back_inserter(txObjs), std::back_inserter(txObjs),
[](const auto& item) -> util::StatusObject { [](const auto& item) -> util::StatusObject {
return util::StatusObject{{"owner", item.first.ExtractStatus()}, return util::StatusObject{
{"tx", item.second->ExtractStatus()}}; {"owner", item.first.ExtractStatus()}, {"tx", item.second->ExtractStatus()}};
}); });
obj["tx"] = txObjs; obj["tx"] = txObjs;
std::transform( std::transform(
@ -46,8 +46,8 @@ namespace llarp
timeouts.end(), timeouts.end(),
std::back_inserter(timeoutsObjs), std::back_inserter(timeoutsObjs),
[](const auto& item) -> util::StatusObject { [](const auto& item) -> util::StatusObject {
return util::StatusObject{{"time", to_json(item.second)}, return util::StatusObject{
{"target", item.first.ExtractStatus()}}; {"time", to_json(item.second)}, {"target", item.first.ExtractStatus()}};
}); });
obj["timeouts"] = timeoutsObjs; obj["timeouts"] = timeoutsObjs;
std::transform( std::transform(
@ -55,8 +55,9 @@ namespace llarp
waiting.end(), waiting.end(),
std::back_inserter(waitingObjs), std::back_inserter(waitingObjs),
[](const auto& item) -> util::StatusObject { [](const auto& item) -> util::StatusObject {
return util::StatusObject{{"target", item.first.ExtractStatus()}, return util::StatusObject{
{"whoasked", item.second.ExtractStatus()}}; {"target", item.first.ExtractStatus()},
{"whoasked", item.second.ExtractStatus()}};
}); });
obj["waiting"] = waitingObjs; obj["waiting"] = waitingObjs;
return obj; return obj;

@ -40,15 +40,16 @@ namespace llarp
Endpoint::ExtractStatus() const Endpoint::ExtractStatus() const
{ {
auto now = m_Parent->Now(); auto now = m_Parent->Now();
util::StatusObject obj{{"identity", m_remoteSignKey.ToString()}, util::StatusObject obj{
{"ip", m_IP.ToString()}, {"identity", m_remoteSignKey.ToString()},
{"txRate", m_TxRate}, {"ip", m_IP.ToString()},
{"rxRate", m_RxRate}, {"txRate", m_TxRate},
{"createdAt", to_json(createdAt)}, {"rxRate", m_RxRate},
{"exiting", !m_RewriteSource}, {"createdAt", to_json(createdAt)},
{"looksDead", LooksDead(now)}, {"exiting", !m_RewriteSource},
{"expiresSoon", ExpiresSoon(now)}, {"looksDead", LooksDead(now)},
{"expired", IsExpired(now)}}; {"expiresSoon", ExpiresSoon(now)},
{"expired", IsExpired(now)}};
return obj; return obj;
} }

@ -296,27 +296,28 @@ namespace llarp
{ {
const auto now = m_Parent->Now(); const auto now = m_Parent->Now();
return {{"txRateCurrent", m_Stats.currentRateTX}, return {
{"rxRateCurrent", m_Stats.currentRateRX}, {"txRateCurrent", m_Stats.currentRateTX},
{"rxPktsRcvd", m_Stats.totalPacketsRX}, {"rxRateCurrent", m_Stats.currentRateRX},
{"rxPktsRcvd", m_Stats.totalPacketsRX},
// leave 'tx' and 'rx' as duplicates of 'xRateCurrent' for compat
{"tx", m_Stats.currentRateTX}, // leave 'tx' and 'rx' as duplicates of 'xRateCurrent' for compat
{"rx", m_Stats.currentRateRX}, {"tx", m_Stats.currentRateTX},
{"rx", m_Stats.currentRateRX},
{"txPktsAcked", m_Stats.totalAckedTX},
{"txPktsDropped", m_Stats.totalDroppedTX}, {"txPktsAcked", m_Stats.totalAckedTX},
{"txPktsInFlight", m_Stats.totalInFlightTX}, {"txPktsDropped", m_Stats.totalDroppedTX},
{"txPktsInFlight", m_Stats.totalInFlightTX},
{"state", StateToString(m_State)},
{"inbound", m_Inbound}, {"state", StateToString(m_State)},
{"replayFilter", m_ReplayFilter.size()}, {"inbound", m_Inbound},
{"txMsgQueueSize", m_TXMsgs.size()}, {"replayFilter", m_ReplayFilter.size()},
{"rxMsgQueueSize", m_RXMsgs.size()}, {"txMsgQueueSize", m_TXMsgs.size()},
{"remoteAddr", m_RemoteAddr.toString()}, {"rxMsgQueueSize", m_RXMsgs.size()},
{"remoteRC", m_RemoteRC.ExtractStatus()}, {"remoteAddr", m_RemoteAddr.toString()},
{"created", to_json(m_CreatedAt)}, {"remoteRC", m_RemoteRC.ExtractStatus()},
{"uptime", to_json(now - m_CreatedAt)}}; {"created", to_json(m_CreatedAt)},
{"uptime", to_json(now - m_CreatedAt)}};
} }
bool bool
@ -737,8 +738,8 @@ namespace llarp
} }
uint16_t sz = bufbe16toh(data.data() + CommandOverhead + PacketOverhead); uint16_t sz = bufbe16toh(data.data() + CommandOverhead + PacketOverhead);
uint64_t rxid = bufbe64toh(data.data() + CommandOverhead + sizeof(uint16_t) + PacketOverhead); uint64_t rxid = bufbe64toh(data.data() + CommandOverhead + sizeof(uint16_t) + PacketOverhead);
ShortHash h{data.data() + CommandOverhead + sizeof(uint16_t) + sizeof(uint64_t) ShortHash h{
+ PacketOverhead}; data.data() + CommandOverhead + sizeof(uint16_t) + sizeof(uint64_t) + PacketOverhead};
LogDebug("rxid=", rxid, " sz=", sz, " h=", h.ToHex()); LogDebug("rxid=", rxid, " sz=", sz, " h=", h.ToHex());
m_LastRX = m_Parent->Now(); m_LastRX = m_Parent->Now();
{ {

@ -291,10 +291,11 @@ namespace llarp
[](const auto& item) -> util::StatusObject { return item.second->ExtractStatus(); }); [](const auto& item) -> util::StatusObject { return item.second->ExtractStatus(); });
} }
return {{"name", Name()}, return {
{"rank", uint64_t(Rank())}, {"name", Name()},
{"addr", m_ourAddr.toString()}, {"rank", uint64_t(Rank())},
{"sessions", util::StatusObject{{"pending", pending}, {"established", established}}}}; {"addr", m_ourAddr.toString()},
{"sessions", util::StatusObject{{"pending", pending}, {"established", established}}}};
} }
bool bool

@ -184,10 +184,11 @@ namespace llarp
char tmp[128] = {0}; char tmp[128] = {0};
inet_ntop(AF_INET6, (void*)&a.ip, tmp, sizeof(tmp)); inet_ntop(AF_INET6, (void*)&a.ip, tmp, sizeof(tmp));
j = nlohmann::json{{"rank", a.rank}, j = nlohmann::json{
{"dialect", a.dialect}, {"rank", a.rank},
{"pubkey", a.pubkey.ToString()}, {"dialect", a.dialect},
{"in6_addr", tmp}, {"pubkey", a.pubkey.ToString()},
{"port", a.port}}; {"in6_addr", tmp},
{"port", a.port}};
} }
} // namespace llarp } // namespace llarp

@ -636,22 +636,23 @@ namespace llarp
} }
#if !defined(TESTNET) #if !defined(TESTNET)
static constexpr std::array bogonRanges = {IPRange::FromIPv4(0, 0, 0, 0, 8), static constexpr std::array bogonRanges = {
IPRange::FromIPv4(10, 0, 0, 0, 8), IPRange::FromIPv4(0, 0, 0, 0, 8),
IPRange::FromIPv4(21, 0, 0, 0, 8), IPRange::FromIPv4(10, 0, 0, 0, 8),
IPRange::FromIPv4(100, 64, 0, 0, 10), IPRange::FromIPv4(21, 0, 0, 0, 8),
IPRange::FromIPv4(127, 0, 0, 0, 8), IPRange::FromIPv4(100, 64, 0, 0, 10),
IPRange::FromIPv4(169, 254, 0, 0, 16), IPRange::FromIPv4(127, 0, 0, 0, 8),
IPRange::FromIPv4(172, 16, 0, 0, 12), IPRange::FromIPv4(169, 254, 0, 0, 16),
IPRange::FromIPv4(192, 0, 0, 0, 24), IPRange::FromIPv4(172, 16, 0, 0, 12),
IPRange::FromIPv4(192, 0, 2, 0, 24), IPRange::FromIPv4(192, 0, 0, 0, 24),
IPRange::FromIPv4(192, 88, 99, 0, 24), IPRange::FromIPv4(192, 0, 2, 0, 24),
IPRange::FromIPv4(192, 168, 0, 0, 16), IPRange::FromIPv4(192, 88, 99, 0, 24),
IPRange::FromIPv4(198, 18, 0, 0, 15), IPRange::FromIPv4(192, 168, 0, 0, 16),
IPRange::FromIPv4(198, 51, 100, 0, 24), IPRange::FromIPv4(198, 18, 0, 0, 15),
IPRange::FromIPv4(203, 0, 113, 0, 24), IPRange::FromIPv4(198, 51, 100, 0, 24),
IPRange::FromIPv4(224, 0, 0, 0, 4), IPRange::FromIPv4(203, 0, 113, 0, 24),
IPRange::FromIPv4(240, 0, 0, 0, 4)}; IPRange::FromIPv4(224, 0, 0, 0, 4),
IPRange::FromIPv4(240, 0, 0, 0, 4)};
bool bool
IsIPv4Bogon(const huint32_t& addr) IsIPv4Bogon(const huint32_t& addr)

@ -28,7 +28,8 @@ namespace llarp
{ {
UInt_t h; UInt_t h;
constexpr huint_t operator&(huint_t x) const constexpr huint_t
operator&(huint_t x) const
{ {
return huint_t{UInt_t{h & x.h}}; return huint_t{UInt_t{h & x.h}};
} }
@ -129,7 +130,8 @@ namespace llarp
{ {
UInt_t n; UInt_t n;
constexpr nuint_t operator&(nuint_t x) const constexpr nuint_t
operator&(nuint_t x) const
{ {
return nuint_t{UInt_t(n & x.n)}; return nuint_t{UInt_t(n & x.n)};
} }

@ -56,7 +56,8 @@ namespace llarp
lower &= o.lower; lower &= o.lower;
return *this; return *this;
} }
constexpr uint128_t operator&(const uint128_t& o) const constexpr uint128_t
operator&(const uint128_t& o) const
{ {
uint128_t result = *this; uint128_t result = *this;
result &= o; result &= o;
@ -216,8 +217,7 @@ namespace llarp
operator<<=(uint64_t shift) operator<<=(uint64_t shift)
{ {
if (shift == 0) if (shift == 0)
{ {}
}
else if (shift < 64) else if (shift < 64)
{ {
upper = upper << shift | (lower >> (64 - shift)); upper = upper << shift | (lower >> (64 - shift));
@ -251,8 +251,7 @@ namespace llarp
operator>>=(uint64_t shift) operator>>=(uint64_t shift)
{ {
if (shift == 0) if (shift == 0)
{ {}
}
else if (shift < 64) else if (shift < 64)
{ {
lower = lower >> shift | upper << (64 - shift); lower = lower >> shift | upper << (64 - shift);

@ -276,10 +276,11 @@ namespace llarp
util::StatusObject util::StatusObject
PathHopConfig::ExtractStatus() const PathHopConfig::ExtractStatus() const
{ {
util::StatusObject obj{{"lifetime", to_json(lifetime)}, util::StatusObject obj{
{"router", rc.pubkey.ToHex()}, {"lifetime", to_json(lifetime)},
{"txid", txID.ToHex()}, {"router", rc.pubkey.ToHex()},
{"rxid", rxID.ToHex()}}; {"txid", txID.ToHex()},
{"rxid", rxID.ToHex()}};
return obj; return obj;
} }
@ -288,17 +289,18 @@ namespace llarp
{ {
auto now = llarp::time_now_ms(); auto now = llarp::time_now_ms();
util::StatusObject obj{{"intro", intro.ExtractStatus()}, util::StatusObject obj{
{"lastRecvMsg", to_json(m_LastRecvMessage)}, {"intro", intro.ExtractStatus()},
{"lastLatencyTest", to_json(m_LastLatencyTestTime)}, {"lastRecvMsg", to_json(m_LastRecvMessage)},
{"buildStarted", to_json(buildStarted)}, {"lastLatencyTest", to_json(m_LastLatencyTestTime)},
{"expired", Expired(now)}, {"buildStarted", to_json(buildStarted)},
{"expiresSoon", ExpiresSoon(now)}, {"expired", Expired(now)},
{"expiresAt", to_json(ExpireTime())}, {"expiresSoon", ExpiresSoon(now)},
{"ready", IsReady()}, {"expiresAt", to_json(ExpireTime())},
{"txRateCurrent", m_LastTXRate}, {"ready", IsReady()},
{"rxRateCurrent", m_LastRXRate}, {"txRateCurrent", m_LastTXRate},
{"hasExit", SupportsAnyRoles(ePathRoleExit)}}; {"rxRateCurrent", m_LastRXRate},
{"hasExit", SupportsAnyRoles(ePathRoleExit)}};
std::vector<util::StatusObject> hopsObj; std::vector<util::StatusObject> hopsObj;
std::transform( std::transform(

@ -193,9 +193,10 @@ namespace llarp
util::StatusObject util::StatusObject
Builder::ExtractStatus() const Builder::ExtractStatus() const
{ {
util::StatusObject obj{{"buildStats", m_BuildStats.ExtractStatus()}, util::StatusObject obj{
{"numHops", uint64_t(numHops)}, {"buildStats", m_BuildStats.ExtractStatus()},
{"numPaths", uint64_t(numDesiredPaths)}}; {"numHops", uint64_t(numHops)},
{"numPaths", uint64_t(numDesiredPaths)}};
std::transform( std::transform(
m_Paths.begin(), m_Paths.begin(),
m_Paths.end(), m_Paths.end(),

@ -100,13 +100,14 @@ namespace llarp
util::StatusObject util::StatusObject
OutboundMessageHandler::ExtractStatus() const OutboundMessageHandler::ExtractStatus() const
{ {
util::StatusObject status{"queueStats", util::StatusObject status{
{{"queued", m_queueStats.queued}, "queueStats",
{"dropped", m_queueStats.dropped}, {{"queued", m_queueStats.queued},
{"sent", m_queueStats.sent}, {"dropped", m_queueStats.dropped},
{"queueWatermark", m_queueStats.queueWatermark}, {"sent", m_queueStats.sent},
{"perTickMax", m_queueStats.perTickMax}, {"queueWatermark", m_queueStats.queueWatermark},
{"numTicks", m_queueStats.numTicks}}}; {"perTickMax", m_queueStats.perTickMax},
{"numTicks", m_queueStats.numTicks}}};
return status; return status;
} }

@ -88,14 +88,15 @@ namespace llarp
if (m_peerDb) if (m_peerDb)
peerStatsObj = m_peerDb->ExtractStatus(); peerStatsObj = m_peerDb->ExtractStatus();
return util::StatusObject{{"running", true}, return util::StatusObject{
{"numNodesKnown", _nodedb->NumLoaded()}, {"running", true},
{"dht", _dht->impl->ExtractStatus()}, {"numNodesKnown", _nodedb->NumLoaded()},
{"services", _hiddenServiceContext.ExtractStatus()}, {"dht", _dht->impl->ExtractStatus()},
{"exit", _exitContext.ExtractStatus()}, {"services", _hiddenServiceContext.ExtractStatus()},
{"links", _linkManager.ExtractStatus()}, {"exit", _exitContext.ExtractStatus()},
{"outboundMessages", _outboundMessageHandler.ExtractStatus()}, {"links", _linkManager.ExtractStatus()},
{"peerStats", peerStatsObj}}; {"outboundMessages", _outboundMessageHandler.ExtractStatus()},
{"peerStats", peerStatsObj}};
} }
else else
{ {

@ -217,10 +217,11 @@ namespace llarp
util::StatusObject util::StatusObject
RouterContact::ExtractStatus() const RouterContact::ExtractStatus() const
{ {
util::StatusObject obj{{"lastUpdated", last_updated.count()}, util::StatusObject obj{
{"publicRouter", IsPublicRouter()}, {"lastUpdated", last_updated.count()},
{"identity", pubkey.ToString()}, {"publicRouter", IsPublicRouter()},
{"addresses", addrs}}; {"identity", pubkey.ToString()},
{"addresses", addrs}};
if (HasNick()) if (HasNick())
{ {

@ -60,8 +60,8 @@ namespace llarp::rpc
if (not m_Conn.has_value()) if (not m_Conn.has_value())
{ {
// we don't have a connection to the backend so it's failed // we don't have a connection to the backend so it's failed
reply(service::AuthResult{service::AuthResultCode::eAuthFailed, reply(service::AuthResult{
"remote has no connection to auth backend"}); service::AuthResultCode::eAuthFailed, "remote has no connection to auth backend"});
return; return;
} }

@ -98,8 +98,8 @@ namespace llarp::rpc
.add_request_command( .add_request_command(
"version", "version",
[r = m_Router](oxenmq::Message& msg) { [r = m_Router](oxenmq::Message& msg) {
util::StatusObject result{{"version", llarp::VERSION_FULL}, util::StatusObject result{
{"uptime", to_json(r->Uptime())}}; {"version", llarp::VERSION_FULL}, {"uptime", to_json(r->Uptime())}};
msg.send_reply(CreateJSONResponse(result)); msg.send_reply(CreateJSONResponse(result));
}) })
.add_request_command( .add_request_command(

@ -21,9 +21,10 @@ namespace llarp::service
AuthType AuthType
ParseAuthType(std::string data) ParseAuthType(std::string data)
{ {
std::unordered_map<std::string, AuthType> values = {{"lmq", AuthType::eAuthTypeLMQ}, std::unordered_map<std::string, AuthType> values = {
{"whitelist", AuthType::eAuthTypeWhitelist}, {"lmq", AuthType::eAuthTypeLMQ},
{"none", AuthType::eAuthTypeNone}}; {"whitelist", AuthType::eAuthTypeWhitelist},
{"none", AuthType::eAuthTypeNone}};
const auto itr = values.find(data); const auto itr = values.find(data);
if (itr == values.end()) if (itr == values.end())
throw std::invalid_argument("no such auth type: " + data); throw std::invalid_argument("no such auth type: " + data);

@ -1337,8 +1337,7 @@ namespace llarp
const AlignedBuffer<32> /*addr*/, bool snode, ConvoEventListener_ptr /*ev*/) const AlignedBuffer<32> /*addr*/, bool snode, ConvoEventListener_ptr /*ev*/)
{ {
if (snode) if (snode)
{ {}
}
// TODO: something meaningful // TODO: something meaningful
return false; return false;

@ -7,10 +7,11 @@ namespace llarp
util::StatusObject util::StatusObject
Introduction::ExtractStatus() const Introduction::ExtractStatus() const
{ {
util::StatusObject obj{{"router", router.ToHex()}, util::StatusObject obj{
{"expiresAt", to_json(expiresAt)}, {"router", router.ToHex()},
{"latency", to_json(latency)}, {"expiresAt", to_json(expiresAt)},
{"version", uint64_t(version)}}; {"latency", to_json(latency)},
{"version", uint64_t(version)}};
return obj; return obj;
} }

@ -71,11 +71,12 @@ namespace llarp
ExtractStatus() const ExtractStatus() const
{ {
auto now = time_now_ms(); auto now = time_now_ms();
util::StatusObject obj{{"txid", txid}, util::StatusObject obj{
{"endpoint", endpoint.ToHex()}, {"txid", txid},
{"name", name}, {"endpoint", endpoint.ToHex()},
{"timedOut", IsTimedOut(now)}, {"name", name},
{"createdAt", m_created.count()}}; {"timedOut", IsTimedOut(now)},
{"createdAt", m_created.count()}};
return obj; return obj;
} }

@ -553,8 +553,8 @@ namespace llarp
{ {
if (msg.proto == eProtocolAuth and not msg.payload.empty()) if (msg.proto == eProtocolAuth and not msg.payload.empty())
{ {
result.reason = std::string{reinterpret_cast<const char*>(msg.payload.data()), result.reason = std::string{
msg.payload.size()}; reinterpret_cast<const char*>(msg.payload.data()), msg.payload.size()};
} }
} }
} }
@ -576,8 +576,8 @@ namespace llarp
AuthResult result{AuthResultCode::eAuthAccepted, "OK"}; AuthResult result{AuthResultCode::eAuthAccepted, "OK"};
if (msg->proto == eProtocolAuth and not msg->payload.empty()) if (msg->proto == eProtocolAuth and not msg->payload.empty())
{ {
result.reason = std::string{reinterpret_cast<const char*>(msg->payload.data()), result.reason = std::string{
msg->payload.size()}; reinterpret_cast<const char*>(msg->payload.data()), msg->payload.size()};
} }
handler(result); handler(result);
}; };

@ -7,11 +7,12 @@ namespace llarp
util::StatusObject util::StatusObject
Session::ExtractStatus() const Session::ExtractStatus() const
{ {
util::StatusObject obj{{"lastUsed", to_json(lastUsed)}, util::StatusObject obj{
{"replyIntro", replyIntro.ExtractStatus()}, {"lastUsed", to_json(lastUsed)},
{"remote", remote.Addr().ToString()}, {"replyIntro", replyIntro.ExtractStatus()},
{"seqno", seqno}, {"remote", remote.Addr().ToString()},
{"intro", intro.ExtractStatus()}}; {"seqno", seqno},
{"intro", intro.ExtractStatus()}};
return obj; return obj;
} }

@ -139,13 +139,15 @@ namespace llarp
return *this; return *this;
} }
byte_t& operator[](size_t idx) byte_t&
operator[](size_t idx)
{ {
assert(idx < SIZE); assert(idx < SIZE);
return m_data[idx]; return m_data[idx];
} }
const byte_t& operator[](size_t idx) const const byte_t&
operator[](size_t idx) const
{ {
assert(idx < SIZE); assert(idx < SIZE);
return m_data[idx]; return m_data[idx];

@ -76,7 +76,8 @@ struct llarp_buffer_t
/// max size of buffer /// max size of buffer
size_t sz{0}; size_t sz{0};
byte_t operator[](size_t x) byte_t
operator[](size_t x)
{ {
return *(this->base + x); return *(this->base + x);
} }

@ -52,12 +52,13 @@ namespace llarp
std::transform(level.begin(), level.end(), level.begin(), [](const unsigned char ch) -> char { std::transform(level.begin(), level.end(), level.begin(), [](const unsigned char ch) -> char {
return std::tolower(ch); return std::tolower(ch);
}); });
static const std::unordered_map<std::string, LogLevel> levels = {{"trace", eLogTrace}, static const std::unordered_map<std::string, LogLevel> levels = {
{"debug", eLogDebug}, {"trace", eLogTrace},
{"info", eLogInfo}, {"debug", eLogDebug},
{"warn", eLogWarn}, {"info", eLogInfo},
{"error", eLogError}, {"warn", eLogWarn},
{"none", eLogNone}}; {"error", eLogError},
{"none", eLogNone}};
const auto itr = levels.find(level); const auto itr = levels.find(level);
if (itr == levels.end()) if (itr == levels.end())

@ -71,16 +71,16 @@ namespace llarp::vpn
if (connect(m_FD, (sockaddr*)&addr, sizeof(addr)) < 0) if (connect(m_FD, (sockaddr*)&addr, sizeof(addr)) < 0)
{ {
::close(m_FD); ::close(m_FD);
throw std::runtime_error{"cannot connect to control socket address: " throw std::runtime_error{
+ std::string{strerror(errno)}}; "cannot connect to control socket address: " + std::string{strerror(errno)}};
} }
uint32_t namesz = IFNAMSIZ; uint32_t namesz = IFNAMSIZ;
char name[IFNAMSIZ + 1]{}; char name[IFNAMSIZ + 1]{};
if (getsockopt(m_FD, SYSPROTO_CONTROL, 2, name, &namesz) < 0) if (getsockopt(m_FD, SYSPROTO_CONTROL, 2, name, &namesz) < 0)
{ {
::close(m_FD); ::close(m_FD);
throw std::runtime_error{"cannot query for interface name: " throw std::runtime_error{
+ std::string{strerror(errno)}}; "cannot query for interface name: " + std::string{strerror(errno)}};
} }
m_IfName = name; m_IfName = name;
for (const auto& ifaddr : m_Info.addrs) for (const auto& ifaddr : m_Info.addrs)
@ -128,8 +128,9 @@ namespace llarp::vpn
constexpr int uintsize = sizeof(unsigned int); constexpr int uintsize = sizeof(unsigned int);
net::IPPacket pkt{}; net::IPPacket pkt{};
unsigned int pktinfo = 0; unsigned int pktinfo = 0;
const struct iovec vecs[2] = {{.iov_base = &pktinfo, .iov_len = uintsize}, const struct iovec vecs[2] = {
{.iov_base = pkt.buf, .iov_len = sizeof(pkt.buf)}}; {.iov_base = &pktinfo, .iov_len = uintsize},
{.iov_base = pkt.buf, .iov_len = sizeof(pkt.buf)}};
int sz = readv(m_FD, vecs, 2); int sz = readv(m_FD, vecs, 2);
if (sz >= uintsize) if (sz >= uintsize)
pkt.sz = sz - uintsize; pkt.sz = sz - uintsize;

Loading…
Cancel
Save