clang-format

pull/323/head
Rick V 5 years ago
parent 0f45e286ff
commit 5a3947ca5c
No known key found for this signature in database
GPG Key ID: C0EDC8723FDC3465

@ -97,7 +97,8 @@ namespace abyss
bool
ShouldProcessHeader(const llarp::string_view& name) const
{
return name == llarp::string_view("content-length") || name == llarp::string_view("content-type");
return name == llarp::string_view("content-length")
|| name == llarp::string_view("content-type");
}
/// return true if we get a 200 status code

@ -103,7 +103,8 @@ namespace abyss
ShouldProcessHeader(const string_view& name) const
{
// TODO: header whitelist
return name == string_view("content-type") || name == string_view("content-length");
return name == string_view("content-type")
|| name == string_view("content-length");
}
bool

@ -26,7 +26,7 @@ llarp_ev_loop_alloc(struct llarp_ev_loop **ev)
|| (__APPLE__ && __MACH__)
*ev = new llarp_kqueue_loop;
#elif defined(_WIN32) || defined(_WIN64) || defined(__NT__)
*ev = new llarp_win32_loop;
*ev = new llarp_win32_loop;
#else
// TODO: fall back to a generic select-based event loop
#error no event loop subclass

@ -173,24 +173,25 @@ namespace llarp
util::StatusObject
ILinkLayer::ExtractStatus() const
{
std::vector<util::StatusObject> pending, established;
std::transform(m_Pending.begin(), m_Pending.end(), std::back_inserter(pending), [](const auto & item) -> util::StatusObject {
return item.second->ExtractStatus();
});
std::transform(m_AuthedLinks.begin(), m_AuthedLinks.end(), std::back_inserter(established), [](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}
}}
};
std::vector< util::StatusObject > pending, established;
std::transform(m_Pending.begin(), m_Pending.end(),
std::back_inserter(pending),
[](const auto& item) -> util::StatusObject {
return item.second->ExtractStatus();
});
std::transform(m_AuthedLinks.begin(), m_AuthedLinks.end(),
std::back_inserter(established),
[](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}}}};
}
bool

@ -124,7 +124,7 @@ namespace llarp
virtual const char*
Name() const = 0;
util::StatusObject
util::StatusObject
ExtractStatus() const override;
void
@ -180,7 +180,8 @@ namespace llarp
bool
MapAddr(const RouterID& pk, ILinkSession* s);
void Tick(llarp_time_t now);
void
Tick(llarp_time_t now);
LinkMessageHandler HandleMessage;
TimeoutHandler HandleTimeout;

@ -139,7 +139,7 @@ namespace llarp
void
Alive();
util::StatusObject
util::StatusObject
ExtractStatus() const override;
/// base

@ -281,7 +281,7 @@ namespace llarp
using namespace std::placeholders;
if(self->record.work
&& self->record.work->IsValid(
std::bind(&Crypto::shorthash, crypto, _1, _2), now))
std::bind(&Crypto::shorthash, crypto, _1, _2), now))
{
llarp::LogDebug("LRCM extended lifetime by ",
self->record.work->extendedLifetime, " seconds for ",

@ -160,26 +160,24 @@ namespace llarp
IHopHandler*
PathContext::GetByUpstream(const RouterID& remote, const PathID_t& id)
{
auto own = MapGet(
m_OurPaths, id,
[](__attribute__((unused)) const PathSet* s) -> bool {
// TODO: is this right?
return true;
},
[remote, id](PathSet* p) -> IHopHandler* {
return p->GetByUpstream(remote, id);
});
auto own = MapGet(m_OurPaths, id,
[](__attribute__((unused)) const PathSet* s) -> bool {
// TODO: is this right?
return true;
},
[remote, id](PathSet* p) -> IHopHandler* {
return p->GetByUpstream(remote, id);
});
if(own)
return own;
return MapGet(
m_TransitPaths, id,
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
return hop->info.upstream == remote;
},
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
return h.get();
});
return MapGet(m_TransitPaths, id,
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
return hop->info.upstream == remote;
},
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
return h.get();
});
}
bool
@ -196,14 +194,13 @@ namespace llarp
IHopHandler*
PathContext::GetByDownstream(const RouterID& remote, const PathID_t& id)
{
return MapGet(
m_TransitPaths, id,
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
return hop->info.downstream == remote;
},
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
return h.get();
});
return MapGet(m_TransitPaths, id,
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
return hop->info.downstream == remote;
},
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
return h.get();
});
}
PathSet*

