make format

pull/269/head
Ryan Tharp 5 years ago
parent fefb012bf8
commit 4bf4faa956

@ -23,7 +23,9 @@ namespace llarp
{
namespace dht
{
AbstractContext::~AbstractContext() {}
AbstractContext::~AbstractContext()
{
}
Context::Context() : router(nullptr), allowTransit(false)
{

@ -31,17 +31,16 @@ namespace llarp
/// on behalf of whoasked request introset for target from dht router with
/// key askpeer
virtual void
LookupIntroSetRecursive(const service::Address& target,
const Key_t& whoasked, uint64_t whoaskedTX,
const Key_t& askpeer, uint64_t R,
service::IntroSetLookupHandler result = nullptr) = 0;
LookupIntroSetRecursive(
const service::Address& target, const Key_t& whoasked,
uint64_t whoaskedTX, const Key_t& askpeer, uint64_t R,
service::IntroSetLookupHandler result = nullptr) = 0;
virtual void
LookupIntroSetIterative(const service::Address& target,
const Key_t& whoasked, uint64_t whoaskedTX,
const Key_t& askpeer,
service::IntroSetLookupHandler result = nullptr) = 0;
LookupIntroSetIterative(
const service::Address& target, const Key_t& whoasked,
uint64_t whoaskedTX, const Key_t& askpeer,
service::IntroSetLookupHandler result = nullptr) = 0;
virtual std::set< service::IntroSet >
FindRandomIntroSetsWithTagExcluding(
@ -63,7 +62,8 @@ namespace llarp
virtual const Key_t&
OurKey() const = 0;
virtual Bucket< RCNode >* Nodes() const = 0;
virtual Bucket< RCNode >*
Nodes() const = 0;
};
struct Context final : public AbstractContext
@ -80,16 +80,16 @@ namespace llarp
/// on behalf of whoasked request introset for target from dht router with
/// key askpeer
void
LookupIntroSetRecursive(const service::Address& target,
const Key_t& whoasked, uint64_t whoaskedTX,
const Key_t& askpeer, uint64_t R,
service::IntroSetLookupHandler result = nullptr) override;
LookupIntroSetRecursive(
const service::Address& target, const Key_t& whoasked,
uint64_t whoaskedTX, const Key_t& askpeer, uint64_t R,
service::IntroSetLookupHandler result = nullptr) override;
void
LookupIntroSetIterative(const service::Address& target,
const Key_t& whoasked, uint64_t whoaskedTX,
const Key_t& askpeer,
service::IntroSetLookupHandler result = nullptr) override;
LookupIntroSetIterative(
const service::Address& target, const Key_t& whoasked,
uint64_t whoaskedTX, const Key_t& askpeer,
service::IntroSetLookupHandler result = nullptr) override;
/// on behalf of whoasked request router with public key target from dht
/// router with key askpeer
@ -141,7 +141,8 @@ namespace llarp
/// send a dht message to peer, if keepalive is true then keep the session
/// with that peer alive for 10 seconds
void
DHTSendTo(const RouterID& peer, IMessage* msg, bool keepalive = true) override;
DHTSendTo(const RouterID& peer, IMessage* msg,
bool keepalive = true) override;
/// get routers closest to target excluding requester
bool
@ -198,7 +199,11 @@ namespace llarp
std::unique_ptr< Bucket< ISNode > > services;
bool allowTransit;
Bucket< RCNode >* Nodes() const override { return nodes.get(); }
Bucket< RCNode >*
Nodes() const override
{
return nodes.get();
}
const Key_t&
OurKey() const override
@ -207,7 +212,10 @@ namespace llarp
}
llarp::Router*
GetRouter() const override { return router; }
GetRouter() const override
{
return router;
}
TXHolder< service::Address, service::IntroSet, service::Address::Hash >
pendingIntrosetLookups;

@ -11,7 +11,8 @@ namespace llarp
namespace dht
{
LocalRouterLookup::LocalRouterLookup(const PathID_t &path, uint64_t txid,
const RouterID &target, AbstractContext *ctx)
const RouterID &target,
AbstractContext *ctx)
: RecursiveRouterLookup(TXOwner{ctx->OurKey(), txid}, target, ctx,
nullptr)
, localPath(path)

@ -14,7 +14,8 @@ namespace llarp
PathID_t localPath;
LocalServiceAddressLookup(const PathID_t &pathid, uint64_t txid,
const service::Address &addr, AbstractContext *ctx,
const service::Address &addr,
AbstractContext *ctx,
__attribute__((unused)) const Key_t &askpeer);
void

@ -10,7 +10,8 @@ namespace llarp
namespace dht
{
LocalTagLookup::LocalTagLookup(const PathID_t &path, uint64_t txid,
const service::Tag &target, AbstractContext *ctx)
const service::Tag &target,
AbstractContext *ctx)
: TagLookup(TXOwner{ctx->OurKey(), txid}, target, ctx, 0)
, localPath(path)
{

@ -12,7 +12,7 @@ namespace llarp
}
bool
FindIntroMessage::DecodeKey(const llarp_buffer_t &k, llarp_buffer_t* val)
FindIntroMessage::DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* val)
{
bool read = false;

@ -51,7 +51,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
bool
HandleMessage(

@ -31,7 +31,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(

@ -40,7 +40,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(

@ -38,7 +38,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(

@ -15,7 +15,8 @@ namespace llarp
}
bool
PublishIntroMessage::DecodeKey(const llarp_buffer_t &key, llarp_buffer_t *val)
PublishIntroMessage::DecodeKey(const llarp_buffer_t &key,
llarp_buffer_t *val)
{
bool read = false;
if(llarp_buffer_eq(key, "E"))

@ -35,7 +35,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(

@ -9,8 +9,9 @@ namespace llarp
namespace dht
{
ServiceAddressLookup::ServiceAddressLookup(
const TXOwner &asker, const service::Address &addr, AbstractContext *ctx,
uint64_t r, service::IntroSetLookupHandler handler)
const TXOwner &asker, const service::Address &addr,
AbstractContext *ctx, uint64_t r,
service::IntroSetLookupHandler handler)
: TX< service::Address, service::IntroSet >(asker, addr, ctx)
, handleResult(handler)
, R(r)

@ -12,8 +12,8 @@ namespace llarp
struct TagLookup : public TX< service::Tag, service::IntroSet >
{
uint64_t R;
TagLookup(const TXOwner &asker, const service::Tag &tag, AbstractContext *ctx,
uint64_t r)
TagLookup(const TXOwner &asker, const service::Tag &tag,
AbstractContext *ctx, uint64_t r)
: TX< service::Tag, service::IntroSet >(asker, tag, ctx), R(r)
{
}

@ -7,7 +7,7 @@ namespace llarp
{
namespace dns
{
constexpr uint16_t qTypeAAAA = 28;
constexpr uint16_t qTypeAAAA = 28;
constexpr uint16_t qTypeTXT = 16;
constexpr uint16_t qTypeMX = 15;
constexpr uint16_t qTypePTR = 12;

@ -114,7 +114,7 @@ namespace llarp
ObtainServiceNodeIP(const RouterID& router);
bool
QueueSNodePacket(const llarp_buffer_t & buf, huint32_t from);
QueueSNodePacket(const llarp_buffer_t& buf, huint32_t from);
void
MarkIPActive(huint32_t ip);

@ -1057,8 +1057,7 @@ namespace llarp
llarp_buffer_t out(rxFragBody);
// decrypt
if(!Crypto()->xchacha20_alt(out, in, rxKey,
ptr + FragmentHashSize))
if(!Crypto()->xchacha20_alt(out, in, rxKey, ptr + FragmentHashSize))
{
llarp::LogError("failed to decrypt message from ", remoteAddr);
return false;
@ -1083,8 +1082,7 @@ namespace llarp
llarp::LogError("failed to read the rest of the header");
return false;
}
if(length
> (out.sz - (out.cur - out.base)))
if(length > (out.sz - (out.cur - out.base)))
{
// too big length
llarp::LogError("fragment body too big");

@ -18,7 +18,7 @@ namespace llarp
~DHTMessage();
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const override;

@ -19,7 +19,7 @@ namespace llarp
std::vector< std::unique_ptr< llarp::dht::IMessage > > msgs;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
BEncode(llarp_buffer_t* buf) const override;

@ -53,7 +53,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
@ -86,7 +86,7 @@ namespace llarp
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
@ -140,7 +140,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
@ -182,7 +182,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
@ -217,7 +217,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;

@ -19,7 +19,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;

@ -17,7 +17,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
void
Clear() override

@ -25,7 +25,7 @@ namespace llarp
~PathTransferMessage();
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const override;

@ -21,7 +21,7 @@ namespace llarp
~RelayUpstreamMessage();
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
BEncode(llarp_buffer_t* buf) const override;
@ -43,7 +43,7 @@ namespace llarp
~RelayDownstreamMessage();
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
BEncode(llarp_buffer_t* buf) const override;

@ -279,11 +279,12 @@ namespace llarp
return;
}
// generate hash of hop key for nonce mutation
crypto->shorthash(self->hop->nonceXOR, llarp_buffer_t(self->hop->pathKey));
crypto->shorthash(self->hop->nonceXOR,
llarp_buffer_t(self->hop->pathKey));
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 ",

@ -68,7 +68,7 @@ namespace llarp
}
bool
ExitInfo::DecodeKey(const llarp_buffer_t &k, llarp_buffer_t* buf)
ExitInfo::DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* buf)
{
bool read = false;
if(!BEncodeMaybeReadDictEntry("k", pubkey, read, k, buf))

@ -23,8 +23,8 @@ namespace llarp
struct in6_addr netmask;
PubKey pubkey;
ExitInfo(const PubKey &pk, const nuint32_t &ipv4_exit) : IBEncodeMessage(),
pubkey(pk)
ExitInfo(const PubKey &pk, const nuint32_t &ipv4_exit)
: IBEncodeMessage(), pubkey(pk)
{
memset(address.s6_addr, 0, 16);
address.s6_addr[11] = 0xff;
@ -37,8 +37,8 @@ namespace llarp
{
}
ExitInfo(const ExitInfo &other) : IBEncodeMessage(other.version),
pubkey(other.pubkey)
ExitInfo(const ExitInfo &other)
: IBEncodeMessage(other.version), pubkey(other.pubkey)
{
memcpy(address.s6_addr, other.address.s6_addr, 16);
memcpy(netmask.s6_addr, other.netmask.s6_addr, 16);

@ -155,26 +155,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
@ -191,14 +189,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*

@ -21,7 +21,7 @@ namespace llarp
IsValid(shorthash_func hashfunc, llarp_time_t now) const;
bool
DecodeKey(const llarp_buffer_t &k, llarp_buffer_t* val) override;
DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const override;

@ -26,7 +26,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &k, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* buf) override;
bool
IsGood(uint64_t chances) const;
@ -55,7 +55,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &k, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* buf) override;
bool
Load(const char* fname);

@ -191,7 +191,7 @@ namespace llarp
};
using RouterLookupHandler =
std::function< void(const std::vector< RouterContact >&) >;
std::function< void(const std::vector< RouterContact > &) >;
} // namespace llarp
#endif

@ -11,7 +11,7 @@ namespace llarp
}
bool
DHTMessage::DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val)
DHTMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val)
{
llarp::dht::Key_t from;
from.Zero();

@ -18,7 +18,8 @@ namespace llarp
}
bool
PathConfirmMessage::DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val)
PathConfirmMessage::DecodeKey(const llarp_buffer_t& key,
llarp_buffer_t* val)
{
bool read = false;
if(!BEncodeMaybeReadDictInt("L", pathLifetime, read, key, val))

@ -10,7 +10,8 @@ namespace llarp
}
bool
PathLatencyMessage::DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val)
PathLatencyMessage::DecodeKey(const llarp_buffer_t& key,
llarp_buffer_t* val)
{
bool read = false;
if(!BEncodeMaybeReadDictInt("L", L, read, key, val))

@ -16,7 +16,8 @@ namespace llarp
}
bool
PathTransferMessage::DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* val)
PathTransferMessage::DecodeKey(const llarp_buffer_t& key,
llarp_buffer_t* val)
{
bool read = false;
if(!BEncodeMaybeReadDictEntry("P", P, read, key, val))

@ -9,7 +9,7 @@ namespace llarp
}
bool
Introduction::DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf)
Introduction::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf)
{
bool read = false;
if(!BEncodeMaybeReadDictEntry("k", router, read, key, buf))

@ -56,7 +56,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
void
Clear();

@ -149,7 +149,7 @@ namespace llarp
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t* buf) override;
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
bool
Verify(llarp::Crypto* crypto, llarp_time_t now) const;

@ -34,7 +34,7 @@ namespace llarp
static size_t
Base32DecodeSize(size_t sz)
{
return DecodeSize<5, 8>(sz);
return DecodeSize< 5, 8 >(sz);
}
template < typename Stack, typename V >

Loading…
Cancel
Save