Browse Source

don't send RouterInfo twice

pull/1223/head
orignal 6 years ago
parent
commit
86782aeb1b
  1. 7
      libi2pd/NTCP2.cpp
  2. 2
      libi2pd/NTCP2.h
  3. 1
      libi2pd/TransportSession.h
  4. 11
      libi2pd/Transports.cpp

7
libi2pd/NTCP2.cpp

@ -644,7 +644,6 @@ namespace transport @@ -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 @@ -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)

2
libi2pd/NTCP2.h

@ -120,6 +120,8 @@ namespace transport @@ -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:

1
libi2pd/TransportSession.h

@ -79,6 +79,7 @@ namespace transport @@ -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:

11
libi2pd/Transports.cpp

@ -401,7 +401,7 @@ namespace transport @@ -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 @@ -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 @@ -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 @@ -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…
Cancel
Save