@ -2,5 +2,4 @@
namespace llarp
{
} // namespace llarp

@ -41,7 +41,6 @@ namespace llarp
struct AbstractRouter : public util::IStateful
{
virtual void
OnSessionEstablished(RouterContact rc) = 0;
@ -139,12 +138,13 @@ namespace llarp
CheckRenegotiateValid(RouterContact newRc, RouterContact oldRC) = 0;
/// set router's service node whitelist
virtual void
SetRouterWhitelist(const std::vector<RouterID> & routers) =0 ;
virtual void
SetRouterWhitelist(const std::vector< RouterID > &routers) = 0;
/// visit each connected link session
/// visit each connected link session
virtual void
ForEachPeer(std::function<void(const ILinkSession*, bool)> visit) const = 0;
ForEachPeer(
std::function< void(const ILinkSession *, bool) > visit) const = 0;
};
} // namespace llarp

@ -679,9 +679,7 @@ namespace llarp
Router::NumberOfConnectedRouters() const
{
size_t s = 0;
ForEachPeer([&s](const auto *, bool) {
++s;
});
ForEachPeer([&s](const auto *, bool) { ++s; });
return s;
}

@ -141,7 +141,7 @@ namespace llarp
}
void
SetRouterWhitelist(const std::vector<RouterID> & routers) override;
SetRouterWhitelist(const std::vector< RouterID > &routers) override;
exit::Context &
exitContext() override
@ -430,7 +430,8 @@ namespace llarp
RouterID remote, const std::vector< RouterContact > &results) override;
void
ForEachPeer(std::function< void(const ILinkSession *, bool) > visit) const override;
ForEachPeer(
std::function< void(const ILinkSession *, bool) > visit) const override;
void
ForEachPeer(std::function< void(ILinkSession *) > visit);

@ -266,9 +266,7 @@ namespace llarp
auto itr = m_PrefetchedTags.find(tag);
if(itr == m_PrefetchedTags.end())
{
itr = m_PrefetchedTags
.emplace(tag, CachedTagResult(tag, this))
.first;
itr = m_PrefetchedTags.emplace(tag, CachedTagResult(tag, this)).first;
}
for(const auto& introset : itr->second.result)
{
@ -1196,11 +1194,11 @@ namespace llarp
m_SNodeSessions.emplace(
snode,
std::make_unique< exit::SNodeSession >(
snode,
std::bind(&Endpoint::HandleWriteIPPacket, this,
std::placeholders::_1,
[themIP]() -> huint32_t { return themIP; }),
m_Router, 2, numHops));
snode,
std::bind(&Endpoint::HandleWriteIPPacket, this,
std::placeholders::_1,
[themIP]() -> huint32_t { return themIP; }),
m_Router, 2, numHops));
}
}
@ -1310,13 +1308,12 @@ namespace llarp
}
}
// no converstation
return EnsurePathToService(
remote,
[](Address, OutboundContext* c) {
if(c)
c->UpdateIntroSet(true);
},
5000, false);
return EnsurePathToService(remote,
[](Address, OutboundContext* c) {
if(c)
c->UpdateIntroSet(true);
},
5000, false);
}
bool

@ -134,7 +134,8 @@ namespace llarp
Verify(Crypto* c, const ServiceInfo& from) const;
bool
HandleMessage(routing::IMessageHandler* h, AbstractRouter* r) const override;
HandleMessage(routing::IMessageHandler* h,
AbstractRouter* r) const override;
};
} // namespace service
} // namespace llarp

@ -125,7 +125,9 @@ struct llarp_buffer_t
writef(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
;
#else
bool writef(const char *fmt, ...) __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 2, 3)));
bool
writef(const char *fmt, ...)
__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 3)));
;
#endif

@ -71,7 +71,7 @@ namespace llarp
/// an entity that has a status that can be extracted
struct IStateful
{
virtual ~IStateful() {};
virtual ~IStateful(){};
virtual StatusObject
ExtractStatus() const = 0;

@ -16,8 +16,8 @@ struct llarp_threadpool
std::queue< std::function< void(void) > > jobs;
llarp_threadpool(int workers, const char *name)
: impl(
std::make_unique< llarp::thread::ThreadPool >(workers, workers * 128))
: impl(std::make_unique< llarp::thread::ThreadPool >(workers,
workers * 128))
{
(void)name;
}

Loading…
Cancel
Save