From 0d6b1d161b88bff17757309981b519a2664dadf2 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Sun, 26 Aug 2018 01:45:11 +0200 Subject: [PATCH 1/4] web_service: Unify links for web service endpoints --- src/citra/config.cpp | 9 ++------ src/citra/default_ini.h | 8 ++----- src/citra_qt/configuration/config.cpp | 26 +++++------------------ src/core/announce_multiplayer_session.cpp | 2 +- src/core/settings.h | 4 +--- src/core/telemetry_session.cpp | 7 +++--- 6 files changed, 15 insertions(+), 41 deletions(-) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 07bb36ffe..e30efc450 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -229,13 +229,8 @@ void Config::ReadValues() { // Web Service Settings::values.enable_telemetry = sdl2_config->GetBoolean("WebService", "enable_telemetry", true); - Settings::values.telemetry_endpoint_url = sdl2_config->Get( - "WebService", "telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry"); - Settings::values.verify_endpoint_url = sdl2_config->Get( - "WebService", "verify_endpoint_url", "https://services.citra-emu.org/api/profile"); - Settings::values.announce_multiplayer_room_endpoint_url = - sdl2_config->Get("WebService", "announce_multiplayer_room_endpoint_url", - "https://services.citra-emu.org/api/multiplayer/rooms"); + Settings::values.web_services_endpoint_url = + sdl2_config->Get("WebService", "web_services_endpoint_url", "https://api.citra-emu.org"); Settings::values.citra_username = sdl2_config->Get("WebService", "citra_username", ""); Settings::values.citra_token = sdl2_config->Get("WebService", "citra_token", ""); } diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 246ae51a9..d7389e789 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -245,12 +245,8 @@ gdbstub_port=24689 # Whether or not to enable telemetry # 0: No, 1 (default): Yes enable_telemetry = -# Endpoint URL for submitting telemetry data -telemetry_endpoint_url = https://services.citra-emu.org/api/telemetry -# Endpoint URL to verify the username and token -verify_endpoint_url = https://services.citra-emu.org/api/profile -# Endpoint URL for announcing public rooms -announce_multiplayer_room_endpoint_url = https://services.citra-emu.org/api/multiplayer/rooms +# Endpoint URL for web services +web_services_endpoint_url = https://api.citra-emu.org # Username and token for Citra Web Service # See https://services.citra-emu.org/ for more info citra_username = diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 5e16a02ef..3f6897743 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -191,17 +191,8 @@ void Config::ReadValues() { qt_config->beginGroup("WebService"); Settings::values.enable_telemetry = ReadSetting("enable_telemetry", true).toBool(); - Settings::values.telemetry_endpoint_url = - ReadSetting("telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry") - .toString() - .toStdString(); - Settings::values.verify_endpoint_url = - ReadSetting("verify_endpoint_url", "https://services.citra-emu.org/api/profile") - .toString() - .toStdString(); - Settings::values.announce_multiplayer_room_endpoint_url = - ReadSetting("announce_multiplayer_room_endpoint_url", - "https://services.citra-emu.org/api/multiplayer/rooms") + Settings::values.web_services_endpoint_url = + ReadSetting("web_services_endpoint_url", "https://api.citra-emu.org") .toString() .toStdString(); Settings::values.citra_username = ReadSetting("citra_username").toString().toStdString(); @@ -435,16 +426,9 @@ void Config::SaveValues() { qt_config->beginGroup("WebService"); WriteSetting("enable_telemetry", Settings::values.enable_telemetry, true); - WriteSetting("telemetry_endpoint_url", - QString::fromStdString(Settings::values.telemetry_endpoint_url), - "https://services.citra-emu.org/api/telemetry"); - WriteSetting("verify_endpoint_url", - QString::fromStdString(Settings::values.verify_endpoint_url), - "https://services.citra-emu.org/api/profile"); - WriteSetting("announce_multiplayer_room_endpoint_url", - QString::fromStdString(Settings::values.announce_multiplayer_room_endpoint_url), - "https://services.citra-emu.org/" - "api/multiplayer/rooms"); + WriteSetting("web_services_endpoint_url", + QString::fromStdString(Settings::values.web_services_endpoint_url), + "https://api.citra-emu.org"); WriteSetting("citra_username", QString::fromStdString(Settings::values.citra_username)); WriteSetting("citra_token", QString::fromStdString(Settings::values.citra_token)); qt_config->endGroup(); diff --git a/src/core/announce_multiplayer_session.cpp b/src/core/announce_multiplayer_session.cpp index b6a224ad6..74f1d6a20 100644 --- a/src/core/announce_multiplayer_session.cpp +++ b/src/core/announce_multiplayer_session.cpp @@ -22,7 +22,7 @@ static constexpr std::chrono::seconds announce_time_interval(15); AnnounceMultiplayerSession::AnnounceMultiplayerSession() { #ifdef ENABLE_WEB_SERVICE backend = std::make_unique( - Settings::values.announce_multiplayer_room_endpoint_url, Settings::values.citra_username, + Settings::values.web_services_endpoint_url + "/lobby", Settings::values.citra_username, Settings::values.citra_token); #else backend = std::make_unique(); diff --git a/src/core/settings.h b/src/core/settings.h index 37a5e42ee..fecc92b7a 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -165,9 +165,7 @@ struct Values { // WebService bool enable_telemetry; - std::string telemetry_endpoint_url; - std::string verify_endpoint_url; - std::string announce_multiplayer_room_endpoint_url; + std::string web_services_endpoint_url; std::string citra_username; std::string citra_token; } extern values; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index ccb954e8a..484c41727 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -82,7 +82,8 @@ u64 RegenerateTelemetryId() { std::future VerifyLogin(std::string username, std::string token, std::function func) { #ifdef ENABLE_WEB_SERVICE - return WebService::VerifyLogin(username, token, Settings::values.verify_endpoint_url, func); + return WebService::VerifyLogin(username, token, + Settings::values.web_services_endpoint_url + "/profile", func); #else return std::async(std::launch::async, [func{std::move(func)}]() { func(); @@ -95,8 +96,8 @@ TelemetrySession::TelemetrySession() { #ifdef ENABLE_WEB_SERVICE if (Settings::values.enable_telemetry) { backend = std::make_unique( - Settings::values.telemetry_endpoint_url, Settings::values.citra_username, - Settings::values.citra_token); + Settings::values.web_services_endpoint_url + "/telemetry", + Settings::values.citra_username, Settings::values.citra_token); } else { backend = std::make_unique(); } From 73a38c62440ec8a6354bd9a8818d21262562bad4 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Sun, 26 Aug 2018 02:14:12 +0200 Subject: [PATCH 2/4] Fix compilation --- src/dedicated_room/citra-room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dedicated_room/citra-room.cpp b/src/dedicated_room/citra-room.cpp index bd3ebfbc1..594f7fcc7 100644 --- a/src/dedicated_room/citra-room.cpp +++ b/src/dedicated_room/citra-room.cpp @@ -166,7 +166,7 @@ int main(int argc, char** argv) { } if (announce) { std::cout << "Hosting a public room\n\n"; - Settings::values.announce_multiplayer_room_endpoint_url = announce_url; + Settings::values.web_services_endpoint_url = announce_url; Settings::values.citra_username = username; Settings::values.citra_token = token; } From d408f89a912aff80ac05550b1c535c3234d0d525 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Mon, 27 Aug 2018 23:09:29 +0200 Subject: [PATCH 3/4] Rename announce-url, use variable for JWT retrieval url --- src/dedicated_room/citra-room.cpp | 14 +++++++------- src/web_service/web_backend.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dedicated_room/citra-room.cpp b/src/dedicated_room/citra-room.cpp index 594f7fcc7..368fc2e47 100644 --- a/src/dedicated_room/citra-room.cpp +++ b/src/dedicated_room/citra-room.cpp @@ -42,7 +42,7 @@ static void PrintHelp(const char* argv0) { "--preferred-game-id The preferred game-id for this room\n" "--username The username used for announce\n" "--token The token used for announce\n" - "--announce-url The url to the announce server\n" + "--endpoint-url The endpoint url to the announce server\n" "-h, --help Display this help and exit\n" "-v, --version Output version information and exit\n"; } @@ -65,7 +65,7 @@ int main(int argc, char** argv) { std::string preferred_game; std::string username; std::string token; - std::string announce_url; + std::string endpoint_url; u64 preferred_game_id = 0; u32 port = Network::DefaultRoomPort; u32 max_members = 16; @@ -79,7 +79,7 @@ int main(int argc, char** argv) { {"preferred-game-id", required_argument, 0, 'i'}, {"username", required_argument, 0, 'u'}, {"token", required_argument, 0, 't'}, - {"announce-url", required_argument, 0, 'a'}, + {"endpoint-url", required_argument, 0, 'a'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0}, @@ -114,7 +114,7 @@ int main(int argc, char** argv) { token.assign(optarg); break; case 'a': - announce_url.assign(optarg); + endpoint_url.assign(optarg); break; case 'h': PrintHelp(argv[0]); @@ -160,13 +160,13 @@ int main(int argc, char** argv) { announce = false; std::cout << "token is empty: Hosting a private room\n\n"; } - if (announce_url.empty() && announce) { + if (endpoint_url.empty() && announce) { announce = false; - std::cout << "announce url is empty: Hosting a private room\n\n"; + std::cout << "endpoint url is empty: Hosting a private room\n\n"; } if (announce) { std::cout << "Hosting a public room\n\n"; - Settings::values.web_services_endpoint_url = announce_url; + Settings::values.web_services_endpoint_url = endpoint_url; Settings::values.citra_username = username; Settings::values.citra_token = token; } diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index b50635d7b..b7f0b1c55 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp @@ -25,8 +25,8 @@ std::string UpdateCoreJWT(bool force_new_token, const std::string& username, static std::string jwt; if (jwt.empty() || force_new_token) { if (!username.empty() && !token.empty()) { - std::future future = - PostJson("https://api.citra-emu.org/jwt/internal", username, token); + std::future future = PostJson( + Settings::values.web_services_endpoint_url + "/jwt/internal", username, token); jwt = future.get().returned_data; } } From b82bf1ccdb68bdf037d3d57763feb0b655894101 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Wed, 12 Sep 2018 19:07:06 +0200 Subject: [PATCH 4/4] Change variable name to web_api_url --- src/citra/config.cpp | 4 ++-- src/citra/default_ini.h | 4 ++-- src/citra_qt/configuration/config.cpp | 9 +++------ src/core/announce_multiplayer_session.cpp | 6 +++--- src/core/settings.h | 2 +- src/core/telemetry_session.cpp | 8 ++++---- src/dedicated_room/citra-room.cpp | 12 ++++++------ src/web_service/web_backend.cpp | 4 ++-- 8 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index e30efc450..88ce9463f 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -229,8 +229,8 @@ void Config::ReadValues() { // Web Service Settings::values.enable_telemetry = sdl2_config->GetBoolean("WebService", "enable_telemetry", true); - Settings::values.web_services_endpoint_url = - sdl2_config->Get("WebService", "web_services_endpoint_url", "https://api.citra-emu.org"); + Settings::values.web_api_url = + sdl2_config->Get("WebService", "web_api_url", "https://api.citra-emu.org"); Settings::values.citra_username = sdl2_config->Get("WebService", "citra_username", ""); Settings::values.citra_token = sdl2_config->Get("WebService", "citra_token", ""); } diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index d7389e789..d05fc6bbc 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -245,8 +245,8 @@ gdbstub_port=24689 # Whether or not to enable telemetry # 0: No, 1 (default): Yes enable_telemetry = -# Endpoint URL for web services -web_services_endpoint_url = https://api.citra-emu.org +# URL for Web API +web_api_url = https://api.citra-emu.org # Username and token for Citra Web Service # See https://services.citra-emu.org/ for more info citra_username = diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 3f6897743..46b5028ef 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -191,10 +191,8 @@ void Config::ReadValues() { qt_config->beginGroup("WebService"); Settings::values.enable_telemetry = ReadSetting("enable_telemetry", true).toBool(); - Settings::values.web_services_endpoint_url = - ReadSetting("web_services_endpoint_url", "https://api.citra-emu.org") - .toString() - .toStdString(); + Settings::values.web_api_url = + ReadSetting("web_api_url", "https://api.citra-emu.org").toString().toStdString(); Settings::values.citra_username = ReadSetting("citra_username").toString().toStdString(); Settings::values.citra_token = ReadSetting("citra_token").toString().toStdString(); qt_config->endGroup(); @@ -426,8 +424,7 @@ void Config::SaveValues() { qt_config->beginGroup("WebService"); WriteSetting("enable_telemetry", Settings::values.enable_telemetry, true); - WriteSetting("web_services_endpoint_url", - QString::fromStdString(Settings::values.web_services_endpoint_url), + WriteSetting("web_api_url", QString::fromStdString(Settings::values.web_api_url), "https://api.citra-emu.org"); WriteSetting("citra_username", QString::fromStdString(Settings::values.citra_username)); WriteSetting("citra_token", QString::fromStdString(Settings::values.citra_token)); diff --git a/src/core/announce_multiplayer_session.cpp b/src/core/announce_multiplayer_session.cpp index 74f1d6a20..efbe6cc5c 100644 --- a/src/core/announce_multiplayer_session.cpp +++ b/src/core/announce_multiplayer_session.cpp @@ -21,9 +21,9 @@ static constexpr std::chrono::seconds announce_time_interval(15); AnnounceMultiplayerSession::AnnounceMultiplayerSession() { #ifdef ENABLE_WEB_SERVICE - backend = std::make_unique( - Settings::values.web_services_endpoint_url + "/lobby", Settings::values.citra_username, - Settings::values.citra_token); + backend = std::make_unique(Settings::values.web_api_url + "/lobby", + Settings::values.citra_username, + Settings::values.citra_token); #else backend = std::make_unique(); #endif diff --git a/src/core/settings.h b/src/core/settings.h index fecc92b7a..929db156c 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -165,7 +165,7 @@ struct Values { // WebService bool enable_telemetry; - std::string web_services_endpoint_url; + std::string web_api_url; std::string citra_username; std::string citra_token; } extern values; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 484c41727..04ab300f8 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -82,8 +82,8 @@ u64 RegenerateTelemetryId() { std::future VerifyLogin(std::string username, std::string token, std::function func) { #ifdef ENABLE_WEB_SERVICE - return WebService::VerifyLogin(username, token, - Settings::values.web_services_endpoint_url + "/profile", func); + return WebService::VerifyLogin(username, token, Settings::values.web_api_url + "/profile", + func); #else return std::async(std::launch::async, [func{std::move(func)}]() { func(); @@ -96,8 +96,8 @@ TelemetrySession::TelemetrySession() { #ifdef ENABLE_WEB_SERVICE if (Settings::values.enable_telemetry) { backend = std::make_unique( - Settings::values.web_services_endpoint_url + "/telemetry", - Settings::values.citra_username, Settings::values.citra_token); + Settings::values.web_api_url + "/telemetry", Settings::values.citra_username, + Settings::values.citra_token); } else { backend = std::make_unique(); } diff --git a/src/dedicated_room/citra-room.cpp b/src/dedicated_room/citra-room.cpp index 368fc2e47..9d4dc2a92 100644 --- a/src/dedicated_room/citra-room.cpp +++ b/src/dedicated_room/citra-room.cpp @@ -42,7 +42,7 @@ static void PrintHelp(const char* argv0) { "--preferred-game-id The preferred game-id for this room\n" "--username The username used for announce\n" "--token The token used for announce\n" - "--endpoint-url The endpoint url to the announce server\n" + "--web-api-url Citra Web API url\n" "-h, --help Display this help and exit\n" "-v, --version Output version information and exit\n"; } @@ -65,7 +65,7 @@ int main(int argc, char** argv) { std::string preferred_game; std::string username; std::string token; - std::string endpoint_url; + std::string web_api_url; u64 preferred_game_id = 0; u32 port = Network::DefaultRoomPort; u32 max_members = 16; @@ -79,7 +79,7 @@ int main(int argc, char** argv) { {"preferred-game-id", required_argument, 0, 'i'}, {"username", required_argument, 0, 'u'}, {"token", required_argument, 0, 't'}, - {"endpoint-url", required_argument, 0, 'a'}, + {"web-api-url", required_argument, 0, 'a'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0}, @@ -114,7 +114,7 @@ int main(int argc, char** argv) { token.assign(optarg); break; case 'a': - endpoint_url.assign(optarg); + web_api_url.assign(optarg); break; case 'h': PrintHelp(argv[0]); @@ -160,13 +160,13 @@ int main(int argc, char** argv) { announce = false; std::cout << "token is empty: Hosting a private room\n\n"; } - if (endpoint_url.empty() && announce) { + if (web_api_url.empty() && announce) { announce = false; std::cout << "endpoint url is empty: Hosting a private room\n\n"; } if (announce) { std::cout << "Hosting a public room\n\n"; - Settings::values.web_services_endpoint_url = endpoint_url; + Settings::values.web_api_url = web_api_url; Settings::values.citra_username = username; Settings::values.citra_token = token; } diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index b7f0b1c55..3659fe4ff 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp @@ -25,8 +25,8 @@ std::string UpdateCoreJWT(bool force_new_token, const std::string& username, static std::string jwt; if (jwt.empty() || force_new_token) { if (!username.empty() && !token.empty()) { - std::future future = PostJson( - Settings::values.web_services_endpoint_url + "/jwt/internal", username, token); + std::future future = + PostJson(Settings::values.web_api_url + "/jwt/internal", username, token); jwt = future.get().returned_data; } }