Skip to content

Commit

Permalink
reply with CANT_REACH_PEER if connect to outselves
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Jan 10, 2024
1 parent dfe8b25 commit cd08756
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions libi2pd_client/SAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,20 @@ namespace client
{
if (addr->IsIdentHash ())
{
auto leaseSet = session->GetLocalDestination ()->FindLeaseSet(addr->identHash);
if (leaseSet)
Connect(leaseSet, session);
else
{
session->GetLocalDestination ()->RequestDestination(addr->identHash,
std::bind(&SAMSocket::HandleConnectLeaseSetRequestComplete,
shared_from_this(), std::placeholders::_1));
if (session->GetLocalDestination ()->GetIdentHash () != addr->identHash)
{
auto leaseSet = session->GetLocalDestination ()->FindLeaseSet(addr->identHash);
if (leaseSet)
Connect(leaseSet, session);
else
{
session->GetLocalDestination ()->RequestDestination(addr->identHash,
std::bind(&SAMSocket::HandleConnectLeaseSetRequestComplete,
shared_from_this(), std::placeholders::_1));
}
}
else
SendStreamCantReachPeer ("Can't connect to myself");
}
else // B33
session->GetLocalDestination ()->RequestDestinationWithEncryptedLeaseSet (addr->blindedPublicKey,
Expand Down

0 comments on commit cd08756

Please sign in to comment.