Compare commits

...

2 commits

Author SHA1 Message Date
crueter
c05d999225
[bcat] Fix news to use Forgejo releases instead (#3841)
Some checks are pending
tx-src / sources (push) Waiting to run
Check Strings / check-strings (push) Waiting to run
Signed-off-by: crueter <crueter@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3841
2026-04-08 22:09:55 +02:00
crueter
71d3dd67d3
[frontend] Force https on bundled OpenSSL (#3843)
For some unknown reason, bundled OpenSSL likes the `https` scheme,
whereas system OpenSSL (on Gentoo at least) does not... even when the
bundled OpenSSL is built exactly like the Gentoo one, certificate and
all...

Signed-off-by: crueter <crueter@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3843
2026-04-08 21:27:10 +02:00
2 changed files with 56 additions and 21 deletions

View file

@ -35,7 +35,8 @@
namespace Service::News { namespace Service::News {
namespace { namespace {
constexpr const char* GitHubAPI_EdenReleases = "/repos/eden-emulator/Releases/releases"; // TODO(crueter): COMPILE DEFINITION
constexpr const char* GitHubAPI_EdenReleases = "/api/v1/repos/eden-emu/eden/releases";
// Cached logo data // Cached logo data
std::vector<u8> default_logo_small; std::vector<u8> default_logo_small;
@ -227,22 +228,58 @@ void WriteCachedJson(std::string_view json) {
std::optional<std::string> DownloadReleasesJson() { std::optional<std::string> DownloadReleasesJson() {
try { try {
httplib::SSLClient cli{"api.github.com", 443};
cli.set_connection_timeout(10);
cli.set_read_timeout(10);
httplib::Headers headers{
{"User-Agent", "Eden"},
{"Accept", "application/vnd.github+json"},
};
// TODO(crueter): automate this in some way...
#ifdef YUZU_BUNDLED_OPENSSL #ifdef YUZU_BUNDLED_OPENSSL
cli.load_ca_cert_store(kCert, sizeof(kCert)); const auto url = "https://git.eden-emu.dev";
#else
const auto url = "git.eden-emu.dev";
#endif #endif
if (auto res = cli.Get(GitHubAPI_EdenReleases, headers); res && res->status < 400) { // TODO(crueter): This is duplicated between frontend and here.
return res->body; constexpr auto path = GitHubAPI_EdenReleases;
constexpr std::size_t timeout_seconds = 15;
std::unique_ptr<httplib::Client> client = std::make_unique<httplib::Client>(url);
client->set_connection_timeout(timeout_seconds);
client->set_read_timeout(timeout_seconds);
client->set_write_timeout(timeout_seconds);
#ifdef YUZU_BUNDLED_OPENSSL
client->load_ca_cert_store(kCert, sizeof(kCert));
#endif
if (client == nullptr) {
LOG_ERROR(Service_BCAT, "Invalid URL {}{}", url, path);
return {};
}
httplib::Request request{
.method = "GET",
.path = path,
};
client->set_follow_location(true);
httplib::Result result = client->send(request);
if (!result) {
LOG_ERROR(Service_BCAT, "GET to {}{} returned null", url, path);
return {};
} else if (result->status < 400) {
return result->body;
}
if (result->status >= 400) {
LOG_ERROR(Service_BCAT,
"GET to {}{} returned error status code: {}",
url,
path,
result->status);
return {};
}
if (!result->headers.contains("content-type")) {
LOG_ERROR(Service_BCAT, "GET to {}{} returned no content", url, path);
return {};
} }
} catch (...) { } catch (...) {
LOG_WARNING(Service_BCAT, " failed to download releases"); LOG_WARNING(Service_BCAT, " failed to download releases");
@ -332,7 +369,7 @@ std::string FormatBody(const nlohmann::json& release, std::string_view title) {
body.pop_back(); body.pop_back();
} }
body += "\n\n... View more on GitHub"; body += "\n\n... View more on Forgejo";
} }
return body; return body;
@ -489,7 +526,7 @@ std::vector<u8> BuildMsgpack(std::string_view title, std::string_view body,
w.WriteString(""); w.WriteString("");
w.WriteKey("allow_domains"); w.WriteKey("allow_domains");
w.WriteString("^https?://github.com(/|$)"); w.WriteString("^https?://git.eden-emu.dev(/|$)");
// More link // More link
w.WriteKey("more"); w.WriteKey("more");
@ -499,7 +536,7 @@ std::vector<u8> BuildMsgpack(std::string_view title, std::string_view body,
w.WriteKey("url"); w.WriteKey("url");
w.WriteString(html_url); w.WriteString(html_url);
w.WriteKey("text"); w.WriteKey("text");
w.WriteString("Open GitHub"); w.WriteString("Open Forgejo");
// Body // Body
w.WriteKey("body"); w.WriteKey("body");
@ -536,7 +573,7 @@ void EnsureBuiltinNewsLoaded() {
if (const auto fresh = DownloadReleasesJson()) { if (const auto fresh = DownloadReleasesJson()) {
WriteCachedJson(*fresh); WriteCachedJson(*fresh);
ImportReleases(*fresh); ImportReleases(*fresh);
LOG_DEBUG(Service_BCAT, "news: {} entries updated from GitHub", NewsStorage::Instance().ListAll().size()); LOG_DEBUG(Service_BCAT, "news: {} entries updated from Forgejo", NewsStorage::Instance().ListAll().size());
} }
}).detach(); }).detach();
}); });

View file

@ -81,9 +81,7 @@ std::optional<std::string> UpdateChecker::GetResponse(std::string url, std::stri
} }
std::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease(bool include_prereleases) { std::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease(bool include_prereleases) {
// For some unbeknownst reason, only Android likes when https is specified. #ifdef YUZU_BUNDLED_OPENSSL
// Consider dropping support for this radioactive platform.
#ifdef __ANDROID__
const auto update_check_url = fmt::format("https://{}", Common::g_build_auto_update_api); const auto update_check_url = fmt::format("https://{}", Common::g_build_auto_update_api);
#else #else
const auto update_check_url = std::string{Common::g_build_auto_update_api}; const auto update_check_url = std::string{Common::g_build_auto_update_api};