mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-23 17:34:21 +00:00
don't send RouterInfo twice
This commit is contained in:
parent
49a44fc92e
commit
86782aeb1b
@ -644,7 +644,6 @@ namespace transport
|
||||
SetRemoteIdentity (existing ? existing->GetRouterIdentity () : ri.GetRouterIdentity ());
|
||||
m_Server.AddNTCP2Session (shared_from_this ());
|
||||
Established ();
|
||||
SendRouterInfo ();
|
||||
ReceiveLength ();
|
||||
}
|
||||
else
|
||||
@ -919,6 +918,12 @@ namespace transport
|
||||
SendQueue ();
|
||||
}
|
||||
|
||||
void NTCP2Session::SendLocalRouterInfo ()
|
||||
{
|
||||
if (!IsOutgoing ()) // we send it in SessionConfirmed
|
||||
SendRouterInfo ();
|
||||
}
|
||||
|
||||
NTCP2Server::NTCP2Server ():
|
||||
m_IsRunning (false), m_Thread (nullptr), m_Work (m_Service),
|
||||
m_TerminationTimer (m_Service)
|
||||
|
@ -120,6 +120,8 @@ namespace transport
|
||||
|
||||
void ClientLogin (); // Alice
|
||||
void ServerLogin (); // Bob
|
||||
|
||||
void SendLocalRouterInfo (); // after handshake
|
||||
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
|
||||
|
||||
private:
|
||||
|
@ -79,6 +79,7 @@ namespace transport
|
||||
bool IsTerminationTimeoutExpired (uint64_t ts) const
|
||||
{ return ts >= m_LastActivityTimestamp + GetTerminationTimeout (); };
|
||||
|
||||
virtual void SendLocalRouterInfo () { SendI2NPMessages ({ CreateDatabaseStoreMsg () }); };
|
||||
virtual void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -401,7 +401,7 @@ namespace transport
|
||||
{
|
||||
if (peer.router) // we have RI already
|
||||
{
|
||||
if (!peer.numAttempts) // NTCP
|
||||
if (!peer.numAttempts) // NTCP2
|
||||
{
|
||||
peer.numAttempts++;
|
||||
if (m_NTCP2Server) // we support NTCP2
|
||||
@ -415,7 +415,10 @@ namespace transport
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// otherwise NTCP1
|
||||
}
|
||||
if (peer.numAttempts == 1) // NTCP1
|
||||
{
|
||||
peer.numAttempts++;
|
||||
auto address = peer.router->GetNTCPAddress (!context.SupportsV6 ());
|
||||
if (address && m_NTCPServer)
|
||||
{
|
||||
@ -473,7 +476,7 @@ namespace transport
|
||||
else
|
||||
LogPrint (eLogDebug, "Transports: NTCP address is not present for ", i2p::data::GetIdentHashAbbreviation (ident), ", trying SSU");
|
||||
}
|
||||
if (peer.numAttempts == 1)// SSU
|
||||
if (peer.numAttempts == 2)// SSU
|
||||
{
|
||||
peer.numAttempts++;
|
||||
if (m_SSUServer && peer.router->IsSSU (!context.SupportsV6 ()))
|
||||
@ -736,7 +739,7 @@ namespace transport
|
||||
sendDatabaseStore = false; // we have it in the list already
|
||||
}
|
||||
if (sendDatabaseStore)
|
||||
session->SendI2NPMessages ({ CreateDatabaseStoreMsg () });
|
||||
session->SendLocalRouterInfo ();
|
||||
else
|
||||
session->SetTerminationTimeout (10); // most likely it's publishing, no follow-up messages expected, set timeout to 10 seconds
|
||||
it->second.sessions.push_back (session);
|
||||
|
Loading…
x
Reference in New Issue
Block a user