const int nServersCount = 147;
-const std::string NtpServers[147] = {
+std::string NtpServers[147] = {
// Microsoft
"time.windows.com",
// ... To be continued
};
-bool InitWithHost(const std::string &strHostName, SOCKET &sockfd, socklen_t &servlen, struct sockaddr *pcliaddr) {
+bool InitWithHost(std::string &strHostName, SOCKET &sockfd, socklen_t &servlen, struct sockaddr *pcliaddr) {
sockfd = -1;
std::vector<CNetAddr> vIP;
return nTime;
}
-int64_t NtpGetTime(const std::string &strHostName)
+int64_t NtpGetTime(std::string &strHostName)
{
struct sockaddr cliaddr;
printf("Trying to find NTP server at localhost...\n");
- const std::string strLocalHost = "127.0.0.1";
+ std::string strLocalHost = "127.0.0.1";
if (NtpGetTime(strLocalHost) == GetTime()) {
printf("There is NTP server active at localhost, we don't need NTP thread.\n");
CMedianFilter<int64_t> vTimeOffsets(200,0);
while (!fShutdown) {
- if (strTrustedUpstream != strLocalHost) {
+ if (strTrustedUpstream != "localhost") {
// Trying to get new offset sample from trusted NTP server.
int64_t nClockOffset = NtpGetTime(strTrustedUpstream) - GetTime();
else {
// Something went wrong, disable trusted offset sampling.
nNtpOffset = INT64_MAX;
- strTrustedUpstream = strLocalHost;
+ strTrustedUpstream = "localhost";
int nSleepMinutes = 1 + GetRandInt(9); // Sleep for 1-10 minutes.
for (int i = 0; i < nSleepMinutes * 60 && !fShutdown; i++)
int64_t NtpGetTime(CNetAddr& ip);
// Get time from provided server.
-int64_t NtpGetTime(const std::string &strHostName);
+int64_t NtpGetTime(std::string &strHostName);
extern std::string strTrustedUpstream;