@tak-ps/node-tak 11.27.0 → 12.1.0
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/CHANGELOG.md +6 -2
- package/cli.ts +3 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +96 -8
- package/dist/index.js +197 -48
- package/dist/index.js.map +1 -1
- package/dist/lib/utils/queue.d.ts +13 -0
- package/dist/lib/utils/queue.js +47 -0
- package/dist/lib/utils/queue.js.map +1 -0
- package/dist/test/pipeline.test.d.ts +1 -0
- package/dist/test/pipeline.test.js +222 -0
- package/dist/test/pipeline.test.js.map +1 -0
- package/dist/test/queue.test.d.ts +1 -0
- package/dist/test/queue.test.js +46 -0
- package/dist/test/queue.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +312 -98
- package/lib/utils/queue.ts +53 -0
- package/package.json +4 -3
- package/test/pipeline.test.ts +268 -0
- package/test/queue.test.ts +49 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,9 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
## Version History
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### v12.1.0 - 2025-03-02
|
|
14
14
|
|
|
15
|
-
- :
|
|
15
|
+
- :bug: Fix connect_ssl race condition where a stale socket's delayed close or end event could destroy a newly-reconnected socket, leaving the connection permanently dead after a server restart.
|
|
16
|
+
|
|
17
|
+
### v12.0.0 - 2025-02-11
|
|
18
|
+
|
|
19
|
+
- :tada: Significantly improve memory performance of client when writing large amounts of data
|
|
16
20
|
|
|
17
21
|
### v11.26.2 - 2025-02-05
|
|
18
22
|
|
package/cli.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,9 @@ catch (err) {
|
|
|
24
24
|
message: 'No TAK Config file Detected, create one?'
|
|
25
25
|
});
|
|
26
26
|
if (!answer) {
|
|
27
|
-
throw new Error('No config file and not creating one'
|
|
27
|
+
throw new Error('No config file and not creating one', {
|
|
28
|
+
cause: err
|
|
29
|
+
});
|
|
28
30
|
}
|
|
29
31
|
config = {
|
|
30
32
|
version: 1,
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,EAAE,MAAO,SAAS,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,QAA2B,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAExF,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;IAChC,MAAM,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;AAC7D,IAAI,MAAoC,CAAC;AAEzC,IAAI,CAAC;IACD,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACX,IAAI,GAA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AI,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjF,MAAM,IAAI,KAAK,CAAC,OAAO,OAAO,IAAI,UAAU,8BAA8B,IAAI,CAAC,MAAM,4BAA4B,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpK,CAAC;IAED,IAAI,CAAC;QACD,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;QACvB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
1
|
import type { Static } from '@sinclair/typebox';
|
|
3
|
-
import CoT from '@tak-ps/node-cot';
|
|
4
2
|
import type { CoTOptions } from '@tak-ps/node-cot';
|
|
3
|
+
import CoT from '@tak-ps/node-cot';
|
|
4
|
+
import EventEmitter from 'node:events';
|
|
5
5
|
import type { TLSSocket } from 'node:tls';
|
|
6
6
|
import TAKAPI from './lib/api.js';
|
|
7
7
|
import { TAKAuth } from './lib/auth.js';
|
|
8
|
+
import { Queue } from './lib/utils/queue.js';
|
|
8
9
|
export * from './lib/auth.js';
|
|
9
10
|
export declare const REGEX_CONTROL: RegExp;
|
|
10
11
|
export declare const REGEX_EVENT: RegExp;
|
|
@@ -12,10 +13,65 @@ export interface PartialCoT {
|
|
|
12
13
|
event: string;
|
|
13
14
|
remainder: string;
|
|
14
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuration options for a TAK connection.
|
|
18
|
+
*
|
|
19
|
+
* Performance-related options control the write pipeline:
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* write(cots) process()
|
|
23
|
+
* ─────────── ─────────
|
|
24
|
+
* for each CoT: while queue has items:
|
|
25
|
+
* serialize to XML ──push()──► Ring pop socketBatchSize items
|
|
26
|
+
* (returns false ◄──────── Buffer join into one string
|
|
27
|
+
* when full) (capacity = socket.write(batch)
|
|
28
|
+
* writeQueueSize) stop if backpressure
|
|
29
|
+
* when full:
|
|
30
|
+
* setImmediate() yield triggered by:
|
|
31
|
+
* (lets process() drain) - write() calling process()
|
|
32
|
+
* - socket 'drain' event
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example High-throughput bulk ingestion
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const tak = await TAK.connect(url, auth, {
|
|
38
|
+
* writeQueueSize: 50_000, // large buffer absorbs bursts
|
|
39
|
+
* socketBatchSize: 128, // 128 strings per socket.write()
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Low-latency real-time streams
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const tak = await TAK.connect(url, auth, {
|
|
46
|
+
* writeQueueSize: 400, // small buffer keeps memory minimal
|
|
47
|
+
* socketBatchSize: 10, // flush to socket every 10 items
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
15
51
|
export type TAKOptions = {
|
|
52
|
+
/** Unique connection identifier. Appears in log messages for debugging.
|
|
53
|
+
* Useful when running multiple TAK connections in a single process.
|
|
54
|
+
* @default crypto.randomUUID() */
|
|
16
55
|
id?: number | string;
|
|
56
|
+
/** Connection type label. Informational only — helps distinguish
|
|
57
|
+
* connections in logs when multiple are active.
|
|
58
|
+
* @default 'unknown' */
|
|
17
59
|
type?: string;
|
|
60
|
+
/** Options passed through to `@tak-ps/node-cot` for CoT parsing
|
|
61
|
+
* (e.g., on incoming `'cot'` events). Does not affect the write pipeline. */
|
|
18
62
|
cot?: CoTOptions;
|
|
63
|
+
/** Capacity of the ring buffer that sits between `write()` and `process()`.
|
|
64
|
+
* When the queue is full, `write()` yields via `setImmediate()` until
|
|
65
|
+
* `process()` drains space. Larger values allow more XML strings to be
|
|
66
|
+
* buffered, increasing throughput at the cost of higher peak memory.
|
|
67
|
+
* @default 10_000 */
|
|
68
|
+
writeQueueSize?: number;
|
|
69
|
+
/** How many pre-serialized XML strings are popped from the ring buffer
|
|
70
|
+
* and joined into a single `socket.write()` call in `process()`. Higher
|
|
71
|
+
* values reduce syscall overhead and improve TLS frame packing, but
|
|
72
|
+
* increase per-write latency and the size of each socket write.
|
|
73
|
+
* @default 64 */
|
|
74
|
+
socketBatchSize?: number;
|
|
19
75
|
};
|
|
20
76
|
export default class TAK extends EventEmitter {
|
|
21
77
|
id: number | string;
|
|
@@ -24,12 +80,14 @@ export default class TAK extends EventEmitter {
|
|
|
24
80
|
auth: Static<typeof TAKAuth>;
|
|
25
81
|
open: boolean;
|
|
26
82
|
destroyed: boolean;
|
|
27
|
-
queue: string[];
|
|
28
83
|
writing: boolean;
|
|
84
|
+
writeQueueSize: number;
|
|
85
|
+
socketBatchSize: number;
|
|
29
86
|
cotOptions: CoTOptions;
|
|
30
87
|
pingInterval?: ReturnType<typeof setTimeout>;
|
|
31
88
|
client?: TLSSocket;
|
|
32
89
|
version?: string;
|
|
90
|
+
queue: Queue<string>;
|
|
33
91
|
/**
|
|
34
92
|
* @param url - Full URL of Streaming COT Endpoint IE: "https://ops.cotak.gov:8089"
|
|
35
93
|
* @param auth - TAK Certificate Pair
|
|
@@ -43,17 +101,47 @@ export default class TAK extends EventEmitter {
|
|
|
43
101
|
reconnect(): Promise<void>;
|
|
44
102
|
destroy(): void;
|
|
45
103
|
ping(): Promise<void>;
|
|
46
|
-
writer(body: string): Promise<boolean>;
|
|
47
|
-
process(): Promise<void>;
|
|
48
104
|
/**
|
|
49
|
-
*
|
|
105
|
+
* Drain the queue to the socket.
|
|
106
|
+
*
|
|
107
|
+
* Pops pre-serialized XML strings from the ring buffer, batches them
|
|
108
|
+
* (up to `socketBatchSize` per call), and writes to the socket. Runs
|
|
109
|
+
* synchronously in a single event loop tick until the socket signals
|
|
110
|
+
* backpressure or the queue is empty.
|
|
111
|
+
*
|
|
112
|
+
* Called when the socket signals readiness:
|
|
113
|
+
* - `'drain'` event (socket buffer cleared, ready for more)
|
|
114
|
+
* - After `write()` enqueues new items
|
|
115
|
+
*
|
|
116
|
+
* Emits `'_flushed'` when the queue drains to zero, waking any
|
|
117
|
+
* pending `flush()` calls.
|
|
118
|
+
*/
|
|
119
|
+
process(): void;
|
|
120
|
+
/**
|
|
121
|
+
* Write CoTs to the TAK connection.
|
|
50
122
|
*
|
|
51
|
-
*
|
|
123
|
+
* Serializes each CoT to XML upfront and stores the string in a bounded
|
|
124
|
+
* ring buffer. Fully caller-safe: CoT objects can be mutated or GC'd
|
|
125
|
+
* immediately after this returns.
|
|
126
|
+
* Resolves when all items are queued (not when sent over the wire).
|
|
127
|
+
* Use flush() to wait for delivery.
|
|
128
|
+
*
|
|
129
|
+
* @param cots Array of CoT objects to send
|
|
52
130
|
*/
|
|
53
131
|
write(cots: CoT[]): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Wait until all queued CoTs have been flushed to the socket.
|
|
134
|
+
*
|
|
135
|
+
* write() is a fast "enqueue" — it returns once items are in the queue,
|
|
136
|
+
* NOT once they've been sent over the wire.
|
|
137
|
+
*
|
|
138
|
+
* Resolves immediately if nothing is queued.
|
|
139
|
+
* Rejects if the connection is destroyed before flush completes.
|
|
140
|
+
*/
|
|
141
|
+
flush(): Promise<void>;
|
|
54
142
|
write_xml(body: string): void;
|
|
55
143
|
static findCoT(str: string): null | PartialCoT;
|
|
56
144
|
}
|
|
57
145
|
export * from './lib/api.js';
|
|
58
146
|
export { CommandOutputFormat } from './lib/commands.js';
|
|
59
|
-
export {
|
|
147
|
+
export { CoT, TAKAPI };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import CoT, { CoTParser } from '@tak-ps/node-cot';
|
|
1
2
|
import EventEmitter from 'node:events';
|
|
2
3
|
import tls from 'node:tls';
|
|
3
|
-
import CoT, { CoTParser } from '@tak-ps/node-cot';
|
|
4
4
|
import TAKAPI from './lib/api.js';
|
|
5
|
+
import { Queue } from './lib/utils/queue.js';
|
|
5
6
|
export * from './lib/auth.js';
|
|
6
7
|
/* eslint-disable no-control-regex */
|
|
7
8
|
export const REGEX_CONTROL = /[\u000B-\u001F\u007F-\u009F]/g;
|
|
8
9
|
// Match <event .../> or <event> but not <events>
|
|
9
10
|
export const REGEX_EVENT = /(<event[ >][\s\S]*?<\/event>)([\s\S]*)/;
|
|
11
|
+
const DEFAULT_WRITE_QUEUE_SIZE = 10_000;
|
|
12
|
+
const DEFAULT_SOCKET_BATCH_SIZE = 64;
|
|
10
13
|
export default class TAK extends EventEmitter {
|
|
11
14
|
id;
|
|
12
15
|
type;
|
|
@@ -14,12 +17,18 @@ export default class TAK extends EventEmitter {
|
|
|
14
17
|
auth;
|
|
15
18
|
open;
|
|
16
19
|
destroyed;
|
|
17
|
-
queue;
|
|
18
20
|
writing;
|
|
21
|
+
writeQueueSize;
|
|
22
|
+
socketBatchSize;
|
|
19
23
|
cotOptions;
|
|
20
24
|
pingInterval;
|
|
21
25
|
client;
|
|
22
26
|
version;
|
|
27
|
+
// Hybrid pipeline:
|
|
28
|
+
// write() serializes CoTs upfront into a bounded ring buffer of XML strings.
|
|
29
|
+
// process() drains the ring buffer to the socket, driven by drain events.
|
|
30
|
+
// Fully caller-safe: CoT objects can be mutated/GC'd after write() returns.
|
|
31
|
+
queue;
|
|
23
32
|
/**
|
|
24
33
|
* @param url - Full URL of Streaming COT Endpoint IE: "https://ops.cotak.gov:8089"
|
|
25
34
|
* @param auth - TAK Certificate Pair
|
|
@@ -36,10 +45,13 @@ export default class TAK extends EventEmitter {
|
|
|
36
45
|
this.url = url;
|
|
37
46
|
this.auth = auth;
|
|
38
47
|
this.writing = false;
|
|
48
|
+
this.writeQueueSize = opts.writeQueueSize || DEFAULT_WRITE_QUEUE_SIZE;
|
|
49
|
+
this.socketBatchSize =
|
|
50
|
+
opts.socketBatchSize || DEFAULT_SOCKET_BATCH_SIZE;
|
|
39
51
|
this.cotOptions = opts.cot || {};
|
|
40
52
|
this.open = false;
|
|
41
53
|
this.destroyed = false;
|
|
42
|
-
this.queue =
|
|
54
|
+
this.queue = new Queue(this.writeQueueSize);
|
|
43
55
|
}
|
|
44
56
|
static async connect(url, auth, opts = {}) {
|
|
45
57
|
const tak = new TAK(url, auth, opts);
|
|
@@ -57,7 +69,15 @@ export default class TAK extends EventEmitter {
|
|
|
57
69
|
connect_ssl() {
|
|
58
70
|
return new Promise((resolve) => {
|
|
59
71
|
this.destroyed = false;
|
|
60
|
-
this.
|
|
72
|
+
this.open = false;
|
|
73
|
+
// Capture the socket in a local variable so that event handlers
|
|
74
|
+
// registered on *this* socket can detect when they are stale
|
|
75
|
+
// (i.e. a reconnect has already created a newer socket) and
|
|
76
|
+
// bail out early. Without this guard, the old socket's delayed
|
|
77
|
+
// `close` event fires AFTER connect_ssl() sets this.destroyed=false
|
|
78
|
+
// for the new connection and incorrectly calls this.destroy(),
|
|
79
|
+
// killing the newly-created socket with no retry triggered.
|
|
80
|
+
const client = tls.connect({
|
|
61
81
|
host: this.url.hostname,
|
|
62
82
|
port: parseInt(this.url.port),
|
|
63
83
|
rejectUnauthorized: this.auth.rejectUnauthorized ?? false,
|
|
@@ -66,33 +86,45 @@ export default class TAK extends EventEmitter {
|
|
|
66
86
|
passphrase: this.auth.passphrase,
|
|
67
87
|
ca: this.auth.ca,
|
|
68
88
|
});
|
|
69
|
-
this.client
|
|
70
|
-
|
|
89
|
+
this.client = client;
|
|
90
|
+
client.setNoDelay();
|
|
91
|
+
client.on('connect', () => {
|
|
92
|
+
if (client !== this.client)
|
|
93
|
+
return;
|
|
71
94
|
console.error(`ok - ${this.id} @ connect:${this.client ? this.client.authorized : 'NO CLIENT'} - ${this.client ? this.client.authorizationError : 'NO CLIENT'}`);
|
|
72
95
|
});
|
|
73
|
-
|
|
96
|
+
client.on('secureConnect', () => {
|
|
97
|
+
if (client !== this.client)
|
|
98
|
+
return;
|
|
74
99
|
console.error(`ok - ${this.id} @ secure:${this.client ? this.client.authorized : 'NO CLIENT'} - ${this.client ? this.client.authorizationError : 'NO CLIENT'}`);
|
|
75
100
|
this.emit('secureConnect');
|
|
76
101
|
this.ping();
|
|
77
102
|
});
|
|
78
103
|
let buff = '';
|
|
79
|
-
|
|
104
|
+
client
|
|
105
|
+
.on('data', async (data) => {
|
|
106
|
+
if (client !== this.client)
|
|
107
|
+
return;
|
|
80
108
|
// Eventually Parse ProtoBuf
|
|
81
109
|
buff = buff + data.toString();
|
|
82
110
|
let result = TAK.findCoT(buff);
|
|
83
111
|
while (result && result.event) {
|
|
84
112
|
try {
|
|
85
|
-
const cot =
|
|
113
|
+
const cot = CoTParser.from_xml(result.event, this.cotOptions);
|
|
86
114
|
if (cot.raw.event._attributes.type === 't-x-c-t-r') {
|
|
87
115
|
this.open = true;
|
|
88
116
|
this.emit('ping');
|
|
89
117
|
}
|
|
90
|
-
else if (cot.raw.event._attributes.type ===
|
|
91
|
-
&&
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
else if (cot.raw.event._attributes.type ===
|
|
119
|
+
't-x-takp-v' &&
|
|
120
|
+
cot.raw.event.detail &&
|
|
121
|
+
cot.raw.event.detail.TakControl &&
|
|
122
|
+
cot.raw.event.detail.TakControl
|
|
123
|
+
.TakServerVersionInfo &&
|
|
124
|
+
cot.raw.event.detail.TakControl
|
|
125
|
+
.TakServerVersionInfo._attributes) {
|
|
126
|
+
this.version =
|
|
127
|
+
cot.raw.event.detail.TakControl.TakServerVersionInfo._attributes.serverVersion;
|
|
96
128
|
}
|
|
97
129
|
else {
|
|
98
130
|
this.emit('cot', cot);
|
|
@@ -104,13 +136,47 @@ export default class TAK extends EventEmitter {
|
|
|
104
136
|
buff = result.remainder;
|
|
105
137
|
result = TAK.findCoT(buff);
|
|
106
138
|
}
|
|
107
|
-
})
|
|
139
|
+
})
|
|
140
|
+
.on('timeout', () => {
|
|
141
|
+
if (client !== this.client)
|
|
142
|
+
return;
|
|
108
143
|
this.emit('timeout');
|
|
109
|
-
})
|
|
144
|
+
})
|
|
145
|
+
.on('error', (err) => {
|
|
146
|
+
if (client !== this.client)
|
|
147
|
+
return;
|
|
148
|
+
console.error(`[socket] error:`, err.message);
|
|
110
149
|
this.emit('error', err);
|
|
111
|
-
})
|
|
150
|
+
})
|
|
151
|
+
.on('end', () => {
|
|
152
|
+
if (client !== this.client)
|
|
153
|
+
return;
|
|
112
154
|
this.open = false;
|
|
113
155
|
this.emit('end');
|
|
156
|
+
// After emitting 'end', a reconnect triggered synchronously
|
|
157
|
+
// by a listener may have already replaced this.client with
|
|
158
|
+
// a fresh socket and reset this.destroyed to false.
|
|
159
|
+
// Re-check socket identity so we don't destroy the
|
|
160
|
+
// newly-created socket.
|
|
161
|
+
if (client === this.client && !this.destroyed) {
|
|
162
|
+
this.destroy();
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
.on('close', () => {
|
|
166
|
+
if (client !== this.client)
|
|
167
|
+
return;
|
|
168
|
+
if (!this.destroyed) {
|
|
169
|
+
this.destroy();
|
|
170
|
+
// Emit 'close' so consumers can trigger a retry when
|
|
171
|
+
// the socket closes without a preceding 'end' event
|
|
172
|
+
// (e.g. TCP RST where only error+close fires).
|
|
173
|
+
this.emit('close');
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
.on('drain', () => {
|
|
177
|
+
if (client !== this.client)
|
|
178
|
+
return;
|
|
179
|
+
this.process();
|
|
114
180
|
});
|
|
115
181
|
this.pingInterval = setInterval(() => {
|
|
116
182
|
this.ping();
|
|
@@ -131,64 +197,147 @@ export default class TAK extends EventEmitter {
|
|
|
131
197
|
this.destroyed = true;
|
|
132
198
|
if (this.client) {
|
|
133
199
|
this.client.destroy();
|
|
200
|
+
this.client.removeAllListeners();
|
|
201
|
+
this.client = undefined;
|
|
134
202
|
}
|
|
135
203
|
if (this.pingInterval) {
|
|
136
204
|
clearInterval(this.pingInterval);
|
|
137
205
|
this.pingInterval = undefined;
|
|
138
206
|
}
|
|
207
|
+
// Unblock any flush() waiters
|
|
208
|
+
this.emit('_flushed');
|
|
139
209
|
}
|
|
140
210
|
async ping() {
|
|
141
211
|
this.write([CoT.ping()]);
|
|
142
212
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Drain the queue to the socket.
|
|
215
|
+
*
|
|
216
|
+
* Pops pre-serialized XML strings from the ring buffer, batches them
|
|
217
|
+
* (up to `socketBatchSize` per call), and writes to the socket. Runs
|
|
218
|
+
* synchronously in a single event loop tick until the socket signals
|
|
219
|
+
* backpressure or the queue is empty.
|
|
220
|
+
*
|
|
221
|
+
* Called when the socket signals readiness:
|
|
222
|
+
* - `'drain'` event (socket buffer cleared, ready for more)
|
|
223
|
+
* - After `write()` enqueues new items
|
|
224
|
+
*
|
|
225
|
+
* Emits `'_flushed'` when the queue drains to zero, waking any
|
|
226
|
+
* pending `flush()` calls.
|
|
227
|
+
*/
|
|
228
|
+
process() {
|
|
229
|
+
if (this.writing)
|
|
230
|
+
return;
|
|
231
|
+
if (!this.client || this.destroyed)
|
|
232
|
+
return;
|
|
153
233
|
this.writing = true;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
234
|
+
try {
|
|
235
|
+
while (this.queue.length > 0) {
|
|
236
|
+
if (this.destroyed || !this.client)
|
|
237
|
+
break;
|
|
238
|
+
if (this.client.writableNeedDrain)
|
|
239
|
+
break;
|
|
240
|
+
const batchCount = Math.min(this.socketBatchSize, this.queue.length);
|
|
241
|
+
const parts = new Array(batchCount);
|
|
242
|
+
for (let i = 0; i < batchCount; i++) {
|
|
243
|
+
const xml = this.queue.pop();
|
|
244
|
+
if (!xml)
|
|
245
|
+
break;
|
|
246
|
+
parts[i] = xml;
|
|
247
|
+
}
|
|
248
|
+
const ok = this.client.write(parts.join('\n') + '\n');
|
|
249
|
+
if (!ok)
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
159
252
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.process();
|
|
164
|
-
});
|
|
253
|
+
catch (err) {
|
|
254
|
+
this.destroy();
|
|
255
|
+
this.emit('error', err);
|
|
165
256
|
}
|
|
166
|
-
|
|
257
|
+
finally {
|
|
167
258
|
this.writing = false;
|
|
259
|
+
// Safety net: if a drain event fired while writing=true (and was
|
|
260
|
+
// therefore ignored), re-check. If the socket has capacity, reschedule
|
|
261
|
+
// on the next event loop turn so I/O callbacks can run first.
|
|
262
|
+
if (this.queue.length > 0 &&
|
|
263
|
+
!this.destroyed &&
|
|
264
|
+
this.client &&
|
|
265
|
+
!this.client.writableNeedDrain) {
|
|
266
|
+
setImmediate(() => this.process());
|
|
267
|
+
}
|
|
268
|
+
if (this.queue.length === 0) {
|
|
269
|
+
this.emit('_flushed');
|
|
270
|
+
}
|
|
168
271
|
}
|
|
169
272
|
}
|
|
170
273
|
/**
|
|
171
|
-
* Write
|
|
274
|
+
* Write CoTs to the TAK connection.
|
|
275
|
+
*
|
|
276
|
+
* Serializes each CoT to XML upfront and stores the string in a bounded
|
|
277
|
+
* ring buffer. Fully caller-safe: CoT objects can be mutated or GC'd
|
|
278
|
+
* immediately after this returns.
|
|
279
|
+
* Resolves when all items are queued (not when sent over the wire).
|
|
280
|
+
* Use flush() to wait for delivery.
|
|
172
281
|
*
|
|
173
|
-
* @param
|
|
282
|
+
* @param cots Array of CoT objects to send
|
|
174
283
|
*/
|
|
175
284
|
async write(cots) {
|
|
176
|
-
for (
|
|
177
|
-
this.
|
|
178
|
-
|
|
179
|
-
|
|
285
|
+
for (let i = 0; i < cots.length;) {
|
|
286
|
+
if (this.destroyed)
|
|
287
|
+
return;
|
|
288
|
+
// Serialize upfront and push XML strings into the ring buffer
|
|
289
|
+
while (i < cots.length &&
|
|
290
|
+
this.queue.push(CoTParser.to_xml(cots[i]))) {
|
|
291
|
+
i++;
|
|
292
|
+
}
|
|
293
|
+
// Kick process to start draining
|
|
180
294
|
this.process();
|
|
295
|
+
// Queue full — yield to let process() drain via I/O callbacks,
|
|
296
|
+
// then retry on the next event loop turn.
|
|
297
|
+
if (i < cots.length) {
|
|
298
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
299
|
+
}
|
|
181
300
|
}
|
|
182
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Wait until all queued CoTs have been flushed to the socket.
|
|
304
|
+
*
|
|
305
|
+
* write() is a fast "enqueue" — it returns once items are in the queue,
|
|
306
|
+
* NOT once they've been sent over the wire.
|
|
307
|
+
*
|
|
308
|
+
* Resolves immediately if nothing is queued.
|
|
309
|
+
* Rejects if the connection is destroyed before flush completes.
|
|
310
|
+
*/
|
|
311
|
+
async flush() {
|
|
312
|
+
if (this.queue.length === 0 && !this.writing)
|
|
313
|
+
return;
|
|
314
|
+
return new Promise((resolve, reject) => {
|
|
315
|
+
const check = () => {
|
|
316
|
+
if (this.destroyed) {
|
|
317
|
+
cleanup();
|
|
318
|
+
reject(new Error('connection destroyed before flush completed'));
|
|
319
|
+
}
|
|
320
|
+
else if (this.queue.length === 0 && !this.writing) {
|
|
321
|
+
cleanup();
|
|
322
|
+
resolve();
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
const cleanup = () => {
|
|
326
|
+
this.removeListener('_flushed', check);
|
|
327
|
+
};
|
|
328
|
+
this.on('_flushed', check);
|
|
329
|
+
check();
|
|
330
|
+
});
|
|
331
|
+
}
|
|
183
332
|
write_xml(body) {
|
|
184
333
|
this.queue.push(body);
|
|
185
|
-
if (this.queue.length && !this.writing) {
|
|
334
|
+
if (this.queue.length > 0 && !this.writing) {
|
|
186
335
|
this.process();
|
|
187
336
|
}
|
|
188
337
|
}
|
|
189
338
|
// https://github.com/vidterra/multitak/blob/main/app/lib/helper.js#L4
|
|
190
339
|
static findCoT(str) {
|
|
191
|
-
str = str.replace(REGEX_CONTROL,
|
|
340
|
+
str = str.replace(REGEX_CONTROL, '');
|
|
192
341
|
const match = str.match(REGEX_EVENT); // find first CoT
|
|
193
342
|
if (!match)
|
|
194
343
|
return null;
|
|
@@ -200,5 +349,5 @@ export default class TAK extends EventEmitter {
|
|
|
200
349
|
}
|
|
201
350
|
export * from './lib/api.js';
|
|
202
351
|
export { CommandOutputFormat } from './lib/commands.js';
|
|
203
|
-
export {
|
|
352
|
+
export { CoT, TAKAPI };
|
|
204
353
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,YAAY,MAAM,aAAa,CAAC;AAEvC,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,cAAc,eAAe,CAAC;AAE9B,qCAAqC;AACrC,MAAM,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D,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,OAAO;YACH,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACf,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;SACtB,CAAC;IACN,CAAC;CACJ;AAED,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class Queue<T> {
|
|
2
|
+
private buffer;
|
|
3
|
+
private capacity;
|
|
4
|
+
private head;
|
|
5
|
+
private tail;
|
|
6
|
+
private _length;
|
|
7
|
+
constructor(capacity?: number);
|
|
8
|
+
push(item: T): boolean;
|
|
9
|
+
peek(): T | undefined;
|
|
10
|
+
pop(): T | undefined;
|
|
11
|
+
get length(): number;
|
|
12
|
+
get isFull(): boolean;
|
|
13
|
+
}
|