|
|
@ -25,10 +25,10 @@ namespace llarp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Path::Path(
|
|
|
|
Path::Path(
|
|
|
|
const std::vector<RouterContact>& h,
|
|
|
|
const std::vector<RouterContact>& h,
|
|
|
|
PathSet* parent,
|
|
|
|
std::weak_ptr<PathSet> pathset,
|
|
|
|
PathRole startingRoles,
|
|
|
|
PathRole startingRoles,
|
|
|
|
std::string shortName)
|
|
|
|
std::string shortName)
|
|
|
|
: m_PathSet(parent), _role(startingRoles), m_shortName(std::move(shortName))
|
|
|
|
: m_PathSet{pathset}, _role{startingRoles}, m_shortName{std::move(shortName)}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hops.resize(h.size());
|
|
|
|
hops.resize(h.size());
|
|
|
@ -54,7 +54,7 @@ namespace llarp
|
|
|
|
// initialize parts of the introduction
|
|
|
|
// initialize parts of the introduction
|
|
|
|
intro.router = hops[hsz - 1].rc.pubkey;
|
|
|
|
intro.router = hops[hsz - 1].rc.pubkey;
|
|
|
|
intro.pathID = hops[hsz - 1].txID;
|
|
|
|
intro.pathID = hops[hsz - 1].txID;
|
|
|
|
if (parent)
|
|
|
|
if (auto parent = m_PathSet.lock())
|
|
|
|
EnterState(ePathBuilding, parent->Now());
|
|
|
|
EnterState(ePathBuilding, parent->Now());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -253,7 +253,10 @@ namespace llarp
|
|
|
|
edge = *failedAt;
|
|
|
|
edge = *failedAt;
|
|
|
|
r->loop()->call([r, self = shared_from_this(), edge]() {
|
|
|
|
r->loop()->call([r, self = shared_from_this(), edge]() {
|
|
|
|
self->EnterState(ePathFailed, r->Now());
|
|
|
|
self->EnterState(ePathFailed, r->Now());
|
|
|
|
self->m_PathSet->HandlePathBuildFailedAt(self, edge);
|
|
|
|
if (auto parent = self->m_PathSet.lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
parent->HandlePathBuildFailedAt(self, edge);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -272,7 +275,10 @@ namespace llarp
|
|
|
|
if (st == ePathExpired && _status == ePathBuilding)
|
|
|
|
if (st == ePathExpired && _status == ePathBuilding)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_status = st;
|
|
|
|
_status = st;
|
|
|
|
m_PathSet->HandlePathBuildTimeout(shared_from_this());
|
|
|
|
if (auto parent = m_PathSet.lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
parent->HandlePathBuildTimeout(shared_from_this());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (st == ePathBuilding)
|
|
|
|
else if (st == ePathBuilding)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -287,7 +293,10 @@ namespace llarp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LogInfo("path ", Name(), " died");
|
|
|
|
LogInfo("path ", Name(), " died");
|
|
|
|
_status = st;
|
|
|
|
_status = st;
|
|
|
|
m_PathSet->HandlePathDied(shared_from_this());
|
|
|
|
if (auto parent = m_PathSet.lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
parent->HandlePathDied(shared_from_this());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (st == ePathEstablished && _status == ePathTimeout)
|
|
|
|
else if (st == ePathEstablished && _status == ePathTimeout)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -370,12 +379,15 @@ namespace llarp
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
Path::Rebuild()
|
|
|
|
Path::Rebuild()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (auto parent = m_PathSet.lock())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::vector<RouterContact> newHops;
|
|
|
|
std::vector<RouterContact> newHops;
|
|
|
|
for (const auto& hop : hops)
|
|
|
|
for (const auto& hop : hops)
|
|
|
|
newHops.emplace_back(hop.rc);
|
|
|
|
newHops.emplace_back(hop.rc);
|
|
|
|
LogInfo(Name(), " rebuilding on ", ShortName());
|
|
|
|
LogInfo(Name(), " rebuilding on ", ShortName());
|
|
|
|
m_PathSet->Build(newHops);
|
|
|
|
parent->Build(newHops);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
@ -681,9 +693,13 @@ namespace llarp
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
Path::HandleHiddenServiceFrame(const service::ProtocolFrame& frame)
|
|
|
|
Path::HandleHiddenServiceFrame(const service::ProtocolFrame& frame)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MarkActive(m_PathSet->Now());
|
|
|
|
if (auto parent = m_PathSet.lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MarkActive(parent->Now());
|
|
|
|
return m_DataHandler && m_DataHandler(shared_from_this(), frame);
|
|
|
|
return m_DataHandler && m_DataHandler(shared_from_this(), frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Samples_t>
|
|
|
|
template <typename Samples_t>
|
|
|
|
static llarp_time_t
|
|
|
|
static llarp_time_t
|
|
|
|