aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-11-13 18:37:46 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-11-13 18:37:46 +0000
commit3d3d2c2a13a292a9093ad3029563a1c543a07ab7 (patch)
tree60812cb186f9429d7002879167e4102e353ee2d1 /NorthstarDedicatedTest
parentae09e612ea33cb105a47996c4ae3bf8651119042 (diff)
downloadNorthstarLauncher-3d3d2c2a13a292a9093ad3029563a1c543a07ab7.tar.gz
NorthstarLauncher-3d3d2c2a13a292a9093ad3029563a1c543a07ab7.zip
client auth token support
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp10
-rw-r--r--NorthstarDedicatedTest/masterserver.h1
-rw-r--r--NorthstarDedicatedTest/misccommands.cpp2
-rw-r--r--NorthstarDedicatedTest/scriptmodmenu.cpp18
-rw-r--r--NorthstarDedicatedTest/scriptserverbrowser.cpp4
-rw-r--r--NorthstarDedicatedTest/securitypatches.cpp1
6 files changed, 21 insertions, 15 deletions
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index 9ac88667..1d639f28 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -84,7 +84,7 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or
spdlog::info("Trying to authenticate with northstar masterserver for user {} {}", uidStr, tokenStr);
- if (auto result = http.Get(fmt::format("/client/origin_auth?uid={}&token={}", uidStr, tokenStr).c_str()))
+ if (auto result = http.Get(fmt::format("/client/origin_auth?id={}&token={}", uidStr, tokenStr).c_str()))
{
m_successfullyConnected = true;
@@ -103,8 +103,12 @@ void MasterServerManager::AuthenticateOriginWithMasterServer(char* uid, char* or
goto REQUEST_END_CLEANUP;
}
- if (originAuthInfo["success"].IsTrue())
+ if (originAuthInfo["success"].IsTrue() && originAuthInfo.HasMember("token") && originAuthInfo["token"].IsString())
+ {
+ strncpy(m_ownClientAuthToken, originAuthInfo["token"].GetString(), sizeof(m_ownClientAuthToken));
+ m_ownClientAuthToken[sizeof(m_ownClientAuthToken) - 1] = 0;
spdlog::info("Northstar origin authentication completed successfully!");
+ }
else
spdlog::error("Northstar origin authentication failed");
}
@@ -324,7 +328,7 @@ void MasterServerManager::AuthenticateWithOwnServer(char* uid, char* playerToken
goto REQUEST_END_CLEANUP;
}
- newAuthData.pdata[i++] = byte.GetUint();
+ newAuthData.pdata[i++] = (char)byte.GetUint();
}
std::lock_guard<std::mutex> guard(g_ServerAuthenticationManager->m_authDataMutex);
diff --git a/NorthstarDedicatedTest/masterserver.h b/NorthstarDedicatedTest/masterserver.h
index 911555d1..97f5bdce 100644
--- a/NorthstarDedicatedTest/masterserver.h
+++ b/NorthstarDedicatedTest/masterserver.h
@@ -48,6 +48,7 @@ private:
public:
char m_ownServerId[33];
+ char m_ownClientAuthToken[33];
bool m_bOriginAuthWithMasterServerDone = false;
bool m_bOriginAuthWithMasterServerInProgress = false;
diff --git a/NorthstarDedicatedTest/misccommands.cpp b/NorthstarDedicatedTest/misccommands.cpp
index cc6f816d..f7ccbe2c 100644
--- a/NorthstarDedicatedTest/misccommands.cpp
+++ b/NorthstarDedicatedTest/misccommands.cpp
@@ -19,7 +19,7 @@ void SelfAuthAndLeaveToLobbyCommand(const CCommand& arg)
// hack for special case where we're on a local server, so we erase our own newly created auth data on disconnect
g_MasterServerManager->m_bNewgameAfterSelfAuth = true;
- g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, (char*)"");
+ g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, g_MasterServerManager->m_ownClientAuthToken);
}
void EndSelfAuthAndLeaveToLobbyCommand(const CCommand& arg)
diff --git a/NorthstarDedicatedTest/scriptmodmenu.cpp b/NorthstarDedicatedTest/scriptmodmenu.cpp
index 141fdf75..d7c675ea 100644
--- a/NorthstarDedicatedTest/scriptmodmenu.cpp
+++ b/NorthstarDedicatedTest/scriptmodmenu.cpp
@@ -5,7 +5,7 @@
#include "dedicated.h"
// array<string> NSGetModNames()
-SQInteger SQ_GetModNames(void* sqvm)
+SQRESULT SQ_GetModNames(void* sqvm)
{
ClientSq_newarray(sqvm, 0);
@@ -19,7 +19,7 @@ SQInteger SQ_GetModNames(void* sqvm)
}
// bool NSIsModEnabled(string modName)
-SQInteger SQ_IsModEnabled(void* sqvm)
+SQRESULT SQ_IsModEnabled(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
@@ -37,7 +37,7 @@ SQInteger SQ_IsModEnabled(void* sqvm)
}
// void NSSetModEnabled(string modName, bool enabled)
-SQInteger SQ_SetModEnabled(void* sqvm)
+SQRESULT SQ_SetModEnabled(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
const SQBool enabled = ClientSq_getbool(sqvm, 2);
@@ -56,7 +56,7 @@ SQInteger SQ_SetModEnabled(void* sqvm)
}
// string NSGetModDescriptionByModName(string modName)
-SQInteger SQ_GetModDescription(void* sqvm)
+SQRESULT SQ_GetModDescription(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
@@ -74,7 +74,7 @@ SQInteger SQ_GetModDescription(void* sqvm)
}
// string NSGetModVersionByModName(string modName)
-SQInteger SQ_GetModVersion(void* sqvm)
+SQRESULT SQ_GetModVersion(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
@@ -92,7 +92,7 @@ SQInteger SQ_GetModVersion(void* sqvm)
}
// string NSGetModDownloadLinkByModName(string modName)
-SQInteger SQ_GetModDownloadLink(void* sqvm)
+SQRESULT SQ_GetModDownloadLink(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
@@ -110,7 +110,7 @@ SQInteger SQ_GetModDownloadLink(void* sqvm)
}
// int NSGetModLoadPriority(string modName)
-SQInteger SQ_GetModLoadPriority(void* sqvm)
+SQRESULT SQ_GetModLoadPriority(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
@@ -128,7 +128,7 @@ SQInteger SQ_GetModLoadPriority(void* sqvm)
}
// bool NSIsModRequiredOnClient(string modName)
-SQInteger SQ_IsModRequiredOnClient(void* sqvm)
+SQRESULT SQ_IsModRequiredOnClient(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
@@ -146,7 +146,7 @@ SQInteger SQ_IsModRequiredOnClient(void* sqvm)
}
// array<string> NSGetModConvarsByModName(string modName)
-SQInteger SQ_GetModConvars(void* sqvm)
+SQRESULT SQ_GetModConvars(void* sqvm)
{
const SQChar* modName = ClientSq_getstring(sqvm, 1);
ClientSq_newarray(sqvm, 0);
diff --git a/NorthstarDedicatedTest/scriptserverbrowser.cpp b/NorthstarDedicatedTest/scriptserverbrowser.cpp
index 096e84df..1cc4e62e 100644
--- a/NorthstarDedicatedTest/scriptserverbrowser.cpp
+++ b/NorthstarDedicatedTest/scriptserverbrowser.cpp
@@ -243,7 +243,7 @@ SQRESULT SQ_TryAuthWithServer(void* sqvm)
g_ServerAuthenticationManager->WritePersistentData(pair.first);
// do auth
- g_MasterServerManager->AuthenticateWithServer(g_LocalPlayerUserID, (char*)"", g_MasterServerManager->m_remoteServers[serverIndex].id, (char*)password);
+ g_MasterServerManager->AuthenticateWithServer(g_LocalPlayerUserID, g_MasterServerManager->m_ownClientAuthToken, g_MasterServerManager->m_remoteServers[serverIndex].id, (char*)password);
return SQRESULT_NULL;
}
@@ -286,7 +286,7 @@ SQRESULT SQ_ConnectToAuthedServer(void* sqvm)
SQRESULT SQ_TryAuthWithLocalServer(void* sqvm)
{
// do auth request
- g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, (char*)"");
+ g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, g_MasterServerManager->m_ownClientAuthToken);
return SQRESULT_NULL;
}
diff --git a/NorthstarDedicatedTest/securitypatches.cpp b/NorthstarDedicatedTest/securitypatches.cpp
index cbb5a292..dacc075c 100644
--- a/NorthstarDedicatedTest/securitypatches.cpp
+++ b/NorthstarDedicatedTest/securitypatches.cpp
@@ -27,6 +27,7 @@ void InitialiseClientEngineSecurityPatches(HMODULE baseAddress)
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x1C6360, &IsValveModHook, reinterpret_cast<LPVOID*>(&IsValveMod));
// patches to make commands run from client/ui script still work
+ // note: this is likely preventable in a nicer way? test prolly
{
void* ptr = (char*)baseAddress + 0x4FB65;
TempReadWrite rw(ptr);