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

Reformat with clang-format-11

This commit is contained in:
Jason Rhinelander 2021-03-05 13:31:52 -04:00
parent e5aa96ed7c
commit 91d6698a9d
33 changed files with 220 additions and 194 deletions

View file

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

View file

@ -376,8 +376,8 @@ main(int argc, char* argv[])
#ifndef _WIN32
return lokinet_main(argc, argv);
#else
SERVICE_TABLE_ENTRY DispatchTable[] = {{"lokinet", (LPSERVICE_MAIN_FUNCTION)win32_daemon_entry},
{NULL, NULL}};
SERVICE_TABLE_ENTRY DispatchTable[] = {
{"lokinet", (LPSERVICE_MAIN_FUNCTION)win32_daemon_entry}, {NULL, NULL}};
if (lstrcmpi(argv[1], "--win32-daemon") == 0)
{
start_as_daemon = true;
@ -576,26 +576,27 @@ lokinet_main(int argc, char* argv[])
// do periodic non lokinet related tasks here
if (ctx and ctx->IsUp() and not ctx->LooksAlive())
{
for (const auto& wtf : {"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."})
for (const auto& wtf :
{"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."})
{
LogError(wtf);
llarp::LogContext::Instance().ImmediateFlush();

2
external/uvw vendored

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -28,7 +28,8 @@ namespace llarp
{
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}};
}
@ -129,7 +130,8 @@ namespace llarp
{
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)};
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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