Add CSteamNetworkingSockets::GetTimeSecure()

We override this method in the Steam implementation, so we don't have #ifdefs in the base class.
This commit is contained in:
Fletcher Dunn
2019-02-05 13:20:43 -08:00
parent 05f98ddf36
commit fbf3d55f00
3 changed files with 12 additions and 17 deletions
@@ -358,6 +358,12 @@ bool CSteamNetworkingSockets::BHasAnyListenSockets() const
return false;
}
time_t CSteamNetworkingSockets::GetTimeSecure()
{
// Trusting local user's clock!
return time(nullptr);
}
bool CSteamNetworkingSockets::GetIdentity( SteamNetworkingIdentity *pIdentity )
{
SteamDatagramTransportLock scopeLock;
@@ -4,6 +4,7 @@
#define CSTEAMNETWORKINGSOCKETS_H
#pragma once
#include <time.h>
#include <steam/steamnetworkingsockets.h>
#include <steam/isteamnetworkingutils.h>
@@ -53,6 +54,10 @@ public:
virtual void CacheIdentity() = 0;
#endif
// Get current time of day, ideally from a source that
// doesn't depend on the user setting their local clock properly
virtual time_t GetTimeSecure();
const SteamNetworkingIdentity &InternalGetIdentity()
{
if ( m_identity.IsInvalid() )
@@ -7,10 +7,6 @@
#include "steamnetworkingsockets_lowlevel.h"
#include "csteamnetworkingsockets.h"
#include "crypto.h"
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
#include <steam/steam_gameserver.h>
#include "csteamnetworkingsockets_steam.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -124,7 +120,6 @@ CSteamNetworkingMessage *CSteamNetworkingMessage::New( CSteamNetworkConnectionBa
pMsg->m_usecTimeReceived = usecNow;
pMsg->m_nMessageNumber = nMsgNum;
pMsg->m_pfnFreeData = CSteamNetworkingMessage::DefaultFreeData;
return pMsg;
}
@@ -863,18 +858,7 @@ bool CSteamNetworkConnectionBase::BRecvCryptoHandshake( const CMsgSteamDatagramC
return false;
}
long rtNow = time( nullptr );
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
auto *pSteamNetworkingSocketsSteamBase = assert_cast<CSteamNetworkingSocketsSteamBase *>( m_pSteamNetworkingSocketsInterface );
if ( pSteamNetworkingSocketsSteamBase->m_pSteamUtils )
{
rtNow = pSteamNetworkingSocketsSteamBase->m_pSteamUtils->GetServerRealTime();
}
else
{
AssertMsg( false, "No ISteamUtils? Using local clock to check if cert expired!" );
}
#endif
long rtNow = m_pSteamNetworkingSocketsInterface->GetTimeSecure();
// Make sure hasn't expired. All signed certs without an expiry should be considered invalid!
// For unsigned certs, there's no point in checking the expiry, since anybody who wanted