1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +02:00

Improved ntp time

This commit is contained in:
Laurent Cozic
2020-09-09 00:34:27 +01:00
parent 1f70a76c7e
commit f41ba67e15
3 changed files with 16 additions and 6 deletions

View File

@ -14,11 +14,11 @@
(function (exports) {
"use strict";
var dgram = require('dgram');
exports.defaultNtpPort = 123;
exports.defaultNtpServer = "pool.ntp.org";
exports.dgram = null;
/**
* Amount of acceptable time to await for a response from the remote server.
* Configured default to 10 seconds.
@ -40,7 +40,9 @@
server = server || exports.defaultNtpServer;
port = port || exports.defaultNtpPort;
var client = dgram.createSocket("udp4"),
if (!exports.dgram) throw new Error('dgram package has not been set!!');
var client = exports.dgram.createSocket("udp4"),
ntpData = new Buffer(48);
// RFC 2030 -> LI = 0 (no warning, 2 bits), VN = 3 (IPv4 only, 3 bits), Mode = 3 (Client Mode, 3 bits) -> 1 byte