aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/masterserver.cpp
diff options
context:
space:
mode:
authorEmma Miler <27428383+emma-miler@users.noreply.github.com>2022-03-26 00:56:52 +0100
committerGitHub <noreply@github.com>2022-03-26 00:56:52 +0100
commitebba08beb9e3227c2b646f83745fc0ce5b142264 (patch)
tree7c78d368aa1bc674a050b6aba12340b6c1ba1b1a /NorthstarDedicatedTest/masterserver.cpp
parentde7deafc7e6ba53deec8dd3c05d2ea5e7cf42264 (diff)
downloadNorthstarLauncher-ebba08beb9e3227c2b646f83745fc0ce5b142264.tar.gz
NorthstarLauncher-ebba08beb9e3227c2b646f83745fc0ce5b142264.zip
Add version numbering to all master server requests (#113)
* Add version numbering to all master server requests * Use "+dev" for user agent if dev version instead of "-dev" * Replace "FindResource" with "FindResourceW" As per code review suggestion https://github.com/R2Northstar/NorthstarLauncher/pull/113#discussion_r834788821 * Set User-Agent in SetCommonHttpClientOptions instead of for each curl call individually As per code review suggestion https://github.com/R2Northstar/NorthstarLauncher/pull/113#discussion_r834789168 Co-authored-by: GeckoEidechse <gecko.eidechse+git@pm.me>
Diffstat (limited to 'NorthstarDedicatedTest/masterserver.cpp')
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index b5f87274..076c0a14 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -13,6 +13,7 @@
#include "misccommands.h"
#include <cstring>
#include <regex>
+#include "version.h"
// NOTE for anyone reading this: we used to use httplib for requests here, but it had issues, so we're moving to curl now for masterserver
// requests so httplib is used exclusively for server stuff now
@@ -169,6 +170,7 @@ void MasterServerManager::SetCommonHttpClientOptions(CURL* curl)
{
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, &NSUserAgent);
// curl_easy_setopt(curl, CURLOPT_STDERR, stdout);
if (CommandLine()->FindParm("-msinsecure")) // TODO: this check doesn't seem to work
{
@@ -210,7 +212,6 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or
CURL* curl = curl_easy_init();
SetCommonHttpClientOptions(curl);
-
std::string readBuffer;
curl_easy_setopt(
curl, CURLOPT_URL,
@@ -556,7 +557,7 @@ void MasterServerManager::AuthenticateWithOwnServer(char* uid, char* playerToken
curl_easy_setopt(
curl, CURLOPT_URL,
fmt::format("{}/client/auth_with_self?id={}&playerToken={}", Cvar_ns_masterserver_hostname->GetString(), uidStr, tokenStr)
- .c_str());
+ .c_str());
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToStringBufferCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
@@ -698,7 +699,7 @@ void MasterServerManager::AuthenticateWithServer(char* uid, char* playerToken, c
fmt::format(
"{}/client/auth_with_server?id={}&playerToken={}&server={}&password={}", Cvar_ns_masterserver_hostname->GetString(),
uidStr, tokenStr, serverIdStr, escapedPassword)
- .c_str());
+ .c_str());
curl_free(escapedPassword);
}
@@ -832,7 +833,7 @@ void MasterServerManager::AddSelfToServerList(
"{}/server/add_server?port={}&authPort={}&name={}&description={}&map={}&playlist={}&maxPlayers={}&password={}",
Cvar_ns_masterserver_hostname->GetString(), port, authPort, nameEscaped, descEscaped, mapEscaped, playlistEscaped,
maxPlayers, passwordEscaped)
- .c_str());
+ .c_str());
curl_free(nameEscaped);
curl_free(descEscaped);
@@ -936,7 +937,7 @@ void MasterServerManager::AddSelfToServerList(
Cvar_ns_player_auth_port->GetInt(), escapedNameNew, escapedDescNew, escapedMapNew,
escapedPlaylistNew, g_ServerAuthenticationManager->m_additionalPlayerData.size(), maxPlayers,
escapedPasswordNew)
- .c_str());
+ .c_str());
curl_free(escapedNameNew);
curl_free(escapedDescNew);
@@ -1037,7 +1038,7 @@ void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist,
fmt::format(
"{}/server/update_values?id={}&map={}&playlist={}&maxPlayers={}", Cvar_ns_masterserver_hostname->GetString(),
m_ownServerId, mapEscaped, playlistEscaped, maxPlayers)
- .c_str());
+ .c_str());
curl_free(mapEscaped);
curl_free(playlistEscaped);
@@ -1076,7 +1077,7 @@ void MasterServerManager::UpdateServerPlayerCount(int playerCount)
curl, CURLOPT_URL,
fmt::format(
"{}/server/update_values?id={}&playerCount={}", Cvar_ns_masterserver_hostname->GetString(), m_ownServerId, playerCount)
- .c_str());
+ .c_str());
CURLcode result = curl_easy_perform(curl);
@@ -1116,7 +1117,7 @@ void MasterServerManager::WritePlayerPersistentData(char* playerId, char* pdata,
fmt::format(
"{}/accounts/write_persistence?id={}&serverId={}", Cvar_ns_masterserver_hostname->GetString(), strPlayerId,
m_ownServerId)
- .c_str());
+ .c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteToStringBufferCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
@@ -1261,7 +1262,7 @@ void CHostState__State_GameShutdownHook(CHostState* hostState)
CHostState__State_GameShutdown(hostState);
}
-MasterServerManager::MasterServerManager() : m_pendingConnectionInfo{}, m_ownServerId{""}, m_ownClientAuthToken{""} {}
+MasterServerManager::MasterServerManager() : m_pendingConnectionInfo{}, m_ownServerId{ "" }, m_ownClientAuthToken{ "" } {}
void InitialiseSharedMasterServer(HMODULE baseAddress)
{