aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/serverauthentication.cpp
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-04-20 19:10:26 +0200
committerGitHub <noreply@github.com>2022-04-20 19:10:26 +0200
commit44d1d694982d2a4f302bf7155d4582628f9f32f4 (patch)
tree7cbd75d0eb0464ccd0103424d529fef2000bc0e5 /NorthstarDedicatedTest/serverauthentication.cpp
parent0c7fcc06f0fb072c00729c646773174b273a18b3 (diff)
parent47ea109be0d73120ddfe6896494e1fce986515b3 (diff)
downloadNorthstarLauncher-44d1d694982d2a4f302bf7155d4582628f9f32f4.tar.gz
NorthstarLauncher-44d1d694982d2a4f302bf7155d4582628f9f32f4.zip
Merge branch 'main' into NetCon
Diffstat (limited to 'NorthstarDedicatedTest/serverauthentication.cpp')
-rw-r--r--NorthstarDedicatedTest/serverauthentication.cpp63
1 files changed, 52 insertions, 11 deletions
diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp
index 30eeb553..c9860e02 100644
--- a/NorthstarDedicatedTest/serverauthentication.cpp
+++ b/NorthstarDedicatedTest/serverauthentication.cpp
@@ -19,8 +19,23 @@ const char* AUTHSERVER_VERIFY_STRING = "I am a northstar server!";
// hook types
typedef void* (*CBaseServer__ConnectClientType)(
- void* server, void* a2, void* a3, uint32_t a4, uint32_t a5, int32_t a6, void* a7, void* a8, char* serverFilter, void* a10, char a11,
- void* a12, char a13, char a14, int64_t uid, uint32_t a16, uint32_t a17);
+ void* server,
+ void* a2,
+ void* a3,
+ uint32_t a4,
+ uint32_t a5,
+ int32_t a6,
+ void* a7,
+ void* a8,
+ char* serverFilter,
+ void* a10,
+ char a11,
+ void* a12,
+ char a13,
+ char a14,
+ int64_t uid,
+ uint32_t a16,
+ uint32_t a17);
CBaseServer__ConnectClientType CBaseServer__ConnectClient;
typedef bool (*CBaseClient__ConnectType)(
@@ -82,7 +97,8 @@ void ServerAuthenticationManager::StartPlayerAuthServer()
// this is just a super basic way to verify that servers have ports open, masterserver will try to read this before ensuring
// server is legit
m_playerAuthServer.Get(
- "/verify", [](const httplib::Request& request, httplib::Response& response)
+ "/verify",
+ [](const httplib::Request& request, httplib::Response& response)
{ response.set_content(AUTHSERVER_VERIFY_STRING, "text/plain"); });
m_playerAuthServer.Post(
@@ -312,8 +328,23 @@ char* nextPlayerToken;
uint64_t nextPlayerUid;
void* CBaseServer__ConnectClientHook(
- void* server, void* a2, void* a3, uint32_t a4, uint32_t a5, int32_t a6, void* a7, void* a8, char* serverFilter, void* a10, char a11,
- void* a12, char a13, char a14, int64_t uid, uint32_t a16, uint32_t a17)
+ void* server,
+ void* a2,
+ void* a3,
+ uint32_t a4,
+ uint32_t a5,
+ int32_t a6,
+ void* a7,
+ void* a8,
+ char* serverFilter,
+ void* a10,
+ char a11,
+ void* a12,
+ char a13,
+ char a14,
+ int64_t uid,
+ uint32_t a16,
+ uint32_t a17)
{
// auth tokens are sent with serverfilter, can't be accessed from player struct to my knowledge, so have to do this here
nextPlayerToken = serverFilter;
@@ -486,7 +517,8 @@ char __fastcall CNetChan___ProcessMessagesHook(void* self, void* buf)
Cvar_net_chan_limit_msec_per_sec->GetInt())
{
spdlog::warn(
- "Client {} hit netchan processing limit with {}ms of processing time this second (max is {})", (char*)sender + 0x16,
+ "Client {} hit netchan processing limit with {}ms of processing time this second (max is {})",
+ (char*)sender + 0x16,
g_ServerAuthenticationManager->m_additionalPlayerData[sender].netChanProcessingLimitTime,
Cvar_net_chan_limit_msec_per_sec->GetInt());
@@ -549,7 +581,8 @@ bool ProcessConnectionlessPacketHook(void* a1, netpacket_t* packet)
if (sendData->packetCount >= Cvar_sv_querylimit_per_sec->GetInt())
{
spdlog::warn(
- "Client went over connectionless ratelimit of {} per sec with packet of type {}", Cvar_sv_querylimit_per_sec->GetInt(),
+ "Client went over connectionless ratelimit of {} per sec with packet of type {}",
+ Cvar_sv_querylimit_per_sec->GetInt(),
packet->data[4]);
// timeout for a minute
@@ -582,17 +615,23 @@ void InitialiseServerAuthentication(HMODULE baseAddress)
CVar_ns_auth_allow_insecure =
new ConVar("ns_auth_allow_insecure", "0", FCVAR_GAMEDLL, "Whether this server will allow unauthenicated players to connect");
CVar_ns_auth_allow_insecure_write = new ConVar(
- "ns_auth_allow_insecure_write", "0", FCVAR_GAMEDLL,
+ "ns_auth_allow_insecure_write",
+ "0",
+ FCVAR_GAMEDLL,
"Whether the pdata of unauthenticated clients will be written to disk when changed");
// literally just stolen from a fix valve used in csgo
CVar_sv_quota_stringcmdspersecond = new ConVar(
- "sv_quota_stringcmdspersecond", "60", FCVAR_GAMEDLL,
+ "sv_quota_stringcmdspersecond",
+ "60",
+ FCVAR_GAMEDLL,
"How many string commands per second clients are allowed to submit, 0 to disallow all string commands");
// https://blog.counter-strike.net/index.php/2019/07/24922/ but different because idk how to check what current tick number is
Cvar_net_chan_limit_mode =
new ConVar("net_chan_limit_mode", "0", FCVAR_GAMEDLL, "The mode for netchan processing limits: 0 = log, 1 = kick");
Cvar_net_chan_limit_msec_per_sec = new ConVar(
- "net_chan_limit_msec_per_sec", "0", FCVAR_GAMEDLL,
+ "net_chan_limit_msec_per_sec",
+ "0",
+ FCVAR_GAMEDLL,
"Netchannel processing is limited to so many milliseconds, abort connection if exceeding budget");
Cvar_ns_player_auth_port = new ConVar("ns_player_auth_port", "8081", FCVAR_GAMEDLL, "");
Cvar_sv_querylimit_per_sec = new ConVar("sv_querylimit_per_sec", "15", FCVAR_GAMEDLL, "");
@@ -611,7 +650,9 @@ void InitialiseServerAuthentication(HMODULE baseAddress)
ENABLER_CREATEHOOK(
hook, (char*)baseAddress + 0x1012C0, &CBaseClient__DisconnectHook, reinterpret_cast<LPVOID*>(&CBaseClient__Disconnect));
ENABLER_CREATEHOOK(
- hook, (char*)baseAddress + 0x1022E0, &CGameClient__ExecuteStringCommandHook,
+ hook,
+ (char*)baseAddress + 0x1022E0,
+ &CGameClient__ExecuteStringCommandHook,
reinterpret_cast<LPVOID*>(&CGameClient__ExecuteStringCommand));
ENABLER_CREATEHOOK(
hook, (char*)baseAddress + 0x2140A0, &CNetChan___ProcessMessagesHook, reinterpret_cast<LPVOID*>(&CNetChan___ProcessMessages));