Merge pull request #4138 from FearlessTobi/change-web-links
web_service: Unify links for web service endpoints
This commit is contained in:
commit
0a4d338ffa
@ -229,13 +229,8 @@ void Config::ReadValues() {
|
|||||||
// Web Service
|
// Web Service
|
||||||
Settings::values.enable_telemetry =
|
Settings::values.enable_telemetry =
|
||||||
sdl2_config->GetBoolean("WebService", "enable_telemetry", true);
|
sdl2_config->GetBoolean("WebService", "enable_telemetry", true);
|
||||||
Settings::values.telemetry_endpoint_url = sdl2_config->Get(
|
Settings::values.web_api_url =
|
||||||
"WebService", "telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry");
|
sdl2_config->Get("WebService", "web_api_url", "https://api.citra-emu.org");
|
||||||
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.citra_username = sdl2_config->Get("WebService", "citra_username", "");
|
Settings::values.citra_username = sdl2_config->Get("WebService", "citra_username", "");
|
||||||
Settings::values.citra_token = sdl2_config->Get("WebService", "citra_token", "");
|
Settings::values.citra_token = sdl2_config->Get("WebService", "citra_token", "");
|
||||||
}
|
}
|
||||||
|
@ -245,12 +245,8 @@ gdbstub_port=24689
|
|||||||
# Whether or not to enable telemetry
|
# Whether or not to enable telemetry
|
||||||
# 0: No, 1 (default): Yes
|
# 0: No, 1 (default): Yes
|
||||||
enable_telemetry =
|
enable_telemetry =
|
||||||
# Endpoint URL for submitting telemetry data
|
# URL for Web API
|
||||||
telemetry_endpoint_url = https://services.citra-emu.org/api/telemetry
|
web_api_url = https://api.citra-emu.org
|
||||||
# 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
|
|
||||||
# Username and token for Citra Web Service
|
# Username and token for Citra Web Service
|
||||||
# See https://services.citra-emu.org/ for more info
|
# See https://services.citra-emu.org/ for more info
|
||||||
citra_username =
|
citra_username =
|
||||||
|
@ -191,19 +191,8 @@ void Config::ReadValues() {
|
|||||||
|
|
||||||
qt_config->beginGroup("WebService");
|
qt_config->beginGroup("WebService");
|
||||||
Settings::values.enable_telemetry = ReadSetting("enable_telemetry", true).toBool();
|
Settings::values.enable_telemetry = ReadSetting("enable_telemetry", true).toBool();
|
||||||
Settings::values.telemetry_endpoint_url =
|
Settings::values.web_api_url =
|
||||||
ReadSetting("telemetry_endpoint_url", "https://services.citra-emu.org/api/telemetry")
|
ReadSetting("web_api_url", "https://api.citra-emu.org").toString().toStdString();
|
||||||
.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")
|
|
||||||
.toString()
|
|
||||||
.toStdString();
|
|
||||||
Settings::values.citra_username = ReadSetting("citra_username").toString().toStdString();
|
Settings::values.citra_username = ReadSetting("citra_username").toString().toStdString();
|
||||||
Settings::values.citra_token = ReadSetting("citra_token").toString().toStdString();
|
Settings::values.citra_token = ReadSetting("citra_token").toString().toStdString();
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
@ -435,16 +424,8 @@ void Config::SaveValues() {
|
|||||||
|
|
||||||
qt_config->beginGroup("WebService");
|
qt_config->beginGroup("WebService");
|
||||||
WriteSetting("enable_telemetry", Settings::values.enable_telemetry, true);
|
WriteSetting("enable_telemetry", Settings::values.enable_telemetry, true);
|
||||||
WriteSetting("telemetry_endpoint_url",
|
WriteSetting("web_api_url", QString::fromStdString(Settings::values.web_api_url),
|
||||||
QString::fromStdString(Settings::values.telemetry_endpoint_url),
|
"https://api.citra-emu.org");
|
||||||
"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("citra_username", QString::fromStdString(Settings::values.citra_username));
|
WriteSetting("citra_username", QString::fromStdString(Settings::values.citra_username));
|
||||||
WriteSetting("citra_token", QString::fromStdString(Settings::values.citra_token));
|
WriteSetting("citra_token", QString::fromStdString(Settings::values.citra_token));
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
|
@ -21,8 +21,8 @@ static constexpr std::chrono::seconds announce_time_interval(15);
|
|||||||
|
|
||||||
AnnounceMultiplayerSession::AnnounceMultiplayerSession() {
|
AnnounceMultiplayerSession::AnnounceMultiplayerSession() {
|
||||||
#ifdef ENABLE_WEB_SERVICE
|
#ifdef ENABLE_WEB_SERVICE
|
||||||
backend = std::make_unique<WebService::RoomJson>(
|
backend = std::make_unique<WebService::RoomJson>(Settings::values.web_api_url + "/lobby",
|
||||||
Settings::values.announce_multiplayer_room_endpoint_url, Settings::values.citra_username,
|
Settings::values.citra_username,
|
||||||
Settings::values.citra_token);
|
Settings::values.citra_token);
|
||||||
#else
|
#else
|
||||||
backend = std::make_unique<AnnounceMultiplayerRoom::NullBackend>();
|
backend = std::make_unique<AnnounceMultiplayerRoom::NullBackend>();
|
||||||
|
@ -165,9 +165,7 @@ struct Values {
|
|||||||
|
|
||||||
// WebService
|
// WebService
|
||||||
bool enable_telemetry;
|
bool enable_telemetry;
|
||||||
std::string telemetry_endpoint_url;
|
std::string web_api_url;
|
||||||
std::string verify_endpoint_url;
|
|
||||||
std::string announce_multiplayer_room_endpoint_url;
|
|
||||||
std::string citra_username;
|
std::string citra_username;
|
||||||
std::string citra_token;
|
std::string citra_token;
|
||||||
} extern values;
|
} extern values;
|
||||||
|
@ -82,7 +82,8 @@ u64 RegenerateTelemetryId() {
|
|||||||
|
|
||||||
std::future<bool> VerifyLogin(std::string username, std::string token, std::function<void()> func) {
|
std::future<bool> VerifyLogin(std::string username, std::string token, std::function<void()> func) {
|
||||||
#ifdef ENABLE_WEB_SERVICE
|
#ifdef ENABLE_WEB_SERVICE
|
||||||
return WebService::VerifyLogin(username, token, Settings::values.verify_endpoint_url, func);
|
return WebService::VerifyLogin(username, token, Settings::values.web_api_url + "/profile",
|
||||||
|
func);
|
||||||
#else
|
#else
|
||||||
return std::async(std::launch::async, [func{std::move(func)}]() {
|
return std::async(std::launch::async, [func{std::move(func)}]() {
|
||||||
func();
|
func();
|
||||||
@ -95,7 +96,7 @@ TelemetrySession::TelemetrySession() {
|
|||||||
#ifdef ENABLE_WEB_SERVICE
|
#ifdef ENABLE_WEB_SERVICE
|
||||||
if (Settings::values.enable_telemetry) {
|
if (Settings::values.enable_telemetry) {
|
||||||
backend = std::make_unique<WebService::TelemetryJson>(
|
backend = std::make_unique<WebService::TelemetryJson>(
|
||||||
Settings::values.telemetry_endpoint_url, Settings::values.citra_username,
|
Settings::values.web_api_url + "/telemetry", Settings::values.citra_username,
|
||||||
Settings::values.citra_token);
|
Settings::values.citra_token);
|
||||||
} else {
|
} else {
|
||||||
backend = std::make_unique<Telemetry::NullVisitor>();
|
backend = std::make_unique<Telemetry::NullVisitor>();
|
||||||
|
@ -42,7 +42,7 @@ static void PrintHelp(const char* argv0) {
|
|||||||
"--preferred-game-id The preferred game-id for this room\n"
|
"--preferred-game-id The preferred game-id for this room\n"
|
||||||
"--username The username used for announce\n"
|
"--username The username used for announce\n"
|
||||||
"--token The token used for announce\n"
|
"--token The token used for announce\n"
|
||||||
"--announce-url The url to the announce server\n"
|
"--web-api-url Citra Web API url\n"
|
||||||
"-h, --help Display this help and exit\n"
|
"-h, --help Display this help and exit\n"
|
||||||
"-v, --version Output version information 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 preferred_game;
|
||||||
std::string username;
|
std::string username;
|
||||||
std::string token;
|
std::string token;
|
||||||
std::string announce_url;
|
std::string web_api_url;
|
||||||
u64 preferred_game_id = 0;
|
u64 preferred_game_id = 0;
|
||||||
u32 port = Network::DefaultRoomPort;
|
u32 port = Network::DefaultRoomPort;
|
||||||
u32 max_members = 16;
|
u32 max_members = 16;
|
||||||
@ -79,7 +79,7 @@ int main(int argc, char** argv) {
|
|||||||
{"preferred-game-id", required_argument, 0, 'i'},
|
{"preferred-game-id", required_argument, 0, 'i'},
|
||||||
{"username", required_argument, 0, 'u'},
|
{"username", required_argument, 0, 'u'},
|
||||||
{"token", required_argument, 0, 't'},
|
{"token", required_argument, 0, 't'},
|
||||||
{"announce-url", required_argument, 0, 'a'},
|
{"web-api-url", required_argument, 0, 'a'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
@ -114,7 +114,7 @@ int main(int argc, char** argv) {
|
|||||||
token.assign(optarg);
|
token.assign(optarg);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
announce_url.assign(optarg);
|
web_api_url.assign(optarg);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
@ -160,13 +160,13 @@ int main(int argc, char** argv) {
|
|||||||
announce = false;
|
announce = false;
|
||||||
std::cout << "token is empty: Hosting a private room\n\n";
|
std::cout << "token is empty: Hosting a private room\n\n";
|
||||||
}
|
}
|
||||||
if (announce_url.empty() && announce) {
|
if (web_api_url.empty() && announce) {
|
||||||
announce = false;
|
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) {
|
if (announce) {
|
||||||
std::cout << "Hosting a public room\n\n";
|
std::cout << "Hosting a public room\n\n";
|
||||||
Settings::values.announce_multiplayer_room_endpoint_url = announce_url;
|
Settings::values.web_api_url = web_api_url;
|
||||||
Settings::values.citra_username = username;
|
Settings::values.citra_username = username;
|
||||||
Settings::values.citra_token = token;
|
Settings::values.citra_token = token;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ std::string UpdateCoreJWT(bool force_new_token, const std::string& username,
|
|||||||
if (jwt.empty() || force_new_token) {
|
if (jwt.empty() || force_new_token) {
|
||||||
if (!username.empty() && !token.empty()) {
|
if (!username.empty() && !token.empty()) {
|
||||||
std::future<Common::WebResult> future =
|
std::future<Common::WebResult> future =
|
||||||
PostJson("https://api.citra-emu.org/jwt/internal", username, token);
|
PostJson(Settings::values.web_api_url + "/jwt/internal", username, token);
|
||||||
jwt = future.get().returned_data;
|
jwt = future.get().returned_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user