@platformatic/kafka 2.4.0 → 2.5.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/dist/network/connection.js +31 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -50,6 +50,7 @@ export class Connection extends TypedEventEmitter {
|
|
|
50
50
|
#responseReader;
|
|
51
51
|
#socket;
|
|
52
52
|
#socketMustBeDrained;
|
|
53
|
+
#detectMissingTLS;
|
|
53
54
|
#reauthenticationTimeout;
|
|
54
55
|
constructor(clientId, options = {}) {
|
|
55
56
|
super();
|
|
@@ -75,6 +76,7 @@ export class Connection extends TypedEventEmitter {
|
|
|
75
76
|
this.#responseBuffer = new DynamicBuffer();
|
|
76
77
|
this.#responseReader = new Reader(this.#responseBuffer);
|
|
77
78
|
this.#socketMustBeDrained = false;
|
|
79
|
+
this.#detectMissingTLS = !this.#options.tls;
|
|
78
80
|
notifyCreation('connection', this);
|
|
79
81
|
}
|
|
80
82
|
/* c8 ignore next 3 - Simple getter */
|
|
@@ -120,6 +122,7 @@ export class Connection extends TypedEventEmitter {
|
|
|
120
122
|
return callback[kCallbackPromise];
|
|
121
123
|
}
|
|
122
124
|
this.#status = ConnectionStatuses.CONNECTING;
|
|
125
|
+
this.#detectMissingTLS = !this.#options.tls;
|
|
123
126
|
const connectionOptions = {
|
|
124
127
|
timeout: this.#options.connectTimeout
|
|
125
128
|
};
|
|
@@ -259,7 +262,7 @@ export class Connection extends TypedEventEmitter {
|
|
|
259
262
|
}
|
|
260
263
|
send(apiKey, apiVersion, createPayload, responseParser, hasRequestHeaderTaggedFields, hasResponseHeaderTaggedFields, callback) {
|
|
261
264
|
// Correlation ID is a 32-bit integer in the protocol, so we need to wrap around after 2^31 - 1
|
|
262
|
-
const correlationId = (this.#correlationId + 1) &
|
|
265
|
+
const correlationId = (this.#correlationId + 1) & 0x7fffffff;
|
|
263
266
|
this.#correlationId = correlationId;
|
|
264
267
|
const diagnostic = createDiagnosticContext({
|
|
265
268
|
connection: this,
|
|
@@ -467,6 +470,27 @@ export class Connection extends TypedEventEmitter {
|
|
|
467
470
|
correlation_id => INT32
|
|
468
471
|
*/
|
|
469
472
|
#onData(chunk) {
|
|
473
|
+
if (this.#detectMissingTLS) {
|
|
474
|
+
this.#detectMissingTLS = false;
|
|
475
|
+
if (this.#isTLSRecord(chunk)) {
|
|
476
|
+
const error = new UserError('Broker requires TLS.');
|
|
477
|
+
this.#status = ConnectionStatuses.ERROR;
|
|
478
|
+
for (const request of this.#afterDrainRequests) {
|
|
479
|
+
if (!request.noResponse) {
|
|
480
|
+
clearTimeout(request.timeoutHandle);
|
|
481
|
+
request.callback(error, undefined);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
this.#afterDrainRequests = [];
|
|
485
|
+
for (const request of this.#inflightRequests.values()) {
|
|
486
|
+
clearTimeout(request.timeoutHandle);
|
|
487
|
+
request.callback(error, undefined);
|
|
488
|
+
}
|
|
489
|
+
this.#inflightRequests.clear();
|
|
490
|
+
this.#socket.destroy();
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
470
494
|
this.#responseBuffer.append(chunk);
|
|
471
495
|
// There is at least one message size to add
|
|
472
496
|
// Note that here the initial position is always 0
|
|
@@ -547,6 +571,12 @@ export class Connection extends TypedEventEmitter {
|
|
|
547
571
|
this.#socketMustBeDrained = false;
|
|
548
572
|
this.emit('drain');
|
|
549
573
|
}
|
|
574
|
+
#isTLSRecord(chunk) {
|
|
575
|
+
return (chunk.length >= 3 &&
|
|
576
|
+
(chunk[0] === 0x14 || chunk[0] === 0x15 || chunk[0] === 0x16 || chunk[0] === 0x17) &&
|
|
577
|
+
chunk[1] === 0x03 &&
|
|
578
|
+
chunk[2] <= 0x04);
|
|
579
|
+
}
|
|
550
580
|
#onClose() {
|
|
551
581
|
this.#status = ConnectionStatuses.CLOSED;
|
|
552
582
|
this.emit('close');
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@platformatic/kafka";
|
|
2
|
-
export const version = "2.
|
|
2
|
+
export const version = "2.5.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/kafka",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Modern and performant client for Apache Kafka",
|
|
5
5
|
"homepage": "https://github.com/platformatic/kafka",
|
|
6
6
|
"author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
|