total5 0.0.17-9 → 0.0.18-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/total5 +2 -2
- package/changelog.txt +10 -0
- package/controller.js +10 -1
- package/flow-flowstream.js +4 -2
- package/flow.js +3 -1
- package/flowstream.js +14 -11
- package/index.js +1 -1
- package/ldap.js +50 -15
- package/package.json +1 -1
- package/routing.js +5 -3
- package/websocket.js +19 -19
package/bin/total5
CHANGED
|
@@ -41,7 +41,7 @@ FUNC.help = function() {
|
|
|
41
41
|
console.log('bundle <filename> : it makes a bundle from the current directory');
|
|
42
42
|
console.log('extract <filename> : it extracts a bundle into the current directory');
|
|
43
43
|
console.log('edit <url?id=project> : it opens remote editing of the current directory with the Total.js Code Editor');
|
|
44
|
-
console.log('proxy <server_endpoint> <local_port> : It connects a local port with a remote
|
|
44
|
+
console.log('proxy <server_endpoint> <local_port> : It connects a local port with a remote Total.js proxy server');
|
|
45
45
|
console.log('8000 : it starts a web server on port "8000" for the current directory');
|
|
46
46
|
done();
|
|
47
47
|
};
|
|
@@ -243,7 +243,7 @@ FUNC.server = function(port) {
|
|
|
243
243
|
};
|
|
244
244
|
|
|
245
245
|
FUNC.proxy = function(endpoint, port) {
|
|
246
|
-
|
|
246
|
+
PROXYCLIENT(endpoint, port);
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
FUNC.edit = function(url) {
|
package/changelog.txt
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
========================
|
|
2
|
+
0.0.18
|
|
3
|
+
========================
|
|
4
|
+
|
|
5
|
+
- fixed handling static files
|
|
6
|
+
- added `flow.proxytimeout {Number}` property
|
|
7
|
+
- extended the `message.send(output, data, [clone_data], [check(from, to, output, input)])` method by adding `check` argument
|
|
8
|
+
- extended `LDAP()` options by adding a new option `attributes = { thumbnailPhoto: 'buffer' }` for custom parsing data
|
|
9
|
+
|
|
1
10
|
========================
|
|
2
11
|
0.0.17
|
|
3
12
|
========================
|
|
@@ -23,6 +32,7 @@
|
|
|
23
32
|
- improved `Utils.filestreamer()` method by adding percentage
|
|
24
33
|
- fixed sending data to all outputs `$.send(null, [data])` in the FlowStream
|
|
25
34
|
- fixed sending data to all outputs `instance.send(null, [data])` in the FlowStream
|
|
35
|
+
- fixed removing WebSocket route
|
|
26
36
|
|
|
27
37
|
========================
|
|
28
38
|
0.0.16
|
package/controller.js
CHANGED
|
@@ -1595,7 +1595,7 @@ function send_file(ctrl, path, ext) {
|
|
|
1595
1595
|
|
|
1596
1596
|
var loadstats = function(err, stats, cache) {
|
|
1597
1597
|
|
|
1598
|
-
if (err) {
|
|
1598
|
+
if (err || (cache && cache.size === 0)) {
|
|
1599
1599
|
|
|
1600
1600
|
if (!DEBUG && ctrl.response.cache)
|
|
1601
1601
|
F.temporary.notfound[ctrl.uri.cache] = true;
|
|
@@ -1657,6 +1657,15 @@ function send_file(ctrl, path, ext) {
|
|
|
1657
1657
|
if (ctrl.method === 'HEAD') {
|
|
1658
1658
|
ctrl.res.end();
|
|
1659
1659
|
} else {
|
|
1660
|
+
|
|
1661
|
+
if (end > cache.size || beg > cache.size) {
|
|
1662
|
+
// Unexpected file problem
|
|
1663
|
+
delete F.temporary.tmp[ctrl.uri.cache];
|
|
1664
|
+
ctrl.destroyed = true;
|
|
1665
|
+
ctrl.req.destroy();
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1660
1669
|
reader = F.Fs.createReadStream(path, { start: beg, end: end });
|
|
1661
1670
|
|
|
1662
1671
|
// Unexpected error
|
package/flow-flowstream.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Total.js FlowStream module
|
|
2
2
|
// The MIT License
|
|
3
|
-
// Copyright 2021-
|
|
3
|
+
// Copyright 2021-2026 (c) Peter Širka <petersirka@gmail.com>
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ if (!global.F)
|
|
|
9
9
|
|
|
10
10
|
const W = F.Worker;
|
|
11
11
|
const Fork = F.Child.fork;
|
|
12
|
-
const VERSION =
|
|
12
|
+
const VERSION = 35;
|
|
13
13
|
const NOTIFYPATH = '/notify/';
|
|
14
14
|
|
|
15
15
|
var isFLOWSTREAMWORKER = false;
|
|
@@ -648,6 +648,8 @@ Instance.prototype.reload = function(data) {
|
|
|
648
648
|
}
|
|
649
649
|
|
|
650
650
|
PROXIES[data.id] = F.proxy(data.proxypath, data.unixsocket);
|
|
651
|
+
data.proxytimeout && PROXIES[data.id].timeout(data.proxytimeout);
|
|
652
|
+
|
|
651
653
|
}
|
|
652
654
|
|
|
653
655
|
for (let key in data)
|
package/flow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Total.js Flow module
|
|
2
2
|
// The MIT License
|
|
3
|
-
// Copyright 2023-
|
|
3
|
+
// Copyright 2023-2026 (c) Peter Širka <petersirka@gmail.com>
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
@@ -81,6 +81,7 @@ FS.reload = function(flow, restart = false) {
|
|
|
81
81
|
var instance = FS.instances[flow.id];
|
|
82
82
|
instance.workertype = flow.worker;
|
|
83
83
|
instance.proxypath = flow.proxypath;
|
|
84
|
+
instance.proxytimeout = flow.proxytimeout;
|
|
84
85
|
|
|
85
86
|
if (restart)
|
|
86
87
|
instance.restart();
|
|
@@ -141,6 +142,7 @@ FS.load = function(flow, callback) {
|
|
|
141
142
|
// flow.worker {String/Boolean}
|
|
142
143
|
// flow.memory {Number}
|
|
143
144
|
// flow.proxypath {String}
|
|
145
|
+
// flow.proxytimeout {Number}
|
|
144
146
|
|
|
145
147
|
if (FS.instances[flow.id]) {
|
|
146
148
|
FS.reload(flow);
|
package/flowstream.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Total.js FlowStream
|
|
2
2
|
// The MIT License
|
|
3
|
-
// Copyright 2021-
|
|
3
|
+
// Copyright 2021-2026 (c) Peter Širka <petersirka@gmail.com>
|
|
4
4
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
@@ -350,9 +350,9 @@ function timeouthandler(msg) {
|
|
|
350
350
|
msg.end();
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
MP.send = function(outputindex, data, clonedata) {
|
|
353
|
+
MP.send = function(outputindex, data, clonedata, check) {
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
const self = this;
|
|
356
356
|
|
|
357
357
|
if (clonedata == null)
|
|
358
358
|
clonedata = self.main.cloning;
|
|
@@ -363,7 +363,6 @@ MP.send = function(outputindex, data, clonedata) {
|
|
|
363
363
|
return 0;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
let outputs;
|
|
367
366
|
let count = 0;
|
|
368
367
|
|
|
369
368
|
if (outputindex == null) {
|
|
@@ -379,11 +378,8 @@ MP.send = function(outputindex, data, clonedata) {
|
|
|
379
378
|
return count;
|
|
380
379
|
}
|
|
381
380
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
let now = Date.now();
|
|
385
|
-
|
|
386
|
-
outputs = self.instance.connections ? (self.instance.connections[outputindex] || F.EMPTYARRAY) : F.EMPTYARRAY;
|
|
381
|
+
const now = Date.now();
|
|
382
|
+
const meta = self.main.meta;
|
|
387
383
|
|
|
388
384
|
if (self.processed === 0) {
|
|
389
385
|
self.processed = 1;
|
|
@@ -406,6 +402,7 @@ MP.send = function(outputindex, data, clonedata) {
|
|
|
406
402
|
return count;
|
|
407
403
|
}
|
|
408
404
|
|
|
405
|
+
let outputs = self.instance.connections ? (self.instance.connections[outputindex] || F.EMPTYARRAY) : F.EMPTYARRAY;
|
|
409
406
|
let tid = self.toid + D + outputindex + (self.color || '');
|
|
410
407
|
|
|
411
408
|
if (self.main.stats.traffic[tid]) {
|
|
@@ -425,14 +422,20 @@ MP.send = function(outputindex, data, clonedata) {
|
|
|
425
422
|
if (output.disabled || output.paused)
|
|
426
423
|
continue;
|
|
427
424
|
|
|
428
|
-
|
|
425
|
+
const schema = meta.flow[output.id];
|
|
429
426
|
if (schema && (schema.message || schema['message_' + output.index]) && schema.component && schema.ready && self.main.$can(true, output.id, output.index)) {
|
|
430
|
-
|
|
427
|
+
const next = meta.components[schema.component];
|
|
431
428
|
if (next && next.connected && !next.isdestroyed && !next.disabled) {
|
|
432
429
|
|
|
433
430
|
if (output.color && self.color && self.color !== output.color)
|
|
434
431
|
continue;
|
|
435
432
|
|
|
433
|
+
if (check) {
|
|
434
|
+
// from, to, output, input
|
|
435
|
+
if (!check(self.to, schema, outputindex, output.index))
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
|
|
436
439
|
let inputindex = output.index;
|
|
437
440
|
let message = self.clone();
|
|
438
441
|
|
package/index.js
CHANGED
package/ldap.js
CHANGED
|
@@ -85,12 +85,13 @@ const TYPES = {
|
|
|
85
85
|
Context: 128
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
function Reader(buffer, callback) {
|
|
88
|
+
function Reader(buffer, callback, opt) {
|
|
89
89
|
|
|
90
90
|
if (buffer instanceof Array)
|
|
91
91
|
buffer = Buffer.concat(buffer);
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
const t = this;
|
|
94
|
+
t.opt = opt;
|
|
94
95
|
t.buffer = buffer;
|
|
95
96
|
t.size = t.buffer.length;
|
|
96
97
|
t.length = 0;
|
|
@@ -99,8 +100,8 @@ function Reader(buffer, callback) {
|
|
|
99
100
|
t.callback = callback;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
Reader.parse = function(buffer, callback) {
|
|
103
|
-
|
|
103
|
+
Reader.parse = function(buffer, callback, opt) {
|
|
104
|
+
const reader = new Reader(buffer, callback, opt);
|
|
104
105
|
reader.parse();
|
|
105
106
|
};
|
|
106
107
|
|
|
@@ -112,11 +113,11 @@ Reader.prototype = {
|
|
|
112
113
|
|
|
113
114
|
Reader.prototype.readbyte = function(peek) {
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
const self = this;
|
|
116
117
|
if (self.size - self.offset < 1)
|
|
117
118
|
return null;
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
const b = self.buffer[self.offset] & 0xff;
|
|
120
121
|
|
|
121
122
|
if (!peek)
|
|
122
123
|
self.offset += 1;
|
|
@@ -133,15 +134,48 @@ Reader.prototype.readattribute = function(attr) {
|
|
|
133
134
|
if (self.peek() === PROTOCOL.LBER_SET) {
|
|
134
135
|
|
|
135
136
|
if (self.readsequence(PROTOCOL.LBER_SET)) {
|
|
136
|
-
|
|
137
|
+
let end = self.offset + self.length;
|
|
137
138
|
while (self.offset < end) {
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
let val = self.readstring(TYPES.OctetString, true);
|
|
141
|
+
let is = false;
|
|
142
|
+
|
|
143
|
+
if (self.opt.attributes) {
|
|
144
|
+
switch (self.opt.attributes[id]) {
|
|
145
|
+
case 'string':
|
|
146
|
+
val = val.toString('utf8');
|
|
147
|
+
is = true;
|
|
148
|
+
break;
|
|
149
|
+
case 'number':
|
|
150
|
+
val = val.toString('utf8').parseFloat();
|
|
151
|
+
is = true;
|
|
152
|
+
break;
|
|
153
|
+
case 'date':
|
|
154
|
+
val = val.toString('utf8').parseDate();
|
|
155
|
+
is = true;
|
|
156
|
+
break;
|
|
157
|
+
case 'hex':
|
|
158
|
+
case 'ascii':
|
|
159
|
+
case 'base16':
|
|
160
|
+
case 'base32':
|
|
161
|
+
case 'base64':
|
|
162
|
+
case 'utf8':
|
|
163
|
+
val = val.toString(self.opt.attributes[id]);
|
|
164
|
+
is = true;
|
|
165
|
+
break;
|
|
166
|
+
case 'buffer':
|
|
167
|
+
case 'binary':
|
|
168
|
+
is = true;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
140
172
|
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
173
|
+
if (!is) {
|
|
174
|
+
if (id === 'objectGUID' || id === 'objectSid')
|
|
175
|
+
val = val.toString('hex');
|
|
176
|
+
else
|
|
177
|
+
val = val.toString('utf8');
|
|
178
|
+
}
|
|
145
179
|
|
|
146
180
|
if (attr[id]) {
|
|
147
181
|
if (!(attr[id] instanceof Array))
|
|
@@ -705,6 +739,7 @@ exports.load = function(opt, callback) {
|
|
|
705
739
|
// opt.login {String} required for the "profile" type
|
|
706
740
|
// opt.dn {String}
|
|
707
741
|
// opt.noauth {Boolean} true skips auth
|
|
742
|
+
// opt.attributes = { prop1: 'buffer', prop2: 'hex', prop3: 'base64' }; types must be in lower-case
|
|
708
743
|
|
|
709
744
|
if (opt.callback)
|
|
710
745
|
callback = opt.callback;
|
|
@@ -732,7 +767,7 @@ exports.load = function(opt, callback) {
|
|
|
732
767
|
Reader.parse(buffer, function(err, response) {
|
|
733
768
|
callback(err, profile ? (response ? response[0] : null) : response);
|
|
734
769
|
meta.close();
|
|
735
|
-
});
|
|
770
|
+
}, opt);
|
|
736
771
|
};
|
|
737
772
|
|
|
738
773
|
meta.ondata(function(chunk) {
|
|
@@ -753,7 +788,7 @@ exports.load = function(opt, callback) {
|
|
|
753
788
|
}
|
|
754
789
|
|
|
755
790
|
auth = false;
|
|
756
|
-
});
|
|
791
|
+
}, opt);
|
|
757
792
|
} else {
|
|
758
793
|
buffer.push(chunk);
|
|
759
794
|
timeout && clearTimeout(timeout);
|
|
@@ -769,7 +804,7 @@ exports.load = function(opt, callback) {
|
|
|
769
804
|
// No emitted any data in "ondata" handler
|
|
770
805
|
Reader.parse(buffer, function(err) {
|
|
771
806
|
callback(err, profile ? null : EMPTYARRAY);
|
|
772
|
-
});
|
|
807
|
+
}, opt);
|
|
773
808
|
|
|
774
809
|
});
|
|
775
810
|
|
package/package.json
CHANGED
package/routing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The MIT License
|
|
2
|
-
// Copyright 2023 (c) Peter Širka <petersirka@gmail.com>
|
|
2
|
+
// Copyright 2023-2026 (c) Peter Širka <petersirka@gmail.com>
|
|
3
3
|
|
|
4
4
|
const NEWLINE = '\r\n';
|
|
5
5
|
|
|
@@ -322,8 +322,10 @@ Route.prototype.remove = function() {
|
|
|
322
322
|
index = F.routes.websockets.indexOf(self);
|
|
323
323
|
if (index !== -1)
|
|
324
324
|
F.routes.websockets.splice(index, 1);
|
|
325
|
-
|
|
326
|
-
conn.
|
|
325
|
+
if (self.connections instanceof Array) {
|
|
326
|
+
for (let conn of self.connections)
|
|
327
|
+
conn.destroy();
|
|
328
|
+
}
|
|
327
329
|
break;
|
|
328
330
|
case 'file':
|
|
329
331
|
index = F.routes.files.indexOf(self);
|
package/websocket.js
CHANGED
|
@@ -694,9 +694,9 @@ WebSocket.prototype.encrypt = function(enable) {
|
|
|
694
694
|
};
|
|
695
695
|
|
|
696
696
|
WebSocket.prototype.find = function(fn) {
|
|
697
|
-
|
|
698
|
-
for (
|
|
699
|
-
|
|
697
|
+
let self = this;
|
|
698
|
+
for (let key in self.connections) {
|
|
699
|
+
let ctrl = self.connections[key];
|
|
700
700
|
if (fn(ctrl))
|
|
701
701
|
return ctrl;
|
|
702
702
|
}
|
|
@@ -704,7 +704,7 @@ WebSocket.prototype.find = function(fn) {
|
|
|
704
704
|
|
|
705
705
|
WebSocket.prototype.send = function(message, comparer, replacer, params) {
|
|
706
706
|
|
|
707
|
-
|
|
707
|
+
let self = this;
|
|
708
708
|
|
|
709
709
|
if (message === undefined)
|
|
710
710
|
return self;
|
|
@@ -714,11 +714,11 @@ WebSocket.prototype.send = function(message, comparer, replacer, params) {
|
|
|
714
714
|
replacer = null;
|
|
715
715
|
}
|
|
716
716
|
|
|
717
|
-
|
|
718
|
-
|
|
717
|
+
let raw = false;
|
|
718
|
+
let data = null;
|
|
719
719
|
|
|
720
|
-
for (
|
|
721
|
-
|
|
720
|
+
for (let key in self.connections) {
|
|
721
|
+
let ctrl = self.connections[key];
|
|
722
722
|
if (data == null) {
|
|
723
723
|
if (ctrl.datatype === 'json') {
|
|
724
724
|
raw = true;
|
|
@@ -740,20 +740,20 @@ WebSocket.prototype.send = function(message, comparer, replacer, params) {
|
|
|
740
740
|
// Ping all connections
|
|
741
741
|
WebSocket.prototype.ping = function() {
|
|
742
742
|
|
|
743
|
-
|
|
743
|
+
let self = this;
|
|
744
744
|
|
|
745
745
|
self.$ping = true;
|
|
746
746
|
F.stats.other.websocketping++;
|
|
747
747
|
|
|
748
|
-
|
|
749
|
-
for (
|
|
748
|
+
let ts = Date.now();
|
|
749
|
+
for (let key in self.connections)
|
|
750
750
|
self.connections[key].ping(ts);
|
|
751
751
|
|
|
752
752
|
return self;
|
|
753
753
|
};
|
|
754
754
|
|
|
755
755
|
WebSocket.prototype.api = function(api) {
|
|
756
|
-
|
|
756
|
+
let self = this;
|
|
757
757
|
|
|
758
758
|
if (!api.startsWith('/@')) {
|
|
759
759
|
if (api[0] !== '@')
|
|
@@ -771,9 +771,9 @@ WebSocket.prototype.api = function(api) {
|
|
|
771
771
|
|
|
772
772
|
WebSocket.prototype.close = function(code, message) {
|
|
773
773
|
|
|
774
|
-
|
|
774
|
+
let self = this;
|
|
775
775
|
|
|
776
|
-
for (
|
|
776
|
+
for (let key in self.connections) {
|
|
777
777
|
self.connections[key].close(code, message);
|
|
778
778
|
delete self.connections[key];
|
|
779
779
|
}
|
|
@@ -783,13 +783,13 @@ WebSocket.prototype.close = function(code, message) {
|
|
|
783
783
|
};
|
|
784
784
|
|
|
785
785
|
WebSocket.prototype.error = function(err) {
|
|
786
|
-
|
|
786
|
+
let self = this;
|
|
787
787
|
F.error(typeof(err) === 'string' ? new Error(err) : err, self.name, self.url);
|
|
788
788
|
};
|
|
789
789
|
|
|
790
790
|
WebSocket.prototype.destroy = function() {
|
|
791
791
|
|
|
792
|
-
|
|
792
|
+
let self = this;
|
|
793
793
|
|
|
794
794
|
if (!self.connections)
|
|
795
795
|
return self;
|
|
@@ -800,15 +800,15 @@ WebSocket.prototype.destroy = function() {
|
|
|
800
800
|
|
|
801
801
|
setTimeout(function(self) {
|
|
802
802
|
|
|
803
|
-
for (
|
|
804
|
-
|
|
803
|
+
for (let key in self.connections) {
|
|
804
|
+
let conn = self.connections[key];
|
|
805
805
|
if (conn) {
|
|
806
806
|
conn.isclosed2 = true;
|
|
807
807
|
conn.socket.removeAllListeners();
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
810
|
|
|
811
|
-
|
|
811
|
+
let index = self.route.connections.indexOf(self);
|
|
812
812
|
if (index !== -1)
|
|
813
813
|
self.route.connections.splice(index, 1);
|
|
814
814
|
|