disconnect established session if clock skew detected

This commit is contained in:
orignal 2023-02-10 11:48:11 -05:00
parent 234540f9e7
commit ac94341203
2 changed files with 14 additions and 1 deletions

View File

@ -884,8 +884,20 @@ namespace transport
switch (blk)
{
case eNTCP2BlkDateTime:
{
LogPrint (eLogDebug, "NTCP2: Datetime");
break;
if (m_IsEstablished)
{
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
uint64_t tsA = bufbe32toh (frame + offset);
if (tsA < ts - NTCP2_CLOCK_SKEW || tsA > ts + NTCP2_CLOCK_SKEW)
{
LogPrint (eLogWarning, "NTCP2: Established session time difference ", (int)(ts - tsA), " exceeds clock skew");
SendTerminationAndTerminate (eNTCP2ClockSkew);
}
}
break;
}
case eNTCP2BlkOptions:
LogPrint (eLogDebug, "NTCP2: Options");
break;

View File

@ -1617,6 +1617,7 @@ namespace transport
{
case eSSU2SessionStateSessionRequestReceived:
case eSSU2SessionStateTokenRequestReceived:
case eSSU2SessionStateEstablished:
if (std::abs (offset) > SSU2_CLOCK_SKEW)
m_TerminationReason = eSSU2TerminationReasonClockSkew;
break;