finish converting to shared_ptr

pull/576/head
Jeff Becker 5 years ago
parent 8484e29c9b
commit 6711296b26
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -186,8 +186,8 @@ main(int argc, char *argv[])
// does this file exist?
if(genconfigOnly)
{
if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(), overWrite,
asRouter))
if(!llarp_ensure_config(conffname.c_str(), basedir.string().c_str(),
overWrite, asRouter))
return 1;
}
else

@ -25,8 +25,7 @@ namespace llarp
{
}
void
BaseSession::HandlePathDied(path::Path_ptr)
void BaseSession::HandlePathDied(path::Path_ptr)
{
}
@ -135,8 +134,9 @@ namespace llarp
{
if(success)
{
auto self = shared_from_this();
for(auto& f : m_PendingCallbacks)
f(this);
f(self);
}
else
{
@ -161,6 +161,7 @@ namespace llarp
}
};
ForEachPath(sendExitClose);
router->pathContext().RemovePathSet(shared_from_this());
return llarp::path::Builder::Stop();
}

@ -15,10 +15,13 @@ namespace llarp
{
struct BaseSession;
using SessionReadyFunc = std::function< void(BaseSession*) >;
using BaseSession_ptr = std::shared_ptr< BaseSession >;
using SessionReadyFunc = std::function< void(BaseSession_ptr) >;
/// a persisting exit session with an exit router
struct BaseSession : public llarp::path::Builder
struct BaseSession : public llarp::path::Builder,
public std::enable_shared_from_this< BaseSession >
{
static constexpr size_t MaxUpstreamQueueLength = 256;
static constexpr llarp_time_t LifeSpan = 60 * 10 * 1000;
@ -29,6 +32,12 @@ namespace llarp
virtual ~BaseSession();
std::shared_ptr< path::PathSet >
GetSelf() override
{
return shared_from_this();
}
util::StatusObject
ExtractStatus() const;

@ -552,14 +552,13 @@ namespace llarp
huint32_t ip = GetIPForIdent(pubKey);
if(m_SNodeKeys.emplace(pubKey).second)
{
// this is a new service node make an outbound session to them
m_SNodeSessions.emplace(
other,
std::unique_ptr< exit::SNodeSession >(new exit::SNodeSession(
auto session = std::make_shared< exit::SNodeSession >(
other,
std::bind(&ExitEndpoint::QueueSNodePacket, this,
std::placeholders::_1, ip),
GetRouter(), 2, 1, true)));
GetRouter(), 2, 1, true);
// this is a new service node make an outbound session to them
m_SNodeSessions.emplace(other, session);
}
return ip;
}
@ -625,9 +624,12 @@ namespace llarp
if(itr->second->IsExpired(now))
itr = m_SNodeSessions.erase(itr);
else
{
itr->second->Tick(now);
++itr;
}
}
}
{
// expire
auto itr = m_ActiveExits.begin();

@ -147,7 +147,7 @@ namespace llarp
SNodes_t m_SNodeKeys;
using SNodeSessions_t =
std::unordered_map< RouterID, std::unique_ptr< exit::SNodeSession >,
std::unordered_map< RouterID, std::shared_ptr< exit::SNodeSession >,
RouterID::Hash >;
/// snode sessions we are talking to directly
SNodeSessions_t m_SNodeSessions;

@ -7,7 +7,9 @@ namespace llarp
{
namespace handlers
{
struct NullEndpoint final : public llarp::service::Endpoint
struct NullEndpoint final
: public llarp::service::Endpoint,
public std::enable_shared_from_this< NullEndpoint >
{
NullEndpoint(const std::string &name, AbstractRouter *r,
llarp::service::Context *parent)
@ -20,6 +22,12 @@ namespace llarp
return true;
}
path::PathSet_ptr
GetSelf() override
{
return shared_from_this();
}
huint32_t
ObtainIPForAddr(const AlignedBuffer< 32 > &, bool) override
{

@ -102,11 +102,11 @@ namespace llarp
llarp::LogError(Name(), " bad exit router key: ", v);
return false;
}
m_Exit.reset(new llarp::exit::ExitSession(
m_Exit = std::make_shared< llarp::exit::ExitSession >(
exitRouter,
std::bind(&TunEndpoint::QueueInboundPacketForExit, this,
std::placeholders::_1),
router, m_NumPaths, numHops));
router, m_NumPaths, numHops);
llarp::LogInfo(Name(), " using exit at ", exitRouter);
}
if(k == "local-dns")
@ -349,10 +349,10 @@ namespace llarp
else if(addr.FromString(qname, ".snode"))
{
dns::Message *replyMsg = new dns::Message(std::move(msg));
EnsurePathToSNode(addr.as_array(),
[=](const RouterID &remote, exit::BaseSession *s) {
SendDNSReply(remote, s, replyMsg, reply, true,
isV6);
EnsurePathToSNode(
addr.as_array(),
[=](const RouterID &remote, exit::BaseSession_ptr s) {
SendDNSReply(remote, s, replyMsg, reply, true, isV6);
});
return true;
}
@ -580,7 +580,10 @@ namespace llarp
// call tun code in endpoint logic in case of network isolation
// EndpointLogic()->queue_job({this, handleTickTun});
if(m_Exit)
{
EnsureRouterIsKnown(m_Exit->Endpoint());
m_Exit->Tick(now);
}
Endpoint::Tick(now);
}

@ -20,12 +20,20 @@ namespace llarp
static const char DefaultTunDstAddr[] = "10.10.0.1";
static const char DefaultTunSrcAddr[] = "10.10.0.2";
struct TunEndpoint : public service::Endpoint, public dns::IQueryHandler
struct TunEndpoint : public service::Endpoint,
public dns::IQueryHandler,
public std::enable_shared_from_this< TunEndpoint >
{
TunEndpoint(const std::string& nickname, AbstractRouter* r,
llarp::service::Context* parent);
~TunEndpoint();
path::PathSet_ptr
GetSelf() override
{
return shared_from_this();
}
virtual bool
SetOption(const std::string& k, const std::string& v) override;
@ -198,7 +206,7 @@ namespace llarp
template < typename Addr_t, typename Endpoint_t >
void
SendDNSReply(Addr_t addr, Endpoint_t* ctx, dns::Message* query,
SendDNSReply(Addr_t addr, Endpoint_t ctx, dns::Message* query,
std::function< void(dns::Message) > reply, bool snode,
bool sendIPv6)
{

@ -269,6 +269,7 @@ namespace llarp
void
PathContext::ExpirePaths(llarp_time_t now)
{
{
util::Lock lock(&m_TransitPaths.first);
auto& map = m_TransitPaths.second;
@ -282,33 +283,16 @@ namespace llarp
else
++itr;
}
for(auto& builder : m_PathBuilders)
{
if(builder)
builder->ExpirePaths(now);
}
}
void
PathContext::BuildPaths(llarp_time_t now)
{
for(auto& builder : m_PathBuilders)
{
if(builder->ShouldBuildMore(now))
util::Lock lock(&m_OurPaths.first);
auto& map = m_OurPaths.second;
for(auto& item : map)
{
builder->BuildOne();
item.second->ExpirePaths(now);
}
}
}
void
PathContext::TickPaths(llarp_time_t now)
{
for(auto& builder : m_PathBuilders)
builder->Tick(now, m_Router);
}
routing::MessageHandler_ptr
PathContext::GetHandler(const PathID_t& id)
{
@ -334,12 +318,6 @@ namespace llarp
return nullptr;
}
void
PathContext::AddPathBuilder(Builder_ptr ctx)
{
m_PathBuilders.emplace_back(ctx);
}
void
PathContext::RemovePathSet(PathSet_ptr set)
{
@ -355,13 +333,6 @@ namespace llarp
}
}
void
PathContext::RemovePathBuilder(Builder_ptr ctx)
{
m_PathBuilders.remove(ctx);
RemovePathSet(ctx);
}
std::ostream&
TransitHop::print(std::ostream& stream, int level, int spaces) const
{

@ -303,7 +303,9 @@ namespace llarp
};
/// A path we made
struct Path : public IHopHandler, public routing::IMessageHandler, public std::enable_shared_from_this<Path>
struct Path : public IHopHandler,
public routing::IMessageHandler,
public std::enable_shared_from_this< Path >
{
using BuildResultHookFunc = std::function< void(Path_ptr) >;
using CheckForDeadFunc = std::function< bool(Path_ptr, llarp_time_t) >;
@ -579,19 +581,6 @@ namespace llarp
void
ExpirePaths(llarp_time_t now);
/// called from router tick function
/// builds all paths we need to build at current tick
void
BuildPaths(llarp_time_t now);
/// called from router tick function
void
TickPaths(llarp_time_t now);
/// track a path builder with this context
void
AddPathBuilder(Builder_ptr set);
void
AllowTransit();
@ -644,9 +633,6 @@ namespace llarp
void
AddOwnPath(PathSet_ptr set, Path_ptr p);
void
RemovePathBuilder(Builder_ptr ctx);
void
RemovePathSet(PathSet_ptr set);
@ -689,9 +675,7 @@ namespace llarp
private:
AbstractRouter* m_Router;
SyncTransitMap_t m_TransitPaths;
SyncTransitMap_t m_Paths;
SyncOwnedPathsMap_t m_OurPaths;
std::list< Builder_ptr > m_PathBuilders;
bool m_AllowTransit;
};
} // namespace path

@ -16,7 +16,7 @@ namespace llarp
struct AsyncPathKeyExchangeContext
{
typedef path::Path_ptr Path_t;
typedef path::Builder_ptr PathSet_t;
typedef path::PathSet_ptr PathSet_t;
PathSet_t pathset = nullptr;
Path_t path = nullptr;
typedef std::function< void(AsyncPathKeyExchangeContext< User >*) > Handler;
@ -79,7 +79,6 @@ namespace llarp
else
{
hop.upstream = ctx->path->hops[ctx->idx].rc.pubkey;
if(ctx->pathset->ShouldBundleRC())
record.nextRC =
std::make_unique< RouterContact >(ctx->path->hops[ctx->idx].rc);
}
@ -166,8 +165,6 @@ namespace llarp
else
LogError(ctx->pathset->Name(), " failed to send LRCM to ", remote);
}
// decrement keygen counter
ctx->pathset->keygens--;
}
namespace path
@ -176,21 +173,27 @@ namespace llarp
size_t pathNum, size_t hops)
: path::PathSet(pathNum), router(p_router), dht(p_dht), numHops(hops)
{
p_router->pathContext().AddPathBuilder(shared_from_this());
p_router->crypto()->encryption_keygen(enckey);
_run.store(true);
keygens.store(0);
}
Builder::~Builder()
{
}
void
Builder::Tick(llarp_time_t now)
{
ExpirePaths(now);
if(ShouldBuildMore(now))
BuildOne();
TickPaths(now, router);
}
util::StatusObject
Builder::ExtractStatus() const
{
util::StatusObject obj{{"keygens", uint64_t(keygens.load())},
{"numHops", uint64_t(numHops)},
util::StatusObject obj{{"numHops", uint64_t(numHops)},
{"numPaths", uint64_t(m_NumPaths)}};
std::vector< util::StatusObject > pathObjs;
std::transform(m_Paths.begin(), m_Paths.end(),
@ -243,7 +246,6 @@ namespace llarp
Builder::Stop()
{
_run.store(false);
router->pathContext().RemovePathBuilder(shared_from_this());
return true;
}
@ -256,9 +258,7 @@ namespace llarp
bool
Builder::ShouldRemove() const
{
if(!IsStopped())
return false;
return keygens.load() > 0;
return IsStopped();
}
const SecretKey&
@ -337,10 +337,10 @@ namespace llarp
AsyncPathKeyExchangeContext< Builder >* ctx =
new AsyncPathKeyExchangeContext< Builder >(router->crypto());
ctx->router = router;
ctx->pathset = shared_from_this();
ctx->pathset = GetSelf();
auto path = std::make_shared< path::Path >(hops, this, roles);
path->SetBuildResultHook([this](Path_ptr p) { this->HandlePathBuilt(p); });
++keygens;
path->SetBuildResultHook(
[this](Path_ptr p) { this->HandlePathBuilt(p); });
ctx->AsyncGenerateKeys(path, router->logic(), router->threadpool(), this,
&PathBuilderKeysGenerated);
}

@ -15,7 +15,7 @@ namespace llarp
// milliseconds waiting between builds on a path
constexpr llarp_time_t MIN_PATH_BUILD_INTERVAL = 1000;
struct Builder : public PathSet, std::enable_shared_from_this<Builder> // yes private scope
struct Builder : public PathSet
{
protected:
/// flag for PathSet::Stop()
@ -29,9 +29,6 @@ namespace llarp
llarp_time_t lastBuild = 0;
llarp_time_t buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
// how many keygens are currently happening
std::atomic< uint8_t > keygens;
/// construct
Builder(AbstractRouter* p_router, llarp_dht_context* p_dht,
size_t numPaths, size_t numHops);
@ -75,8 +72,11 @@ namespace llarp
llarp_time_t
Now() const override;
virtual void
Tick(llarp_time_t now) override;
void
BuildOne(PathRole roles = ePathRoleAny);
BuildOne(PathRole roles = ePathRoleAny) override;
void
Build(const std::vector< RouterContact >& hops,

@ -61,7 +61,7 @@ namespace llarp
}
void
PathSet::Tick(llarp_time_t now, AbstractRouter* r)
PathSet::TickPaths(llarp_time_t now, AbstractRouter* r)
{
Lock_t l(&m_PathsMutex);
for(auto& item : m_Paths)

@ -58,6 +58,10 @@ namespace llarp
using Path_ptr = std::shared_ptr< Path >;
struct PathSet;
using PathSet_ptr = std::shared_ptr< PathSet >;
/// a set of paths owned by an entity
struct PathSet
{
@ -65,9 +69,16 @@ namespace llarp
/// @params numPaths the number of paths to maintain
PathSet(size_t numPaths);
/// get a shared_ptr of ourself
virtual PathSet_ptr
GetSelf() = 0;
virtual void
BuildOne(PathRole roles = ePathRoleAny) = 0;
/// tick owned paths
void
Tick(llarp_time_t now, AbstractRouter* r);
virtual void
Tick(llarp_time_t now) = 0;
/// count the number of paths that will exist at this timestamp in future
size_t
@ -209,6 +220,9 @@ namespace llarp
protected:
size_t m_NumPaths;
void
TickPaths(llarp_time_t now, AbstractRouter* r);
void
ForEachPath(std::function< void(const Path_ptr&) > visit) const
{
@ -233,13 +247,12 @@ namespace llarp
};
using Mtx_t = util::NullMutex;
using Lock_t = util::NullLock;
using PathMap_t = std::unordered_map< PathInfo_t, Path_ptr, PathInfoHash >;
using PathMap_t =
std::unordered_map< PathInfo_t, Path_ptr, PathInfoHash >;
mutable Mtx_t m_PathsMutex;
PathMap_t m_Paths;
};
using PathSet_ptr = std::shared_ptr<PathSet>;
} // namespace path
} // namespace llarp

@ -1073,7 +1073,9 @@ namespace llarp
ServiceNodeLookupRouterWhenExpired(remote);
return;
}
_hiddenServiceContext.ForEachService([=](const std::string &, const std::shared_ptr<service::Endpoint> & ep) -> bool {
_hiddenServiceContext.ForEachService(
[=](const std::string &,
const std::shared_ptr< service::Endpoint > &ep) -> bool {
return !ep->LookupRouterAnon(remote);
});
}
@ -1125,7 +1127,7 @@ namespace llarp
return !IsBootstrapNode(rc.pubkey);
});
}
paths.TickPaths(now);
// expire transit paths
paths.ExpirePaths(now);
{
@ -1183,9 +1185,10 @@ namespace llarp
}
if(!IsServiceNode())
{
_hiddenServiceContext.Tick(now);
}
paths.BuildPaths(now);
_exitContext.Tick(now);
if(rpcCaller)
rpcCaller->Tick(now);

@ -102,7 +102,8 @@ namespace llarp
expired.emplace_back(rc.pubkey);
return true;
});
ForEachService([&](const std::string &, const std::shared_ptr<Endpoint> &ep) -> bool {
ForEachService([&](const std::string &,
const std::shared_ptr< Endpoint > &ep) -> bool {
// TODO: we need to stop looking up service nodes that are gone forever
// how do?
for(const auto &k : expired)
@ -198,22 +199,30 @@ namespace llarp
keyfile = option.second;
}
std::unique_ptr< service::Endpoint > service;
service::Endpoint_ptr service;
static std::map<
std::string,
std::function< std::unique_ptr< service::Endpoint >(
std::function< service::Endpoint_ptr(
const std::string &, AbstractRouter *, service::Context *) > >
endpointConstructors = {
{"tun",
[](const std::string &nick, AbstractRouter *r,
service::Context *c) -> std::unique_ptr< service::Endpoint > {
return std::make_unique< handlers::TunEndpoint >(nick, r, c);
service::Context *c) -> service::Endpoint_ptr {
return std::make_shared< handlers::TunEndpoint >(nick, r, c);
}},
{"ios-tun",
[](const std::string &nick, AbstractRouter *r,
service::Context *c) -> service::Endpoint_ptr {
return nullptr;
/// SOOOOOOON (tm)
// return std::make_shared<handlers::IOSTunEndpoint>(nick, r,
// c);
}},
{"null",
[](const std::string &nick, AbstractRouter *r,
service::Context *c) -> std::unique_ptr< service::Endpoint > {
return std::make_unique< handlers::NullEndpoint >(nick, r, c);
service::Context *c) -> service::Endpoint_ptr {
return std::make_shared< handlers::NullEndpoint >(nick, r, c);
}}};
{
@ -227,7 +236,8 @@ namespace llarp
// construct
service = itr->second(conf.first, m_Router, this);
if(service)
{
// if ephemeral, then we need to regen key
// if privkey file, then set it and load it
if(keyfile != "")
@ -239,6 +249,9 @@ namespace llarp
service->LoadKeyFile(); // only start endpoint not tun
// now Name() will be correct
}
}
if(service == nullptr)
return false;
// configure
for(const auto &option : conf.second)
{
@ -259,7 +272,7 @@ namespace llarp
if(service->Start())
{
LogInfo("autostarting hidden service endpoint ", service->Name());
m_Endpoints.emplace(conf.first, std::move(service));
m_Endpoints.emplace(conf.first, service);
return true;
}
LogError("failed to start hidden service endpoint ", conf.first);
@ -268,7 +281,7 @@ namespace llarp
else
{
LogInfo("added hidden service endpoint ", service->Name());
m_Endpoints.emplace(conf.first, std::move(service));
m_Endpoints.emplace(conf.first, service);
return true;
}
}

@ -31,15 +31,14 @@ namespace llarp
bool
hasEndpoints();
bool
FindBestAddressFor(const AlignedBuffer< 32 > &addr, bool isSNode,
huint32_t &);
/// function visitor returns false to prematurely break iteration
void
ForEachService(std::function< bool(const std::string &,
const Endpoint_ptr &) >
ForEachService(
std::function< bool(const std::string &, const Endpoint_ptr &) >
visit) const;
/// add default endpoint with options

@ -240,6 +240,7 @@ namespace llarp
void
Endpoint::Tick(llarp_time_t now)
{
path::Builder::Tick(now);
// publish descriptors
if(ShouldPublishDescriptors(now))
{
@ -256,7 +257,8 @@ namespace llarp
auto itr = m_SNodeSessions.begin();
while(itr != m_SNodeSessions.end())
{
if(itr->second->ShouldRemove() && itr->second->IsStopped())
itr->second->Tick(now);
if(itr->second->ShouldRemove())
{
itr = m_SNodeSessions.erase(itr);
continue;
@ -362,6 +364,7 @@ namespace llarp
auto itr = m_DeadSessions.begin();
while(itr != m_DeadSessions.end())
{
itr->second->Tick(now);
if(itr->second->IsDone(now))
itr = m_DeadSessions.erase(itr);
else
@ -373,16 +376,19 @@ namespace llarp
auto itr = m_RemoteSessions.begin();
while(itr != m_RemoteSessions.end())
{
if(itr->second->Tick(now))
if(itr->second->Pump(now))
{
itr->second->Stop();
m_DeadSessions.emplace(itr->first, std::move(itr->second));
itr = m_RemoteSessions.erase(itr);
}
else
{
itr->second->Tick(now);
++itr;
}
}
}
// expire convotags
{
auto itr = m_Sessions.begin();
@ -797,7 +803,7 @@ namespace llarp
}
auto it = m_RemoteSessions.emplace(
addr, std::make_unique< OutboundContext >(introset, this));
addr, std::make_shared< OutboundContext >(introset, this));
LogInfo("Created New outbound context for ", addr.ToString());
// inform pending
@ -879,7 +885,8 @@ namespace llarp
}
bool
Endpoint::HandleDataDrop(path::Path_ptr p, const PathID_t& dst, uint64_t seq)
Endpoint::HandleDataDrop(path::Path_ptr p, const PathID_t& dst,
uint64_t seq)
{
LogWarn(Name(), " message ", seq, " dropped by endpoint ", p->Endpoint(),
" via ", dst);
@ -964,7 +971,8 @@ namespace llarp
return true;
}
if(!frame.AsyncDecryptAndVerify(EndpointLogic(), GetCrypto(), p,
CryptoWorker(), m_Identity, m_DataHandler))
CryptoWorker(), m_Identity,
m_DataHandler))
{
// send discard
@ -974,17 +982,15 @@ namespace llarp
f.F = p->intro.pathID;
if(!f.Sign(GetCrypto(), m_Identity))
return false;
auto d = std::make_shared<const routing::PathTransferMessage>(f, frame.F);
RouterLogic()->queue_func([=]() {
p->SendRoutingMessage(*d, router);
});
auto d =
std::make_shared< const routing::PathTransferMessage >(f, frame.F);
RouterLogic()->queue_func([=]() { p->SendRoutingMessage(*d, router); });
return true;
}
return true;
}
void
Endpoint::HandlePathDied(path::Path_ptr)
void Endpoint::HandlePathDied(path::Path_ptr)
{
RegenAndPublishIntroSet(Now(), true);
}
@ -1074,20 +1080,19 @@ namespace llarp
if(m_SNodeSessions.count(snode) == 0)
{
auto themIP = ObtainIPForAddr(snode, true);
m_SNodeSessions.emplace(
snode,
std::make_unique< exit::SNodeSession >(
auto session = std::make_shared< exit::SNodeSession >(
snode,
std::bind(&Endpoint::HandleWriteIPPacket, this, _1,
[themIP]() -> huint32_t { return themIP; }),
m_Router, 2, numHops));
m_Router, 2, numHops);
m_SNodeSessions.emplace(snode, session);
}
auto range = m_SNodeSessions.equal_range(snode);
auto itr = range.first;
while(itr != range.second)
{
if(itr->second->IsReady())
h(snode, itr->second.get());
h(snode, itr->second);
else
itr->second->AddReadyHook(std::bind(h, snode, _1));
++itr;
@ -1178,9 +1183,8 @@ namespace llarp
}
LogDebug(Name(), " send ", data.sz, " via ", remoteIntro.router);
auto router = Router();
RouterLogic()->queue_func([=]() {
p->SendRoutingMessage(*transfer, router);
});
RouterLogic()->queue_func(
[=]() { p->SendRoutingMessage(*transfer, router); });
return true;
}
}

@ -66,7 +66,7 @@ namespace llarp
SetOption(const std::string& k, const std::string& v);
virtual void
Tick(llarp_time_t now);
Tick(llarp_time_t now) override;
/// return true if we have a resolvable ip address
virtual bool
@ -92,14 +92,14 @@ namespace llarp
Logic*
EndpointLogic();
/// borrow endpoint's net loop for sending data to user on local network interface
/// borrow endpoint's net loop for sending data to user on local network
/// interface
llarp_ev_loop_ptr
EndpointNetLoop();
Crypto*
GetCrypto();
/// crypto worker threadpool
llarp_threadpool*
CryptoWorker();
@ -239,7 +239,7 @@ namespace llarp
uint64_t timeoutMS, bool lookupOnRandomPath = false);
using SNodeEnsureHook =
std::function< void(RouterID, exit::BaseSession*) >;
std::function< void(RouterID, exit::BaseSession_ptr) >;
/// ensure a path to a service node by public key
void
@ -346,7 +346,7 @@ namespace llarp
protected:
IDataHandler* m_DataHandler = nullptr;
Identity m_Identity;
std::unique_ptr< exit::BaseSession > m_Exit;
std::shared_ptr< exit::BaseSession > m_Exit;
hooks::Backend_ptr m_OnUp;
hooks::Backend_ptr m_OnDown;
hooks::Backend_ptr m_OnReady;
@ -367,14 +367,14 @@ namespace llarp
PendingTraffic m_PendingTraffic;
using Sessions =
std::unordered_multimap< Address, std::unique_ptr< OutboundContext >,
std::unordered_multimap< Address, std::shared_ptr< OutboundContext >,
Address::Hash >;
Sessions m_RemoteSessions;
Sessions m_DeadSessions;
using SNodeSessions = std::unordered_multimap<
RouterID, std::unique_ptr< exit::BaseSession >, RouterID::Hash >;
RouterID, std::shared_ptr< exit::BaseSession >, RouterID::Hash >;
SNodeSessions m_SNodeSessions;

@ -26,9 +26,7 @@ namespace llarp
if(!msg)
return false;
endpoint = path->Endpoint();
r->logic()->queue_func([=]() {
path->SendRoutingMessage(*msg, r);
});
r->logic()->queue_func([=]() { path->SendRoutingMessage(*msg, r); });
return true;
}
} // namespace service

@ -274,7 +274,7 @@ namespace llarp
}
bool
OutboundContext::Tick(llarp_time_t now)
OutboundContext::Pump(llarp_time_t now)
{
// we are probably dead af
if(m_LookupFails > 16 || m_BuildFails > 10)

@ -15,7 +15,10 @@ namespace llarp
struct Endpoint;
/// context needed to initiate an outbound hidden service session
struct OutboundContext : public path::Builder, public SendContext
struct OutboundContext
: public path::Builder,
public SendContext,
public std::enable_shared_from_this< OutboundContext >
{
OutboundContext(const IntroSet& introSet, Endpoint* parent);
~OutboundContext();
@ -26,6 +29,12 @@ namespace llarp
bool
ShouldBundleRC() const override;
path::PathSet_ptr
GetSelf() override
{
return shared_from_this();
}
bool
Stop() override;
@ -54,10 +63,10 @@ namespace llarp
bool
ShouldBuildMore(llarp_time_t now) const override;
/// tick internal state
/// pump internal state
/// return true to mark as dead
bool
Tick(llarp_time_t now);
Pump(llarp_time_t now);
/// return true if it's safe to remove ourselves
bool

Loading…
Cancel
Save