From fa2b801690e8f06321adeb742076638d74f09bf6 Mon Sep 17 00:00:00 2001 From: Karutoh Date: Tue, 9 Jul 2024 17:39:01 -0700 Subject: [PATCH] Fixed `Spotify.Play` and fixed `TCP.Connect`. --- src/io/socket/TCP_BSD.cpp | 12 +++++++++++- src/io/socket/TCP_W32.cpp | 12 +++++++++++- src/io/socket/rest/Spotify.cpp | 5 +---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/io/socket/TCP_BSD.cpp b/src/io/socket/TCP_BSD.cpp index c905f2a..734aea5 100644 --- a/src/io/socket/TCP_BSD.cpp +++ b/src/io/socket/TCP_BSD.cpp @@ -213,13 +213,23 @@ namespace ehs return; remoteHostName = address; - remoteAddr = DNS::Resolve(address); remotePort = port; if (addrType == AddrType::IPV6) + { + if (IsIPv6Only()) + remoteAddr = DNS::Resolve(AddrType::IPV6, address); + else + remoteAddr = DNS::Resolve(address); + Connect_v6(remoteAddr, port); + } else if (addrType == AddrType::IPV4) + { + remoteAddr = DNS::Resolve(AddrType::IPV4, address); + Connect_v4(remoteAddr, port); + } connected = true; } diff --git a/src/io/socket/TCP_W32.cpp b/src/io/socket/TCP_W32.cpp index a589953..71fadf8 100644 --- a/src/io/socket/TCP_W32.cpp +++ b/src/io/socket/TCP_W32.cpp @@ -242,13 +242,23 @@ namespace ehs return; remoteHostName = address; - remoteAddr = DNS::Resolve(address); remotePort = port; if (addrType == AddrType::IPV6) + { + if (IsIPv6Only()) + remoteAddr = DNS::Resolve(AddrType::IPV6, address); + else + remoteAddr = DNS::Resolve(address); + Connect_v6(remoteAddr, port); + } else if (addrType == AddrType::IPV4) + { + remoteAddr = DNS::Resolve(AddrType::IPV4, address); + Connect_v4(remoteAddr, port); + } connected = true; } diff --git a/src/io/socket/rest/Spotify.cpp b/src/io/socket/rest/Spotify.cpp index c51a418..83cac55 100644 --- a/src/io/socket/rest/Spotify.cpp +++ b/src/io/socket/rest/Spotify.cpp @@ -155,9 +155,6 @@ namespace ehs Request req(Verb::PUT, "/v1/me/player/play"); req.BearerAuth(token); - client.Release(); - client.Initialize(); - client.Connect("", SSL::HTTPS_Port); client.SendReq(req); Response res = client.RecvRes(); @@ -590,7 +587,7 @@ namespace ehs bool Spotify::ReAuthorize() { - SSL accounts; + SSL accounts(AddrType::IPV4); accounts.Initialize(); accounts.Connect("accounts.spotify.com", SSL::HTTPS_Port);