More multiplexor work, letsencrypt will now default to cert if names not set.
Ylian Saint-Hilaire committed
Apr 24, 2020 at 14:58 UTC
19f195b032557713139f1fd22953338cd0024995
3 files changed
+47
-15
MeshCentralServer.njsproj
+1
@@ -107,6 +107,7 @@
107
<Compile Include="mcrec.js" />
108
<Compile Include="meshaccelerator.js" />
109
<Compile Include="meshctrl.js" />
110
+ <Compile Include="meshdesktopmultiplex.js" />
111
<Compile Include="meshmail.js" />
112
<Compile Include="meshsms.js" />
113
<Compile Include="meshscanner.js" />
meshcentral.js
+1
@@ -1190,6 +1190,7 @@ function CreateMeshCentralServer(config, args) {
1190
} else {
1191
// Check Let's Encrypt settings
1192
var leok = true;
1193
+ if ((typeof obj.config.letsencrypt.names != 'string') && (typeof obj.config.settings.cert == 'string')) { obj.config.letsencrypt.names = obj.config.settings.cert; }
1194
if (typeof obj.config.letsencrypt.email != 'string') { leok = false; addServerWarning("Missing Let's Encrypt email address."); }
1195
else if (typeof obj.config.letsencrypt.names != 'string') { leok = false; addServerWarning("Invalid Let's Encrypt host names."); }
1196
else if (obj.config.letsencrypt.names.indexOf('*') >= 0) { leok = false; addServerWarning("Invalid Let's Encrypt names, can't contain a *."); }
meshdesktopmultiplex.js
+45
-15
@@ -26,6 +26,8 @@ function CreateDesktopDecoder() {
26
obj.images = {};
27
obj.lastScreenSizeCmd = null;
28
obj.lastScreenSizeCounter = 0;
29
+ obj.firstData = null;
30
+ obj.lastData = null;
31
32
obj.processAgentData = function (data) {
33
if ((typeof data != 'object') || (data.length < 4)) return;
@@ -37,7 +39,7 @@ function CreateDesktopDecoder() {
39
command = data.readUInt16BE(8);
40
cmdsize = data.readUInt32BE(4);
41
if (data.length == (cmdsize + 8)) {
40
- data = data.slice(8, block.data.length);
42
+ data = data.slice(8, data.length);
43
} else {
44
console.log('TODO-PARTIAL-JUMBO', command, cmdsize, data.length);
45
return; // TODO
@@ -47,30 +49,48 @@ function CreateDesktopDecoder() {
49
50
switch (command) {
51
case 3: // Tile, check dimentions and store
50
- var x = data.readUInt16BE(4);
51
- var y = data.readUInt16BE(6);
52
+ var x = data.readUInt16BE(4), y = data.readUInt16BE(6);
53
var dimensions = require('image-size')(data.slice(8));
54
+ var sx = (x / 16), sy = (y / 16), sw = (dimensions.width / 16), sh = (dimensions.height / 16);
55
obj.counter++;
54
- console.log("Tile", x, y, dimensions.width, dimensions.height);
55
-
56
+ //console.log("Tile", x, y, dimensions.width, dimensions.height);
57
+
58
+ // Keep a reference to this image & how many tiles it covers
59
+ obj.images[obj.counter] = { next: null, prev: obj.lastData, data: data };
60
+ obj.images[obj.lastData].next = obj.counter;
61
+ obj.lastData = obj.counter;
62
+ obj.imagesCounters[obj.counter] = (sw * sh);
63
+ obj.imagesCount++;
64
+ if (obj.imagesCount == 2000000000) { obj.imagesCount = 1; } // Loop the counter if needed
65
+
66
// Update the screen with the correct pointers.
57
- var sx = (x / 16), sy = (y / 16), sw = (dimensions.width / 16), sh = (dimensions.height / 16);
67
for (var i = 0; i < sw; i++) {
68
for (var j = 0; j < sh; j++) {
69
var k = ((obj.swidth * (j + sy)) + (i + sx)), oi = obj.screen[k];
61
- if (--obj.imagesCounters[oi] == 0) { obj.imagesCount--; delete obj.images[oi]; delete obj.imagesCounters[oi]; }
70
+ if ((oi != null) && (--obj.imagesCounters[oi] == 0)) {
71
+ // Remove data from the link list
72
+ obj.imagesCount--;
73
+ var d = obj.images[oi];
74
+ obj.images[d.prev].next = d.next;
75
+ obj.images[d.next].prev = d.prev;
76
+ delete obj.images[oi];
77
+ delete obj.imagesCounters[oi];
78
+
79
+ // If any viewers are currently on image "oi" must be moved to "d.next"
80
+ // TODO
81
+ }
82
obj.screen[k] = obj.counter;
83
}
84
}
85
66
- // Keep a reference to this image & how many tiles it covers
67
- obj.images[obj.counter] = data;
68
- obj.imagesCounters[obj.counter] = (sw * sh);
69
- obj.imagesCount++;
70
- console.log('images', obj.imagesCount);
71
-
86
+ // Debug, display the link list
87
+ //var xx = '', xptr = obj.firstData;
88
+ //while (xptr != null) { xx += '>' + xptr; xptr = obj.images[xptr].next; }
89
+ //console.log('list', xx);
90
+ //console.log('images', obj.imagesCount);
91
+
92
break;
73
- case 7:// Screen Size, clear the screen state and compute the tile count
93
+ case 7: // Screen Size, clear the screen state and compute the tile count
94
obj.counter++;
95
obj.lastScreenSizeCmd = data;
96
obj.lastScreenSizeCounter = obj.counter;
@@ -86,8 +106,18 @@ function CreateDesktopDecoder() {
106
obj.imagesCount = 0;
107
obj.imagesCounters = {};
108
obj.images = {};
109
+ obj.images[obj.counter] = { next: null, prev: null, data: data};
110
+ obj.firstData = obj.counter;
111
+ obj.lastData = obj.counter;
112
+
113
+ // Add viewers must be set to start at "obj.counter"
114
+ // TODO
115
90
- console.log("ScreenSize", obj.width, obj.height, obj.swidth, obj.sheight, obj.swidth * obj.sheight);
116
+ //console.log("ScreenSize", obj.width, obj.height, obj.swidth, obj.sheight, obj.swidth * obj.sheight);
117
+ break;
118
+ default:
119
+ // 11, 14, 88
120
+ console.log('Un-handled command: ' + command);
121
break;
122
}
123
}