feat(Core/Time): Implement saparated manager for game time (#8630)

This commit is contained in:
Kargatum 2022-01-24 17:55:00 +07:00 committed by GitHub
parent 12da792a90
commit 8b7df23f06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
129 changed files with 1147 additions and 817 deletions

View file

@ -1,9 +1,22 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TOTP.h"
#include "Timer.h"
#include <openssl/evp.h>
#include <openssl/hmac.h>
@ -34,7 +47,7 @@ static constexpr uint32 HMAC_RESULT_SIZE = 20;
/*static*/ bool Acore::Crypto::TOTP::ValidateToken(Secret const& secret, uint32 token)
{
time_t now = time(nullptr);
time_t now = GetEpochTime().count();
return (
(token == GenerateToken(secret, now - TOTP_INTERVAL)) ||
(token == GenerateToken(secret, now)) ||