Use HTTPS for infra DNS when supported

Select the metadata URL based on the platform HTTPS capability so

legacy platforms continue using HTTP while capable platforms avoid

downgradeable transport. Keep cache lookup and invalidation on the

same URL.
This commit is contained in:
Acts1631 committed 2026-09-07 14:51:47 -04:00
1 parent e4b5511f31
commit 4d51079ea8
1 file changed
+10 -4
+10 -4
View File
@@ -31,6 +31,7 @@
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/Serialize/SerializeMap.h"
#include "Common/Data/Format/JSONReader.h"
#include "Common/System/System.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/ErrorCodes.h"
#include "Core/HLE/FunctionWrappers.h"
@@ -382,10 +383,15 @@ bool LoadAutoDNS(std::string_view json) {
std::shared_ptr<http::Request> g_infraDL;
static const std::string_view jsonUrl = "https://metadata.ppsspp.org/infra-dns.json";
static constexpr std::string_view jsonUrlHttp = "http://metadata.ppsspp.org/infra-dns.json";
static constexpr std::string_view jsonUrlHttps = "https://metadata.ppsspp.org/infra-dns.json";
static std::string_view GetInfraDNSUrl() {
return System_GetPropertyBool(SYSPROP_SUPPORTS_HTTPS) ? jsonUrlHttps : jsonUrlHttp;
}
void DeleteAutoDNSCacheFile() {
File::Delete(g_DownloadManager.UrlToCachePath(jsonUrl));
File::Delete(g_DownloadManager.UrlToCachePath(GetInfraDNSUrl()));
}
void StartInfraJsonDownload() {
@@ -399,7 +405,7 @@ void StartInfraJsonDownload() {
if (!g_Config.bDontDownloadInfraJson) {
const char * const acceptMime = "application/json, text/*; q=0.9, */*; q=0.8";
g_infraDL = g_DownloadManager.StartDownload(jsonUrl, Path(), http::RequestFlags::Cached24H, acceptMime);
g_infraDL = g_DownloadManager.StartDownload(GetInfraDNSUrl(), Path(), http::RequestFlags::Cached24H, acceptMime);
}
}
@@ -444,7 +450,7 @@ bool PollInfraJsonDownload(std::string *jsonOutput) {
// First, fall back to cache if it exists. Could build this functionality into the download manager
// but it would be a bit awkward.
std::string json;
if (File::ReadBinaryFileToString(g_DownloadManager.UrlToCachePath(jsonUrl), &json) && !json.empty()) {
if (File::ReadBinaryFileToString(g_DownloadManager.UrlToCachePath(GetInfraDNSUrl()), &json) && !json.empty()) {
WARN_LOG(Log::sceNet, "Failed to download infra-dns.json, falling back to cached file");
*jsonOutput = json;
LoadAutoDNS(*jsonOutput);