aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/serverauthentication.h
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-07 21:31:41 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-07 21:31:41 +0100
commit2ae34b67e36b8ba05132d481876eb4ed7a826283 (patch)
tree63f44c8e2dcdc959d7a5317a3a7b36efedbd7d38 /NorthstarDLL/serverauthentication.h
parent3406de7aaaf52cbef20b1549f2d7da0255d30f51 (diff)
downloadNorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.tar.gz
NorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.zip
almost fully replaced hooking lib
Diffstat (limited to 'NorthstarDLL/serverauthentication.h')
-rw-r--r--NorthstarDLL/serverauthentication.h219
1 files changed, 111 insertions, 108 deletions
diff --git a/NorthstarDLL/serverauthentication.h b/NorthstarDLL/serverauthentication.h
index 182b3336..4a7281d5 100644
--- a/NorthstarDLL/serverauthentication.h
+++ b/NorthstarDLL/serverauthentication.h
@@ -1,108 +1,111 @@
-#pragma once
-#include "convar.h"
-#include "httplib.h"
-#include <unordered_map>
-#include <string>
-
-struct AuthData
-{
- char uid[33];
- char username[64];
-
- // pdata
- char* pdata;
- size_t pdataSize;
-};
-
-struct AdditionalPlayerData
-{
- bool usingLocalPdata;
- size_t pdataSize;
- bool needPersistenceWriteOnLeave = true;
-
- double lastClientCommandQuotaStart = -1.0;
- int numClientCommandsInQuota = 0;
-
- double lastNetChanProcessingLimitStart = -1.0;
- double netChanProcessingLimitTime = 0.0;
-
- double lastSayTextLimitStart = -1.0;
- int sayTextLimitCount = 0;
-};
-
-#pragma once
-typedef enum
-{
- NA_NULL = 0,
- NA_LOOPBACK,
- NA_IP,
-} netadrtype_t;
-
-#pragma pack(push, 1)
-typedef struct netadr_s
-{
- netadrtype_t type;
- unsigned char ip[16]; // IPv6
- // IPv4's 127.0.0.1 is [::ffff:127.0.0.1], that is:
- // 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 01
- unsigned short port;
-} netadr_t;
-#pragma pack(pop)
-
-#pragma pack(push, 1)
-typedef struct netpacket_s
-{
- netadr_t adr; // sender address
- // int source; // received source
- char unk[10];
- double received_time;
- unsigned char* data; // pointer to raw packet data
- void* message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
- char unk2[16];
- int size;
-
- // bf_read message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
- // int size; // size in bytes
- // int wiresize; // size in bytes before decompression
- // bool stream; // was send as stream
- // struct netpacket_s* pNext; // for internal use, should be NULL in public
-} netpacket_t;
-#pragma pack(pop)
-
-struct UnconnectedPlayerSendData
-{
- char ip[16];
- double lastQuotaStart = 0.0;
- int packetCount = 0;
- double timeoutEnd = -1.0;
-};
-
-class ServerAuthenticationManager
-{
- private:
- httplib::Server m_playerAuthServer;
-
- public:
- std::mutex m_authDataMutex;
- std::unordered_map<std::string, AuthData> m_authData;
- std::unordered_map<void*, AdditionalPlayerData> m_additionalPlayerData;
- std::vector<UnconnectedPlayerSendData> m_unconnectedPlayerSendData;
- bool m_runningPlayerAuthThread = false;
- bool m_bNeedLocalAuthForNewgame = false;
- bool m_bForceReadLocalPlayerPersistenceFromDisk = false;
-
- public:
- void StartPlayerAuthServer();
- void StopPlayerAuthServer();
- bool AuthenticatePlayer(void* player, int64_t uid, char* authToken);
- char* VerifyPlayerName(void* player, char* authToken, char* name);
- bool RemovePlayerAuthData(void* player);
- void WritePersistentData(void* player);
- bool CheckPlayerChatRatelimit(void* player);
-};
-
-typedef void (*CBaseClient__DisconnectType)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
-extern CBaseClient__DisconnectType CBaseClient__Disconnect;
-
-extern ServerAuthenticationManager* g_ServerAuthenticationManager;
-extern ConVar* Cvar_ns_player_auth_port;
+#pragma once
+#include "convar.h"
+#include "httplib.h"
+#include <unordered_map>
+#include <string>
+
+struct AuthData
+{
+ char uid[33];
+ char username[64];
+
+ // pdata
+ char* pdata;
+ size_t pdataSize;
+};
+
+struct AdditionalPlayerData
+{
+ bool usingLocalPdata;
+ size_t pdataSize;
+ bool needPersistenceWriteOnLeave = true;
+
+ double lastClientCommandQuotaStart = -1.0;
+ int numClientCommandsInQuota = 0;
+
+ double lastNetChanProcessingLimitStart = -1.0;
+ double netChanProcessingLimitTime = 0.0;
+
+ double lastSayTextLimitStart = -1.0;
+ int sayTextLimitCount = 0;
+};
+
+#pragma once
+typedef enum
+{
+ NA_NULL = 0,
+ NA_LOOPBACK,
+ NA_IP,
+} netadrtype_t;
+
+#pragma pack(push, 1)
+typedef struct netadr_s
+{
+ netadrtype_t type;
+ unsigned char ip[16]; // IPv6
+ // IPv4's 127.0.0.1 is [::ffff:127.0.0.1], that is:
+ // 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 01
+ unsigned short port;
+} netadr_t;
+#pragma pack(pop)
+
+#pragma pack(push, 1)
+typedef struct netpacket_s
+{
+ netadr_t adr; // sender address
+ // int source; // received source
+ char unk[10];
+ double received_time;
+ unsigned char* data; // pointer to raw packet data
+ void* message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
+ char unk2[16];
+ int size;
+
+ // bf_read message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
+ // int size; // size in bytes
+ // int wiresize; // size in bytes before decompression
+ // bool stream; // was send as stream
+ // struct netpacket_s* pNext; // for internal use, should be NULL in public
+} netpacket_t;
+#pragma pack(pop)
+
+struct UnconnectedPlayerSendData
+{
+ char ip[16];
+ double lastQuotaStart = 0.0;
+ int packetCount = 0;
+ double timeoutEnd = -1.0;
+};
+
+class ServerAuthenticationManager
+{
+ private:
+ httplib::Server m_playerAuthServer;
+
+ public:
+ std::mutex m_authDataMutex;
+ std::unordered_map<std::string, AuthData> m_authData;
+ std::unordered_map<void*, AdditionalPlayerData> m_additionalPlayerData;
+ std::vector<UnconnectedPlayerSendData> m_unconnectedPlayerSendData;
+ bool m_runningPlayerAuthThread = false;
+ bool m_bNeedLocalAuthForNewgame = false;
+ bool m_bForceReadLocalPlayerPersistenceFromDisk = false;
+
+ public:
+ void StartPlayerAuthServer();
+ void StopPlayerAuthServer();
+ bool AuthenticatePlayer(void* player, int64_t uid, char* authToken);
+ char* VerifyPlayerName(void* player, char* authToken, char* name);
+ bool RemovePlayerAuthData(void* player);
+ void WritePersistentData(void* player);
+ bool CheckPlayerChatRatelimit(void* player);
+};
+
+// use the R2 namespace for game funcs
+namespace R2
+{
+ extern void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
+} // namespace R2
+
+extern ServerAuthenticationManager* g_ServerAuthenticationManager;
+extern ConVar* Cvar_ns_player_auth_port;