@basmilius/apple-common 0.6.4 → 0.6.6
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/index.js +15 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -281,8 +281,10 @@ class Connection extends EventEmitter {
|
|
|
281
281
|
return new Promise((resolve, reject) => {
|
|
282
282
|
this.#state = "connecting";
|
|
283
283
|
this.#connectPromise = { resolve, reject };
|
|
284
|
+
this.#socket?.removeAllListeners();
|
|
284
285
|
this.#socket = undefined;
|
|
285
286
|
this.#socket = new Socket;
|
|
287
|
+
this.#socket.setNoDelay(true);
|
|
286
288
|
this.#socket.setTimeout(SOCKET_TIMEOUT);
|
|
287
289
|
this.#socket.on("close", this.#onClose.bind(this));
|
|
288
290
|
this.#socket.on("connect", this.#onConnect.bind(this));
|
|
@@ -318,6 +320,10 @@ class Connection extends EventEmitter {
|
|
|
318
320
|
this.#connectPromise = undefined;
|
|
319
321
|
return;
|
|
320
322
|
}
|
|
323
|
+
if (this.#retryTimeout) {
|
|
324
|
+
clearTimeout(this.#retryTimeout);
|
|
325
|
+
this.#retryTimeout = undefined;
|
|
326
|
+
}
|
|
321
327
|
this.#retryAttempt++;
|
|
322
328
|
this.#context.logger.net(`Retry attempt ${this.#retryAttempt} / ${this.#retryAttempts} in ${this.#retryInterval}ms...`);
|
|
323
329
|
const { resolve, reject } = this.#connectPromise ?? NOOP_PROMISE_HANDLER;
|
|
@@ -787,8 +793,9 @@ class TimingServer {
|
|
|
787
793
|
constructor() {
|
|
788
794
|
this.#logger = new Logger("timing-server");
|
|
789
795
|
this.#socket = createSocket("udp4");
|
|
790
|
-
this.#socket.on("
|
|
791
|
-
this.#socket.on("
|
|
796
|
+
this.#socket.on("connect", this.#onConnect.bind(this));
|
|
797
|
+
this.#socket.on("error", this.#onError.bind(this));
|
|
798
|
+
this.#socket.on("message", this.#onMessage.bind(this));
|
|
792
799
|
}
|
|
793
800
|
async close() {
|
|
794
801
|
this.#socket.close();
|
|
@@ -800,6 +807,10 @@ class TimingServer {
|
|
|
800
807
|
this.#socket.bind(0, resolve);
|
|
801
808
|
});
|
|
802
809
|
}
|
|
810
|
+
#onConnect() {
|
|
811
|
+
this.#socket.setRecvBufferSize(16384);
|
|
812
|
+
this.#socket.setSendBufferSize(16384);
|
|
813
|
+
}
|
|
803
814
|
async#onError(err) {
|
|
804
815
|
this.#logger.error("Timing server error", err);
|
|
805
816
|
}
|
|
@@ -875,13 +886,13 @@ function randomInt64() {
|
|
|
875
886
|
return randomBytes(8).readBigUint64LE(0);
|
|
876
887
|
}
|
|
877
888
|
function uint16ToBE(value) {
|
|
878
|
-
const buffer = Buffer.
|
|
889
|
+
const buffer = Buffer.allocUnsafe(2);
|
|
879
890
|
buffer.writeUInt16BE(value, 0);
|
|
880
891
|
return buffer;
|
|
881
892
|
}
|
|
882
893
|
function uint53ToLE(value) {
|
|
883
894
|
const [upper, lower] = splitUInt53(value);
|
|
884
|
-
const buffer = Buffer.
|
|
895
|
+
const buffer = Buffer.allocUnsafe(8);
|
|
885
896
|
buffer.writeUInt32LE(lower, 0);
|
|
886
897
|
buffer.writeUInt32LE(upper, 4);
|
|
887
898
|
return buffer;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basmilius/apple-common",
|
|
3
3
|
"description": "Common features shared across various apple protocol packages.",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@basmilius/apple-encoding": "0.6.
|
|
43
|
-
"@basmilius/apple-encryption": "0.6.
|
|
42
|
+
"@basmilius/apple-encoding": "0.6.6",
|
|
43
|
+
"@basmilius/apple-encryption": "0.6.6",
|
|
44
44
|
"fast-srp-hap": "^2.0.4",
|
|
45
45
|
"node-dns-sd": "^1.0.1"
|
|
46
46
|
},
|