From 1acf896ca759119a823644c9ecf334f6a01e1620 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Fri, 14 Jun 2024 11:56:55 +0200 Subject: [PATCH] Improve compatibility of device scanning Previously this worked on Linux, but seems to be rejected by Mac without this change, despite the public docs I can see saying the opposite. --- src/index.ts | 2 +- test/unit-tests.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index f2145cb..dd30e1e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ function plistSerialize(value: any) { const plistBuffer = Buffer.from(plistString, 'utf8'); const length = 16 + plistBuffer.byteLength; // Header always 16 bytes - const version = 0; // Also called 'reserved'? Always 0 + const version = 1; // Also called 'reserved' - some docs say 0, but only 1 seems to work const messageType = 8; // 8 is 'plist' message type const tag = 1; // Echoed in responses, not used for now diff --git a/test/unit-tests.spec.ts b/test/unit-tests.spec.ts index 50dea19..28533fd 100644 --- a/test/unit-tests.spec.ts +++ b/test/unit-tests.spec.ts @@ -10,7 +10,7 @@ import { delay } from '@httptoolkit/util'; // Various Base64 encoded messages we expect or use as test data: const MESSAGES = { - LISTEN_REQUEST: "hwEAAAAAAAAIAAAAAQAAADw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04Ij8+CjwhRE9DVFlQRSBwbGlzdCBQVUJMSUMgIi0vL0FwcGxlLy9EVEQgUExJU1QgMS4wLy9FTiIgImh0dHA6Ly93d3cuYXBwbGUuY29tL0RURHMvUHJvcGVydHlMaXN0LTEuMC5kdGQiPgo8cGxpc3QgdmVyc2lvbj0iMS4wIj4KICA8ZGljdD4KICAgIDxrZXk+TWVzc2FnZVR5cGU8L2tleT4KICAgIDxzdHJpbmc+TGlzdGVuPC9zdHJpbmc+CiAgICA8a2V5PkNsaWVudFZlcnNpb25TdHJpbmc8L2tleT4KICAgIDxzdHJpbmc+dXNibXV4LWNsaWVudDwvc3RyaW5nPgogICAgPGtleT5Qcm9nTmFtZ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