From fd0baccff21c3816eebae7bd44363020333b2032 Mon Sep 17 00:00:00 2001 From: Daniel Leong Date: Thu, 15 Apr 2021 19:41:50 -0400 Subject: [PATCH] Fix: omitting important keys from PS4 Second Screen query response Fixes #25 --- src/credentials/mim-requester.ts | 4 ++-- src/discovery/model.ts | 5 +++-- src/discovery/udp.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/credentials/mim-requester.ts b/src/credentials/mim-requester.ts index 984aeb1..4cd4730 100644 --- a/src/credentials/mim-requester.ts +++ b/src/credentials/mim-requester.ts @@ -66,7 +66,7 @@ export class MimCredentialRequester implements ICredentialRequester { this.io?.logInfo("Open the PS4 Second Screen app and attempt to connect to the device named:"); this.io?.logInfo(` ${this.emulatorOptions.hostName}`); - debug("emulating device; awaiting WAKE..."); + debug("emulating device", this.emulatorOptions, "awaiting WAKE..."); return this.emulateUntilWoken( sink, network, @@ -85,8 +85,8 @@ export class MimCredentialRequester implements ICredentialRequester { const searchResponse = { "host-id": this.emulatorOptions.hostId, "host-name": this.emulatorOptions.hostName, - "host-type": hostType, "host-request-port": localBindPort, + "host-type": hostType, }; for await (const message of incomingMessages) { diff --git a/src/discovery/model.ts b/src/discovery/model.ts index 8ec7bca..90e3c21 100644 --- a/src/discovery/model.ts +++ b/src/discovery/model.ts @@ -37,9 +37,9 @@ export interface IDeviceAddress { const discoveryKeysArrray = [ "host-id", - "host-type", - "host-request-port", "host-name", + "host-request-port", + "host-type", "system-version", "device-discovery-protocol-version", ] as const; @@ -49,6 +49,7 @@ export type DiscoveryKey = typeof discoveryKeysArrray[number]; const discoveryKeys: Set = new Set(discoveryKeysArrray); export const outgoingDiscoveryKeys = new Set([ + ...discoveryKeysArrray, "app-type", "auth-type", "client-type", diff --git a/src/discovery/udp.ts b/src/discovery/udp.ts index eb492ef..df86e35 100644 --- a/src/discovery/udp.ts +++ b/src/discovery/udp.ts @@ -104,7 +104,7 @@ export class UdpDiscoveryNetwork implements IDiscoveryNetwork { message: Buffer, ) { debug( - "send:", message, " to ", + "send:", message.toString("hex"), " to ", recipientAddress, ":", recipientPort, ); this.socket.send(message, recipientPort, recipientAddress);