Browse Source

resend RouterInfo after some interval

pull/1634/head
orignal 4 years ago
parent
commit
7e4c33d27e
  1. 9
      libi2pd/NTCP2.cpp
  2. 3
      libi2pd/NTCP2.h

9
libi2pd/NTCP2.cpp

@ -343,6 +343,8 @@ namespace transport @@ -343,6 +343,8 @@ namespace transport
else
LogPrint (eLogWarning, "NTCP2: Missing NTCP2 parameters");
}
m_NextRouterInfoResendTime = i2p::util::GetSecondsSinceEpoch () + NTCP2_ROUTERINFO_RESEND_INTERVAL +
rand ()%NTCP2_ROUTERINFO_RESEND_INTERVAL_THRESHOLD;
}
NTCP2Session::~NTCP2Session ()
@ -1012,6 +1014,13 @@ namespace transport @@ -1012,6 +1014,13 @@ namespace transport
m_NumSentBytes += bytes_transferred;
i2p::transport::transports.UpdateSentBytes (bytes_transferred);
LogPrint (eLogDebug, "NTCP2: Next frame sent ", bytes_transferred);
if (m_LastActivityTimestamp > m_NextRouterInfoResendTime)
{
m_NextRouterInfoResendTime += NTCP2_ROUTERINFO_RESEND_INTERVAL +
rand ()%NTCP2_ROUTERINFO_RESEND_INTERVAL_THRESHOLD;
SendRouterInfo ();
}
else
SendQueue ();
}
}

3
libi2pd/NTCP2.h

@ -34,6 +34,8 @@ namespace transport @@ -34,6 +34,8 @@ namespace transport
const int NTCP2_ESTABLISH_TIMEOUT = 10; // 10 seconds
const int NTCP2_TERMINATION_TIMEOUT = 120; // 2 minutes
const int NTCP2_TERMINATION_CHECK_TIMEOUT = 30; // 30 seconds
const int NTCP2_ROUTERINFO_RESEND_INTERVAL = 25*60; // 25 minuntes in seconds
const int NTCP2_ROUTERINFO_RESEND_INTERVAL_THRESHOLD = 25*60; // 25 minuntes
const int NTCP2_CLOCK_SKEW = 60; // in seconds
const int NTCP2_MAX_OUTGOING_QUEUE_SIZE = 500; // how many messages we can queue up
@ -212,6 +214,7 @@ namespace transport @@ -212,6 +214,7 @@ namespace transport
bool m_IsSending;
std::list<std::shared_ptr<I2NPMessage> > m_SendQueue;
uint64_t m_NextRouterInfoResendTime; // seconds since epoch
};
class NTCP2Server: private i2p::util::RunnableServiceWithWork

Loading…
Cancel
Save