mirror of https://github.com/oxen-io/lokinet
* add establish fail enum
* dont call outbound session hooks for inbound sessions
This commit is contained in:
parent
e3281cd026
commit
75451d7124
|
@ -17,7 +17,8 @@ namespace llarp
|
|||
Timeout,
|
||||
RouterNotFound,
|
||||
InvalidRouter,
|
||||
NoLink
|
||||
NoLink,
|
||||
EstablishFail
|
||||
};
|
||||
|
||||
inline std::ostream&
|
||||
|
@ -35,6 +36,8 @@ namespace llarp
|
|||
return out << "invalid router";
|
||||
case SessionResult::RouterNotFound:
|
||||
return out << "not found";
|
||||
case SessionResult::EstablishFail:
|
||||
return out << "establish failed";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ namespace llarp
|
|||
OutboundSessionMaker::OnSessionEstablished(ILinkSession* session)
|
||||
{
|
||||
// TODO: do we want to keep it
|
||||
|
||||
const RouterContact rc = session->GetRemoteRC();
|
||||
const auto router = RouterID(session->GetPubKey());
|
||||
const bool isOutbound = not session->IsInbound();
|
||||
const std::string remoteType = session->GetRemoteRC().IsPublicRouter() ? "router" : "client";
|
||||
const std::string remoteType = rc.IsPublicRouter() ? "router" : "client";
|
||||
LogInfo(
|
||||
"session with ", remoteType, " [", router, "] ", isOutbound ? "established" : "received");
|
||||
|
||||
|
@ -48,9 +48,12 @@ namespace llarp
|
|||
return false;
|
||||
}
|
||||
|
||||
work([this, rc = session->GetRemoteRC()] { VerifyRC(rc); });
|
||||
|
||||
return true;
|
||||
if (isOutbound)
|
||||
{
|
||||
work([this, rc] { VerifyRC(rc); });
|
||||
return true;
|
||||
}
|
||||
return _rcLookup->CheckRC(rc);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -204,12 +207,10 @@ namespace llarp
|
|||
}
|
||||
|
||||
const auto& job = itr->second;
|
||||
if (!job->link->TryEstablishTo(job->rc))
|
||||
if (not job->link->TryEstablishTo(job->rc))
|
||||
{
|
||||
// TODO: maybe different failure type?
|
||||
|
||||
l.unlock();
|
||||
FinalizeRequest(router, SessionResult::NoLink);
|
||||
FinalizeRequest(router, SessionResult::EstablishFail);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +230,7 @@ namespace llarp
|
|||
|
||||
LinkLayer_ptr link = _linkManager->GetCompatibleLink(rc);
|
||||
|
||||
if (!link)
|
||||
if (not link)
|
||||
{
|
||||
l.unlock();
|
||||
FinalizeRequest(router, SessionResult::NoLink);
|
||||
|
|
Loading…
Reference in New Issue