mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-08-27 10:40:23 +01:00
lookup LeaseSet before sending ping
This commit is contained in:
parent
5dadecba03
commit
a2073a8751
2 changed files with 65 additions and 33 deletions
|
@ -823,6 +823,43 @@ namespace client
|
||||||
SendReplyError ("No local destination");
|
SendReplyError ("No local destination");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (addr->IsIdentHash ())
|
||||||
|
{
|
||||||
|
// we might have leaseset already
|
||||||
|
auto leaseSet = localDestination->FindLeaseSet (addr->identHash);
|
||||||
|
if (leaseSet)
|
||||||
|
{
|
||||||
|
boost::asio::post (localDestination->GetService (),
|
||||||
|
std::bind (&BOBCommandSession::SendPing, shared_from_this (), leaseSet));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// request LeaseSet
|
||||||
|
if (addr->IsIdentHash ())
|
||||||
|
localDestination->RequestDestination (addr->identHash,
|
||||||
|
std::bind (&BOBCommandSession::SendPing, shared_from_this (), std::placeholders::_1));
|
||||||
|
else
|
||||||
|
localDestination->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey,
|
||||||
|
std::bind (&BOBCommandSession::SendPing, shared_from_this (), std::placeholders::_1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SendReplyError ("empty ping address");
|
||||||
|
}
|
||||||
|
|
||||||
|
void BOBCommandSession::SendPing (std::shared_ptr<const i2p::data::LeaseSet> ls)
|
||||||
|
{
|
||||||
|
if (!ls)
|
||||||
|
{
|
||||||
|
SendReplyError ("LeaseSet Not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto localDestination = (m_CurrentDestination && m_CurrentDestination->IsRunning ()) ?
|
||||||
|
m_CurrentDestination->GetLocalDestination () : i2p::client::context.GetSharedLocalDestination ();
|
||||||
|
if (!localDestination)
|
||||||
|
{
|
||||||
|
SendReplyError ("No local destination");
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto streamingDestination = localDestination->GetStreamingDestination ();
|
auto streamingDestination = localDestination->GetStreamingDestination ();
|
||||||
if (!streamingDestination)
|
if (!streamingDestination)
|
||||||
{
|
{
|
||||||
|
@ -853,14 +890,7 @@ namespace client
|
||||||
else
|
else
|
||||||
s->SendReplyOK ({"pong: time=", std::to_string (t), " ms"});
|
s->SendReplyOK ({"pong: time=", std::to_string (t), " ms"});
|
||||||
});
|
});
|
||||||
|
streamingDestination->SendPing (ls);
|
||||||
if (addr->IsIdentHash ())
|
|
||||||
localDestination->SendPing (addr->identHash);
|
|
||||||
else
|
|
||||||
localDestination->SendPing (addr->blindedPublicKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SendReplyError ("empty ping address");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOBCommandSession::ClearCommandHandler (const char * operand, size_t len)
|
void BOBCommandSession::ClearCommandHandler (const char * operand, size_t len)
|
||||||
|
|
|
@ -261,6 +261,8 @@ namespace client
|
||||||
|
|
||||||
void BuildStatusLine(bool currentTunnel, std::shared_ptr<BOBDestination> destination, std::string &out);
|
void BuildStatusLine(bool currentTunnel, std::shared_ptr<BOBDestination> destination, std::string &out);
|
||||||
|
|
||||||
|
void SendPing (std::shared_ptr<const i2p::data::LeaseSet> ls);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
BOBCommandChannel& m_Owner;
|
BOBCommandChannel& m_Owner;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue