mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
3474538697
Some checks are pending
Build Debian packages / ${{ matrix.dist }} (bookworm) (push) Waiting to run
Build Debian packages / ${{ matrix.dist }} (bullseye) (push) Waiting to run
Build Debian packages / ${{ matrix.dist }} (buster) (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (no) (push) Waiting to run
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (no) (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (OFF) (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (ON) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (i386, linux/386) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (armv7, linux/arm/v7) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (amd64, linux/amd64) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (arm64, linux/arm64) (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2013-2024, The PurpleI2P Project
|
|
*
|
|
* This file is part of Purple i2pd project and licensed under BSD3
|
|
*
|
|
* See full license text in LICENSE file at top of project tree
|
|
*/
|
|
|
|
#ifndef TIMESTAMP_H__
|
|
#define TIMESTAMP_H__
|
|
|
|
#include <inttypes.h>
|
|
#include <thread>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <boost/asio.hpp>
|
|
|
|
namespace i2p
|
|
{
|
|
namespace util
|
|
{
|
|
uint64_t GetMillisecondsSinceEpoch ();
|
|
uint64_t GetSecondsSinceEpoch ();
|
|
uint32_t GetMinutesSinceEpoch ();
|
|
uint32_t GetHoursSinceEpoch ();
|
|
|
|
uint64_t GetMonotonicMicroseconds ();
|
|
uint64_t GetMonotonicMilliseconds ();
|
|
uint64_t GetMonotonicSeconds ();
|
|
|
|
void GetCurrentDate (char * date); // returns UTC date as YYYYMMDD string, 9 bytes
|
|
void GetNextDayDate (char * date); // returns next UTC day as YYYYMMDD string, 9 bytes
|
|
void GetDateString (uint64_t timestamp, char * date); // timestamp is seconds since epoch, returns date as YYYYMMDD string, 9 bytes
|
|
void AdjustTimeOffset (int64_t offset); // in seconds from current
|
|
|
|
class NTPTimeSync
|
|
{
|
|
public:
|
|
|
|
NTPTimeSync ();
|
|
~NTPTimeSync ();
|
|
|
|
void Start ();
|
|
void Stop ();
|
|
|
|
private:
|
|
|
|
void Run ();
|
|
void Sync ();
|
|
|
|
private:
|
|
|
|
bool m_IsRunning;
|
|
std::unique_ptr<std::thread> m_Thread;
|
|
boost::asio::io_context m_Service;
|
|
boost::asio::deadline_timer m_Timer;
|
|
int m_SyncInterval;
|
|
std::vector<std::string> m_NTPServersList;
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif
|