From f6de4f03d74b43d2ee3005ed90aa8f5152e1b331 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 7 Mar 2025 21:04:20 -0700 Subject: [PATCH] ui: Migrate reporter from httplib to libcurl wrapper --- ui/xui/reporting.cc | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/ui/xui/reporting.cc b/ui/xui/reporting.cc index c52bf00076..eb4f8192ac 100644 --- a/ui/xui/reporting.cc +++ b/ui/xui/reporting.cc @@ -3,7 +3,7 @@ // // Title compatibility and bug report submission. // -// Copyright (C) 2020-2021 Matt Borgerson +// Copyright (C) 2020-2025 Matt Borgerson // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -18,15 +18,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . // + +#include "qemu/osdep.h" +#include "qemu/http.h" + #include #include #include #include "reporting.hh" -#include #include using json = nlohmann::json; -#define DEBUG_COMPAT_SERVICE 0 +static const char *compat_report_endpoint_url = "https://reports.xemu.app/compatibility"; CompatibilityReport::CompatibilityReport() { @@ -61,38 +64,16 @@ const std::string &CompatibilityReport::GetSerializedReport() bool CompatibilityReport::Send() { - // Serialize the report const std::string &s = GetSerializedReport(); -#if DEBUG_COMPAT_SERVICE - httplib::SSLClient cli("127.0.0.1", 443); -#else - httplib::SSLClient cli("reports.xemu.app", 443); -#endif - - cli.set_follow_location(true); - // cli.enable_server_certificate_verification(true); // FIXME: Package cert bundle - - auto res = cli.Post("/compatibility", s, "application/json"); - - if (!res) { -#if 0 // FIXME: Handle SSL certificate verification failure -#ifdef CPPHTTPLIB_OPENSSL_SUPPORT - auto result = cli.get_openssl_verify_result(); - if (result) { - fprintf(stderr, "verify error: %s\n", X509_verify_cert_error_string(result)); - } -#endif -#endif - + int res = http_post_json(compat_report_endpoint_url, s.c_str(), NULL); + if (res < 0) { result_code = -1; result_msg = "Failed to connect"; return false; } - result_code = res->status; - - switch(res->status) { + switch(res) { case 200: result_msg = "Ok"; return true; @@ -110,7 +91,7 @@ bool CompatibilityReport::Send() result_msg = "Report too long"; return false; default: - result_msg = "Unknown error occured"; + result_msg = "Unknown error occurred"; return false; } }