Browse Source

disconnect established session if clock skew detected

pull/1879/head
orignal 2 years ago
parent
commit
ac94341203
  1. 12
      libi2pd/NTCP2.cpp
  2. 1
      libi2pd/SSU2Session.cpp

12
libi2pd/NTCP2.cpp

@ -884,8 +884,20 @@ namespace transport
switch (blk) switch (blk)
{ {
case eNTCP2BlkDateTime: case eNTCP2BlkDateTime:
{
LogPrint (eLogDebug, "NTCP2: Datetime"); LogPrint (eLogDebug, "NTCP2: Datetime");
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; break;
}
case eNTCP2BlkOptions: case eNTCP2BlkOptions:
LogPrint (eLogDebug, "NTCP2: Options"); LogPrint (eLogDebug, "NTCP2: Options");
break; break;

1
libi2pd/SSU2Session.cpp

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

Loading…
Cancel
Save