From cc9953e04c78deb78f2e45acb80d44239740132c Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Fri, 14 Jun 2024 12:00:28 +0200 Subject: [PATCH] Extract user-agent agent into constants --- src/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2dc7b81..840cee5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,9 @@ const DEFAULT_ADDRESS = process.platform === 'win32' ? { port: 27015 } : { path: '/var/run/usbmuxd' }; +const CLIENT_VERSION = 'usbmux-client'; +const PROG_NAME = 'usbmux-client'; + function plistSerialize(value: any) { const plistString = plist.build(value) const plistBuffer = Buffer.from(plistString, 'utf8'); @@ -35,8 +38,8 @@ const swap16bitEndianness = (port: number) => { function requestTunnelMessage(deviceId: number, port: number) { return plistSerialize({ MessageType: 'Connect', - ClientVersionString: 'usbmux-client', - ProgName: 'usbmux-client', + ClientVersionString: CLIENT_VERSION, + ProgName: PROG_NAME, DeviceID: deviceId, PortNumber: swap16bitEndianness(port) }); @@ -188,8 +191,8 @@ export class UsbmuxClient { // Start listening for connected devices: conn.write(plistSerialize({ MessageType: 'Listen', - ClientVersionString: 'usbmux-client', - ProgName: 'usbmux-client' + ClientVersionString: CLIENT_VERSION, + ProgName: PROG_NAME })); const response = await readPlistMessageFromStream(conn);