Comparing version 0.5.2 to 0.5.3
@@ -41,3 +41,6 @@ /* | ||
ntpData[0] = 0x1B; // RFC 2030 | ||
// RFC 2030 -> LI = 0 (no warning, 2 bits), VN = 3 (IPv4 only, 3 bits), Mode = 3 (Client Mode, 3 bits) -> 1 byte | ||
// -> rtol(LI, 6) ^ rotl(VN, 3) ^ rotl(Mode, 0) | ||
// -> = 0x00 ^ 0x18 ^ 0x03 | ||
ntpData[0] = 0x1B; | ||
@@ -53,5 +56,27 @@ for (var i = 1; i < 48; i++) { | ||
// Some errors can happen before/after send() or cause send() to was impossible. | ||
// Some errors will also be given to the send() callback. | ||
// We keep a flag, therefore, to prevent multiple callbacks. | ||
// NOTE : the error callback is not generalised, as the client has to lose the connection also, apparently. | ||
var errorFired = false; | ||
client.on('error', function (err) { | ||
if (errorFired) { | ||
return; | ||
} | ||
callback(err, null); | ||
errorFired = true; | ||
clearTimeout(timeout); | ||
}); | ||
client.send(ntpData, 0, ntpData.length, port, server, function (err) { | ||
if (err) { | ||
if (errorFired) { | ||
return; | ||
} | ||
clearTimeout(timeout); | ||
callback(err, null); | ||
errorFired = true; | ||
client.close(); | ||
@@ -58,0 +83,0 @@ return; |
{ | ||
"name": "ntp-client", | ||
"description": "Pure Javascript implementation of the NTP Client Protocol", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"homepage": "https://github.com/moonpyk/node-ntp-client", | ||
@@ -23,3 +23,3 @@ "author": { | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
"node": ">= 0.10.0" | ||
}, | ||
@@ -30,7 +30,7 @@ "scripts": { | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-jshint": "~0.6.0", | ||
"grunt-contrib-nodeunit": "~0.2.0", | ||
"grunt-contrib-watch": "~0.4.0", | ||
"nodeunit": "~0.8.1" | ||
"grunt": ">= 0.4.1", | ||
"grunt-contrib-jshint": ">= 0.6.0", | ||
"grunt-contrib-nodeunit": ">= 0.2.0", | ||
"grunt-contrib-watch": ">= 0.4.0", | ||
"nodeunit": ">= 0.8.1" | ||
}, | ||
@@ -41,5 +41,5 @@ "bin": { | ||
"keywords": [ | ||
"ntp", | ||
"date" | ||
"date", | ||
"ntp" | ||
] | ||
} |
@@ -22,4 +22,9 @@ # ntp-client [![Build Status](https://secure.travis-ci.org/moonpyk/node-ntp-client.png?branch=master)](http://travis-ci.org/moonpyk/node-ntp-client) | ||
## Contributors | ||
* Clément Bourgeois (https://github.com/moonpyk) | ||
* Callan Bryant (https://github.com/naggie) | ||
## License | ||
Copyright (c) 2013 Clément Bourgeois | ||
Copyright (c) 2014 Clément Bourgeois | ||
Licensed under the MIT license. | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11936
207
30