From cb1cfddb744f4639c2812b4972a4253baffeaedf Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Wed, 26 Jan 2022 22:24:40 +0100 Subject: [PATCH] Send platform-dependent client token request --- core/src/connection/handshake.rs | 6 ++-- core/src/http_client.rs | 2 +- core/src/spclient.rs | 57 ++++++++++++++++++++++++++----- protocol/proto/connectivity.proto | 12 +++++-- 4 files changed, 63 insertions(+), 14 deletions(-) diff --git a/core/src/connection/handshake.rs b/core/src/connection/handshake.rs index 64ed4404..680f512e 100644 --- a/core/src/connection/handshake.rs +++ b/core/src/connection/handshake.rs @@ -111,11 +111,11 @@ where _ => Platform::PLATFORM_FREEBSD_X86, }, "ios" => match ARCH { - "arm64" => Platform::PLATFORM_IPHONE_ARM64, + "aarch64" => Platform::PLATFORM_IPHONE_ARM64, _ => Platform::PLATFORM_IPHONE_ARM, }, "linux" => match ARCH { - "arm" | "arm64" => Platform::PLATFORM_LINUX_ARM, + "arm" | "aarch64" => Platform::PLATFORM_LINUX_ARM, "blackfin" => Platform::PLATFORM_LINUX_BLACKFIN, "mips" => Platform::PLATFORM_LINUX_MIPS, "sh" => Platform::PLATFORM_LINUX_SH, @@ -128,7 +128,7 @@ where _ => Platform::PLATFORM_OSX_X86, }, "windows" => match ARCH { - "arm" => Platform::PLATFORM_WINDOWS_CE_ARM, + "arm" | "aarch64" => Platform::PLATFORM_WINDOWS_CE_ARM, "x86_64" => Platform::PLATFORM_WIN32_X86_64, _ => Platform::PLATFORM_WIN32_X86, }, diff --git a/core/src/http_client.rs b/core/src/http_client.rs index 7a642444..ed7eac6d 100644 --- a/core/src/http_client.rs +++ b/core/src/http_client.rs @@ -86,7 +86,7 @@ impl HttpClient { let spotify_platform = match OS { "android" => "Android/31", - "ios" => "iOS/15.2", + "ios" => "iOS/15.2.1", "macos" => "OSX/0", "windows" => "Win32/0", _ => "Linux/0", diff --git a/core/src/spclient.rs b/core/src/spclient.rs index 7bfa1064..78cccbf0 100644 --- a/core/src/spclient.rs +++ b/core/src/spclient.rs @@ -122,14 +122,55 @@ impl SpClient { connectivity_data.set_device_id(self.session().device_id().to_string()); let platform_data = connectivity_data.mut_platform_specific_data(); - let windows_data = platform_data.mut_windows(); - windows_data.set_os_version(10); - windows_data.set_os_build(21370); - windows_data.set_platform_id(2); - windows_data.set_unknown_value_6(9); - windows_data.set_image_file_machine(332); - windows_data.set_pe_machine(34404); - windows_data.set_unknown_value_10(true); + + match std::env::consts::OS { + "windows" => { + let (pe, image_file) = match std::env::consts::ARCH { + "arm" => (448, 452), + "aarch64" => (43620, 452), + "x86_64" => (34404, 34404), + _ => (332, 332), // x86 + }; + + let windows_data = platform_data.mut_desktop_windows(); + windows_data.set_os_version(10); + windows_data.set_os_build(21370); + windows_data.set_platform_id(2); + windows_data.set_unknown_value_6(9); + windows_data.set_image_file_machine(image_file); + windows_data.set_pe_machine(pe); + windows_data.set_unknown_value_10(true); + } + "ios" => { + let ios_data = platform_data.mut_ios(); + ios_data.set_user_interface_idiom(0); + ios_data.set_target_iphone_simulator(false); + ios_data.set_hw_machine("iPhone14,5".to_string()); + ios_data.set_system_version("15.2.1".to_string()); + } + "android" => { + let android_data = platform_data.mut_android(); + android_data.set_android_version("12.0.0_r26".to_string()); + android_data.set_api_version(31); + android_data.set_device_name("Pixel".to_owned()); + android_data.set_model_str("GF5KQ".to_owned()); + android_data.set_vendor("Google".to_owned()); + } + "macos" => { + let macos_data = platform_data.mut_desktop_macos(); + macos_data.set_system_version("Darwin Kernel Version 17.7.0: Fri Oct 30 13:34:27 PDT 2020; root:xnu-4570.71.82.8~1/RELEASE_X86_64".to_string()); + macos_data.set_hw_model("iMac21,1".to_string()); + macos_data.set_compiled_cpu_type(std::env::consts::ARCH.to_string()); + } + _ => { + let linux_data = platform_data.mut_desktop_linux(); + linux_data.set_system_name("Linux".to_string()); + linux_data.set_system_release("5.4.0-56-generic".to_string()); + linux_data + .set_system_version("#62-Ubuntu SMP Mon Nov 23 19:20:19 UTC 2020".to_string()); + linux_data.set_hardware(std::env::consts::ARCH.to_string()); + } + } let body = message.write_to_bytes()?; diff --git a/protocol/proto/connectivity.proto b/protocol/proto/connectivity.proto index f1623b41..ec85e4f9 100644 --- a/protocol/proto/connectivity.proto +++ b/protocol/proto/connectivity.proto @@ -15,7 +15,8 @@ message PlatformSpecificData { oneof data { NativeAndroidData android = 1; NativeIOSData ios = 2; - NativeWindowsData windows = 4; + NativeDesktopMacOSData desktop_macos = 3; + NativeDesktopWindowsData desktop_windows = 4; NativeDesktopLinuxData desktop_linux = 5; } } @@ -32,6 +33,7 @@ message NativeAndroidData { } message NativeIOSData { + // https://developer.apple.com/documentation/uikit/uiuserinterfaceidiom int32 user_interface_idiom = 1; bool target_iphone_simulator = 2; string hw_machine = 3; @@ -39,7 +41,7 @@ message NativeIOSData { string simulator_model_identifier = 5; } -message NativeWindowsData { +message NativeDesktopWindowsData { int32 os_version = 1; int32 os_build = 3; // https://docs.microsoft.com/en-us/dotnet/api/system.platformid?view=net-6.0 @@ -60,6 +62,12 @@ message NativeDesktopLinuxData { string hardware = 4; // -i } +message NativeDesktopMacOSData { + string system_version = 1; + string hw_model = 2; + string compiled_cpu_type = 3; +} + message Screen { int32 width = 1; int32 height = 2;