Bug fixes

Ylian Saint-Hilaire committed May 3, 2018 at 17:21 UTC a5d39fa2500d5b6efb24d295534daa00ffdc5181
2 files changed +7 -17
mpsserver.js
+6 -16
@@ -17,9 +17,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
17 const common = require('./common.js');
18 const net = require('net');
19 const tls = require('tls');
20 -
20 const MAX_IDLE = 90000; // 90 seconds max idle time, higher than the typical KEEP-ALIVE periode of 60 seconds
22 - const CHECK_INTERVAL = 30000; // 30 seconds check interval
21
22 if (obj.args.tlsoffload) {
23 obj.server = net.createServer(onConnection);
@@ -32,7 +30,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
30 obj.parent.updateServerState('mps-name', certificates.AmtMpsName);
31 if (args.mpsaliasport != null) { obj.parent.updateServerState('mps-alias-port', args.mpsaliasport); }
32
35 - var APFProtocol = {
33 + const APFProtocol = {
34 UNKNOWN: 0,
35 DISCONNECT: 1,
36 SERVICE_REQUEST: 5,
@@ -56,7 +54,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
54 KEEPALIVE_OPTIONS_REPLY: 211
55 }
56
59 - var APFDisconnectCode = {
57 + const APFDisconnectCode = {
58 HOST_NOT_ALLOWED_TO_CONNECT: 1,
59 PROTOCOL_ERROR: 2,
60 KEY_EXCHANGE_FAILED: 3,
@@ -77,14 +75,14 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
75 TEMPORARILY_UNAVAILABLE: 18
76 }
77
80 - var APFChannelOpenFailCodes = {
78 + const APFChannelOpenFailCodes = {
79 ADMINISTRATIVELY_PROHIBITED: 1,
80 CONNECT_FAILED: 2,
81 UNKNOWN_CHANNEL_TYPE: 3,
82 RESOURCE_SHORTAGE: 4,
83 }
84
87 - var APFChannelOpenFailureReasonCode = {
85 + const APFChannelOpenFailureReasonCode = {
86 AdministrativelyProhibited: 1,
87 ConnectFailed: 2,
88 UnknownChannelType: 3,
@@ -101,12 +99,8 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
99 Debug(1, 'MPS:New CIRA connection');
100
101 // Setup the CIRA keep alive timer
104 - socket.lastping = new Date().getTime(); // Get current time in milliseconds from epoch
105 - socket.timer = setInterval(function () {
106 - const now = new Date().getTime();
107 - Debug(3, "MPS:Check interval:" + (socket.lastping && (socket.lastping + MAX_IDLE) < now));
108 - if (socket.lastping && ((socket.lastping + MAX_IDLE) < now)) { Debug(1, "MPS:CIRA timeout, disconnecting."); try { socket.end(); } catch (e) { } }
109 - }, CHECK_INTERVAL);
102 + socket.setTimeout(MAX_IDLE);
103 + socket.on('timeout', () => { Debug(1, "MPS:CIRA timeout, disconnecting."); try { socket.end(); } catch (e) { } });
104
105 socket.addListener("data", function (data) {
106 if (args.mpsdebug) { var buf = new Buffer(data, "binary"); console.log('MPS <-- (' + buf.length + '):' + buf.toString('hex')); } // Print out received bytes
@@ -178,9 +172,6 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
172 }
173
174 try {
181 - // Set the last time we received data on the CIRA channel
182 - socket.lastping = new Date().getTime();
183 -
175 // Parse all of the APF data we can
176 var l = 0;
177 do { l = ProcessCommand(socket); if (l > 0) { socket.tag.accumulator = socket.tag.accumulator.substring(l); } } while (l > 0);
@@ -544,7 +535,6 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
535
536 socket.addListener("close", function () {
537 Debug(1, 'MPS:CIRA connection closed');
547 - if (socket.timer) { try { clearInterval(socket.timer); } catch (e) { } socket.timer = null; }
538 try { delete obj.ciraConnections[socket.tag.nodeid]; } catch (e) { }
539 obj.parent.ClearConnectivityState(socket.tag.meshid, socket.tag.nodeid, 2);
540 });
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.1.7-h",
3 + "version": "0.1.7-i",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",