MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / HandleDateTime

Method HandleDateTime

libi2pd/SSU2Session.cpp:1914–1949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1912 }
1913
1914 void SSU2Session::HandleDateTime (const uint8_t * buf, size_t len)
1915 {
1916 int64_t offset = (int64_t)i2p::util::GetSecondsSinceEpoch () - (int64_t)bufbe32toh (buf);
1917 switch (m_State)
1918 {
1919 case eSSU2SessionStateSessionRequestReceived:
1920 case eSSU2SessionStateTokenRequestReceived:
1921 case eSSU2SessionStateEstablished:
1922 if (std::abs (offset) > SSU2_CLOCK_SKEW)
1923 m_TerminationReason = eSSU2TerminationReasonClockSkew;
1924 break;
1925 case eSSU2SessionStateSessionCreatedReceived:
1926 case eSSU2SessionStateTokenReceived:
1927 if ((m_RemoteEndpoint.address ().is_v4 () && i2p::context.GetTesting ()) ||
1928 (m_RemoteEndpoint.address ().is_v6 () && i2p::context.GetTestingV6 ()))
1929 {
1930 if (m_Server.IsSyncClockFromPeers ())
1931 {
1932 if (std::abs (offset) > SSU2_CLOCK_THRESHOLD)
1933 {
1934 LogPrint (eLogWarning, "SSU2: Time offset ", offset, " from ", m_RemoteEndpoint);
1935 m_Server.AdjustTimeOffset (-offset, GetRemoteIdentity ());
1936 }
1937 else
1938 m_Server.AdjustTimeOffset (0, nullptr);
1939 }
1940 else if (std::abs (offset) > SSU2_CLOCK_SKEW)
1941 {
1942 LogPrint (eLogError, "SSU2: Clock skew detected ", offset, ". Check your clock");
1943 i2p::context.SetError (eRouterErrorClockSkew);
1944 }
1945 }
1946 break;
1947 default: ;
1948 };
1949 }
1950
1951 void SSU2Session::HandleRouterInfo (const uint8_t * buf, size_t len)
1952 {

Callers

nothing calls this directly

Calls 8

GetSecondsSinceEpochFunction · 0.85
bufbe32tohFunction · 0.85
LogPrintFunction · 0.85
GetTestingMethod · 0.80
GetTestingV6Method · 0.80
IsSyncClockFromPeersMethod · 0.80
AdjustTimeOffsetMethod · 0.80
SetErrorMethod · 0.80

Tested by

no test coverage detected