mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
check if address is still introducer before trying to introduce
This commit is contained in:
parent
f125936b2e
commit
ff8941af71
|
@ -784,10 +784,14 @@ namespace transport
|
||||||
{
|
{
|
||||||
auto it1 = m_SessionsByRouterHash.find (it.iH);
|
auto it1 = m_SessionsByRouterHash.find (it.iH);
|
||||||
if (it1 != m_SessionsByRouterHash.end ())
|
if (it1 != m_SessionsByRouterHash.end ())
|
||||||
|
{
|
||||||
|
auto addr = it1->second->GetAddress ();
|
||||||
|
if (addr && addr->IsIntroducer ())
|
||||||
{
|
{
|
||||||
it1->second->Introduce (session, it.iTag);
|
it1->second->Introduce (session, it.iTag);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
indices.push_back(i);
|
indices.push_back(i);
|
||||||
}
|
}
|
||||||
|
@ -815,12 +819,12 @@ namespace transport
|
||||||
{
|
{
|
||||||
relayTag = introducer.iTag;
|
relayTag = introducer.iTag;
|
||||||
addr = address->IsV6 () ? r->GetSSU2V6Address () : r->GetSSU2V4Address ();
|
addr = address->IsV6 () ? r->GetSSU2V6Address () : r->GetSSU2V4Address ();
|
||||||
if (addr && !addr->host.is_unspecified () && addr->port &&
|
if (addr && addr->IsIntroducer () && !addr->host.is_unspecified () && addr->port &&
|
||||||
!i2p::transport::transports.IsInReservedRange(addr->host))
|
!i2p::transport::transports.IsInReservedRange(addr->host))
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// address is invalid try another SSU2 address if exists
|
// address is invalid or not intrudcer, try another SSU2 address if exists
|
||||||
if (address->IsV4 ())
|
if (address->IsV4 ())
|
||||||
{
|
{
|
||||||
if (i2p::context.SupportsV6 ())
|
if (i2p::context.SupportsV6 ())
|
||||||
|
@ -831,7 +835,7 @@ namespace transport
|
||||||
if (i2p::context.SupportsV4 ())
|
if (i2p::context.SupportsV4 ())
|
||||||
addr = r->GetSSU2V4Address ();
|
addr = r->GetSSU2V4Address ();
|
||||||
}
|
}
|
||||||
if (addr && !addr->host.is_unspecified () && addr->port &&
|
if (addr && addr->IsIntroducer () && !addr->host.is_unspecified () && addr->port &&
|
||||||
!i2p::transport::transports.IsInReservedRange(addr->host))
|
!i2p::transport::transports.IsInReservedRange(addr->host))
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1125,6 +1125,13 @@ namespace transport
|
||||||
LogPrint (eLogError, "SSU2: RouterInfo in SessionConfirmed is from future for ", (ri->GetTimestamp () - ts)/1000LL, " seconds");
|
LogPrint (eLogError, "SSU2: RouterInfo in SessionConfirmed is from future for ", (ri->GetTimestamp () - ts)/1000LL, " seconds");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// update RouterInfo in netdb
|
||||||
|
ri = i2p::data::netdb.AddRouterInfo (ri->GetBuffer (), ri->GetBufferLen ()); // ri points to one from netdb now
|
||||||
|
if (!ri)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "SSU2: Couldn't update RouterInfo from SessionConfirmed in netdb");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
m_Address = m_RemoteEndpoint.address ().is_v6 () ? ri->GetSSU2V6Address () : ri->GetSSU2V4Address ();
|
m_Address = m_RemoteEndpoint.address ().is_v6 () ? ri->GetSSU2V6Address () : ri->GetSSU2V4Address ();
|
||||||
if (!m_Address || memcmp (S, m_Address->s, 32))
|
if (!m_Address || memcmp (S, m_Address->s, 32))
|
||||||
{
|
{
|
||||||
|
@ -1139,13 +1146,6 @@ namespace transport
|
||||||
" and actual endpoint ", m_RemoteEndpoint.address (), " from ", i2p::data::GetIdentHashAbbreviation (ri->GetIdentHash ()));
|
" and actual endpoint ", m_RemoteEndpoint.address (), " from ", i2p::data::GetIdentHashAbbreviation (ri->GetIdentHash ()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// update RouterInfo in netdb
|
|
||||||
ri = i2p::data::netdb.AddRouterInfo (ri->GetBuffer (), ri->GetBufferLen ()); // ri points to one from netdb now
|
|
||||||
if (!ri)
|
|
||||||
{
|
|
||||||
LogPrint (eLogError, "SSU2: Couldn't update RouterInfo from SessionConfirmed in netdb");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SetRemoteIdentity (ri->GetRouterIdentity ());
|
SetRemoteIdentity (ri->GetRouterIdentity ());
|
||||||
AdjustMaxPayloadSize ();
|
AdjustMaxPayloadSize ();
|
||||||
m_Server.AddSessionByRouterHash (shared_from_this ()); // we know remote router now
|
m_Server.AddSessionByRouterHash (shared_from_this ()); // we know remote router now
|
||||||
|
|
Loading…
Reference in a new issue