Rename announce-url, use variable for JWT retrieval url

This commit is contained in:
fearlessTobi 2018-08-27 23:09:29 +02:00
parent 73a38c6244
commit d408f89a91
2 changed files with 9 additions and 9 deletions

View file

@ -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" "--endpoint-url The endpoint url to the announce server\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 endpoint_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'}, {"endpoint-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); endpoint_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 (endpoint_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.web_services_endpoint_url = announce_url; Settings::values.web_services_endpoint_url = endpoint_url;
Settings::values.citra_username = username; Settings::values.citra_username = username;
Settings::values.citra_token = token; Settings::values.citra_token = token;
} }

View file

@ -25,8 +25,8 @@ std::string UpdateCoreJWT(bool force_new_token, const std::string& username,
static std::string jwt; static std::string jwt;
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(
PostJson("https://api.citra-emu.org/jwt/internal", username, token); Settings::values.web_services_endpoint_url + "/jwt/internal", username, token);
jwt = future.get().returned_data; jwt = future.get().returned_data;
} }
} }