From 377c9bc831acea8087b3c2f1b557fce3e6c87874 Mon Sep 17 00:00:00 2001 From: spectranator Date: Wed, 8 May 2024 17:47:00 +0200 Subject: [PATCH] Implemented safer and faster way to get current mirror URL --- src/yuzu/main.cpp | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e2266bc9e7..6c58c5558e 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -3520,38 +3520,18 @@ void GMainWindow::OpenURL(const QUrl& url) { } void GMainWindow::OnOpenMirrorRepo() { - struct Mirror { - const char *host, *path; - }; - const std::initializer_list mirrors = { - {"https://github.com", "/litucks/torzu"}, - {"https://gitlab.com", "/litucks/torzu"}, - {"https://bitbucket.org", "/litucks/torzu"}, - {"https://codeberg.org", "/litucks/torzu"}, - {"https://notabug.org", "/litucks/torzu"}, - {"https://gitea.com", "/litucks/torzu"}, - {"https://try.gitea.io", "/litucks/torzu"}, - {"https://git.math.hamburg", "/litucks/torzu"}, - {"https://gitea.sprint-pay.com", "/litucks/torzu"}, - {"https://gitea.djoe.ovh", "/litucks/torzu"}, - {"https://git.sheetjs.com", "/litucks/torzu"}, - {"https://gitea.cisetech.com", "/litucks/torzu"} - }; - - for (const auto& mirror : mirrors) { - httplib::Client cli(mirror.host); - if (cli.Get(mirror.path)) { - OpenURL(QUrl(QString::fromStdString(fmt::format("{}{}", mirror.host, mirror.path)))); - return; - } + httplib::Client cli("https://codeberg.org"); + auto res = cli.Get("/litucks/tz-mu/raw/branch/main/mu.txt"); + if (!res) { + QMessageBox::warning(this, tr("Error locating mirror"), tr("There has been an error finding the current mirror repository.
" + "Your version may be too old or your network connectivity may be" + "limited.
" + "Please either try again later, through a VPN or access the main
" + "repository via the Tor Browser:
" + "http://y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion/torzu-emu/torzu")); } - QMessageBox::warning(this, tr("Error locating mirror"), tr("There has been an error finding the current mirror repository.\n" - "Your version may be so old the list has already been depleted\n" - "or your network connectivity may be limited.\n" - "Please either try again later, through a VPN or access the main\n" - "repository via the Tor Browser:\n" - "http://y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion/torzu-emu/torzu")); + OpenURL(QUrl(QString::fromStdString(res->body))); } void GMainWindow::ToggleFullscreen() {