make bundling rc in path builds configurable on runtime

pull/531/head
Jeff Becker 5 years ago
parent 94eb37d490
commit 57dc6cc965
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -32,6 +32,13 @@ namespace llarp
util::StatusObject util::StatusObject
ExtractStatus() const override; ExtractStatus() const override;
bool
ShouldBundleRC() const override
{
// TODO: make configurable
return false;
}
void void
HandlePathDied(llarp::path::Path* p) override; HandlePathDied(llarp::path::Path* p) override;

@ -54,6 +54,7 @@ namespace llarp
// current hop // current hop
auto& hop = ctx->path->hops[ctx->idx]; auto& hop = ctx->path->hops[ctx->idx];
auto& frame = ctx->LRCM.frames[ctx->idx]; auto& frame = ctx->LRCM.frames[ctx->idx];
// generate key // generate key
ctx->crypto->encryption_keygen(hop.commkey); ctx->crypto->encryption_keygen(hop.commkey);
hop.nonce.Randomize(); hop.nonce.Randomize();
@ -80,8 +81,9 @@ namespace llarp
else else
{ {
hop.upstream = ctx->path->hops[ctx->idx].rc.pubkey; hop.upstream = ctx->path->hops[ctx->idx].rc.pubkey;
record.nextRC = if(ctx->pathset->ShouldBundleRC())
std::make_unique< RouterContact >(ctx->path->hops[ctx->idx].rc); record.nextRC =
std::make_unique< RouterContact >(ctx->path->hops[ctx->idx].rc);
} }
// build record // build record

@ -48,6 +48,10 @@ namespace llarp
virtual bool virtual bool
ShouldBuildMore(llarp_time_t now) const override; ShouldBuildMore(llarp_time_t now) const override;
/// should we bundle RCs in builds?
virtual bool
ShouldBundleRC() const = 0;
/// return true if we hit our soft limit for building paths too fast /// return true if we hit our soft limit for building paths too fast
bool bool
BuildCooldownHit(llarp_time_t now) const; BuildCooldownHit(llarp_time_t now) const;

@ -390,7 +390,7 @@ namespace llarp
EnsureEncryptionKey(); EnsureEncryptionKey();
bool bool
ConnectionToRouterAllowed(const RouterID &router) const; ConnectionToRouterAllowed(const RouterID &router) const override;
bool bool
SaveRC(); SaveRC();

@ -12,7 +12,7 @@
#include <router/abstractrouter.hpp> #include <router/abstractrouter.hpp>
#include <service/protocol.hpp> #include <service/protocol.hpp>
#include <util/logic.hpp> #include <util/logic.hpp>
#include <util/str.hpp>
#include <util/buffer.hpp> #include <util/buffer.hpp>
namespace llarp namespace llarp
@ -57,6 +57,10 @@ namespace llarp
if(val > 0) if(val > 0)
m_MinPathLatency = val; m_MinPathLatency = val;
} }
if(k == "bundle-rc")
{
m_BundleRC = IsTrueValue(v.c_str());
}
return true; return true;
} }
@ -812,6 +816,12 @@ namespace llarp
self->m_IsolatedLogic); self->m_IsolatedLogic);
} }
bool
Endpoint::ShouldBundleRC() const
{
return m_BundleRC;
}
void void
Endpoint::PutNewOutboundContext(const llarp::service::IntroSet& introset) Endpoint::PutNewOutboundContext(const llarp::service::IntroSet& introset)
{ {

@ -214,6 +214,9 @@ namespace llarp
using PendingBufferQueue = std::queue< PendingBuffer >; using PendingBufferQueue = std::queue< PendingBuffer >;
bool
ShouldBundleRC() const override;
struct SendContext struct SendContext
{ {
SendContext(const ServiceInfo& ident, const Introduction& intro, SendContext(const ServiceInfo& ident, const Introduction& intro,
@ -280,6 +283,12 @@ namespace llarp
util::StatusObject util::StatusObject
ExtractStatus() const override; ExtractStatus() const override;
bool
ShouldBundleRC() const override
{
return m_Endpoint->ShouldBundleRC();
}
bool bool
Stop() override; Stop() override;
@ -494,6 +503,7 @@ namespace llarp
std::string m_Keyfile; std::string m_Keyfile;
std::string m_Name; std::string m_Name;
std::string m_NetNS; std::string m_NetNS;
bool m_BundleRC = false;
using PendingTraffic = using PendingTraffic =
std::unordered_map< Address, PendingBufferQueue, Address::Hash >; std::unordered_map< Address, PendingBufferQueue, Address::Hash >;

Loading…
Cancel
Save