moved webclient name generation over to the connect extension. fixed pending steam ID. name is tracked with cvar value. name also sets the steamID
This commit is contained in:
parent
4c7ec14d52
commit
dfc25da57a
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ Containerfile
|
|||||||
.venv
|
.venv
|
||||||
safetyhook
|
safetyhook
|
||||||
.env
|
.env
|
||||||
|
secret.h
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#include <iclient.h>
|
#include <iclient.h>
|
||||||
#include <ISDKTools.h>
|
#include <ISDKTools.h>
|
||||||
#include <iserver.h>
|
#include <iserver.h>
|
||||||
|
#include "secret.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
Connect g_connect;
|
Connect g_connect;
|
||||||
@ -38,6 +39,7 @@ ConVar g_SvForceSteam("sv_forcesteam", "0", FCVAR_NOTIFY, "Force steam authentic
|
|||||||
ConVar g_SvGameDesc("sv_gamedesc_override", "default", FCVAR_NOTIFY, "Overwrite the default game description. Set to 'default' to keep default description.");
|
ConVar g_SvGameDesc("sv_gamedesc_override", "default", FCVAR_NOTIFY, "Overwrite the default game description. Set to 'default' to keep default description.");
|
||||||
ConVar g_SvMapName("sv_mapname_override", "default", FCVAR_NOTIFY, "Overwrite the map name. Set to 'default' to keep default name.");
|
ConVar g_SvMapName("sv_mapname_override", "default", FCVAR_NOTIFY, "Overwrite the map name. Set to 'default' to keep default name.");
|
||||||
ConVar g_SvSetSteamIDIPS("sv_set_steam_id_ips", "default", FCVAR_NOTIFY, "IP's allowed for webclient nosteamers");
|
ConVar g_SvSetSteamIDIPS("sv_set_steam_id_ips", "default", FCVAR_NOTIFY, "IP's allowed for webclient nosteamers");
|
||||||
|
ConVar g_SvWebclientName("sv_webclient_name", "", FCVAR_NOTIFY, "Generated name for the currently connecting webclient player.");
|
||||||
|
|
||||||
|
|
||||||
IGameConfig *g_pGameConf = NULL;
|
IGameConfig *g_pGameConf = NULL;
|
||||||
@ -48,6 +50,9 @@ ISDKTools *g_pSDKTools = NULL;
|
|||||||
class IClient;
|
class IClient;
|
||||||
class CBaseServer;
|
class CBaseServer;
|
||||||
|
|
||||||
|
//just grabbing clients name.
|
||||||
|
extern IVEngineServer *engine;
|
||||||
|
|
||||||
typedef enum EAuthProtocol
|
typedef enum EAuthProtocol
|
||||||
{
|
{
|
||||||
k_EAuthProtocolWONCertificate = 1,
|
k_EAuthProtocolWONCertificate = 1,
|
||||||
@ -272,6 +277,50 @@ uint64 GenerateSteamIDFromName(const char *pchName)
|
|||||||
return steamID64;
|
return steamID64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//AI generated function
|
||||||
|
static uint32_t HashString(const char *str)
|
||||||
|
{
|
||||||
|
uint32_t hash = 5381;
|
||||||
|
while (*str)
|
||||||
|
{
|
||||||
|
hash = ((hash << 5) + hash) + (unsigned char)*str;
|
||||||
|
hash = hash & 0x7fffffff;
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
//AI generated function
|
||||||
|
void GenerateNickNameFromPassword(const char *pchPassword, const char *salt, char *outName, size_t outSize)
|
||||||
|
{
|
||||||
|
static const char *adjectives[] = {
|
||||||
|
"Fast","Slow","Red","Blue","Green","Dark","Bright","Wild",
|
||||||
|
"Cool","Hot","Big","Small","Sharp","Brave","Swift","Bold"
|
||||||
|
};
|
||||||
|
static const char *nouns[] = {
|
||||||
|
"Wolf","Eagle","Tiger","Bear","Fox","Lion","Hawk","Shark",
|
||||||
|
"Snake","Raven","Storm","Rock","Fire","Ice","Wind","Steel"
|
||||||
|
};
|
||||||
|
|
||||||
|
char salted[256];
|
||||||
|
V_snprintf(salted, sizeof(salted), "%s%s", pchPassword, salt);
|
||||||
|
uint32_t h1 = HashString(salted);
|
||||||
|
|
||||||
|
char salted1[256];
|
||||||
|
V_snprintf(salted1, sizeof(salted1), "%s1", salted);
|
||||||
|
uint32_t h2 = HashString(salted1);
|
||||||
|
|
||||||
|
char salted2[256];
|
||||||
|
V_snprintf(salted2, sizeof(salted2), "%s2", salted);
|
||||||
|
uint32_t h3 = HashString(salted2);
|
||||||
|
|
||||||
|
V_snprintf(outName, outSize, "%s %s %u",
|
||||||
|
adjectives[h1 % 16],
|
||||||
|
nouns[h2 % 16],
|
||||||
|
h3 % 9999
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
DETOUR_DECL_MEMBER1(CBaseClient__SetSteamID, void, const CSteamID &, steamID)
|
DETOUR_DECL_MEMBER1(CBaseClient__SetSteamID, void, const CSteamID &, steamID)
|
||||||
{
|
{
|
||||||
char aSteamID[32];
|
char aSteamID[32];
|
||||||
@ -292,10 +341,12 @@ DETOUR_DECL_MEMBER1(CBaseClient__SetSteamID, void, const CSteamID &, steamID)
|
|||||||
//connects from the IP's designated for the webclients.
|
//connects from the IP's designated for the webclients.
|
||||||
if (strcmp(IpsAllowed, ipString) == 0)
|
if (strcmp(IpsAllowed, ipString) == 0)
|
||||||
{
|
{
|
||||||
|
//changes the storages pchName
|
||||||
|
GenerateNickNameFromPassword(storage.pchPassword, NAME_SALT, storage.pchName, sizeof(storage.pchName));
|
||||||
uint64 steamID64 = GenerateSteamIDFromName(storage.pchName);
|
uint64 steamID64 = GenerateSteamIDFromName(storage.pchName);
|
||||||
CSteamID newSteamID = CSteamID(steamID64);
|
CSteamID newSteamID = CSteamID(steamID64);
|
||||||
//smutils->LogMessage(myself, "Generated SteamID64: %llu for name: %s", steamID64, storage.pchName);
|
//smutils->LogMessage(myself, "Generated SteamID64: %llu for name: %s", steamID64, storage.pchName);
|
||||||
//smutils->LogMessage(myself, "SteamID render: %s", newSteamID.Render());
|
//smutils->LogMessage(myself, "SteamID render: %s. password. %s", newSteamID.Render(), storage.pchPassword);
|
||||||
|
|
||||||
storage.ullSteamID = steamID64;
|
storage.ullSteamID = steamID64;
|
||||||
storage.Webclient = true;
|
storage.Webclient = true;
|
||||||
@ -586,10 +637,9 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
|
|||||||
|
|
||||||
Storage.SuppressBeginAuthSession = true;
|
Storage.SuppressBeginAuthSession = true;
|
||||||
g_ConnectClientStorage.replace(aSteamID, Storage);
|
g_ConnectClientStorage.replace(aSteamID, Storage);
|
||||||
|
|
||||||
auto client = DETOUR_MEMBER_CALL(CBaseServer__ConnectClient)(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, pchPassword, pCookie, cbCookie);
|
auto client = DETOUR_MEMBER_CALL(CBaseServer__ConnectClient)(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, pchPassword, pCookie, cbCookie);
|
||||||
|
|
||||||
Storage.SuppressBeginAuthSession = false;
|
|
||||||
g_ConnectClientStorage.replace(aSteamID, Storage);
|
|
||||||
|
|
||||||
//g_pSM->LogMessage(myself, "finished DETOUR_MEMBER_CALL. %s", aSteamID);
|
//g_pSM->LogMessage(myself, "finished DETOUR_MEMBER_CALL. %s", aSteamID);
|
||||||
|
|
||||||
@ -598,12 +648,17 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
|
|||||||
g_ConnectClientStorage.retrieve(aSteamID, &storage_setSteamID);
|
g_ConnectClientStorage.retrieve(aSteamID, &storage_setSteamID);
|
||||||
if (storage_setSteamID.Webclient)
|
if (storage_setSteamID.Webclient)
|
||||||
{
|
{
|
||||||
|
storage_setSteamID.SuppressBeginAuthSession = false;
|
||||||
CSteamID newSteamID = CSteamID(storage_setSteamID.ullSteamID);
|
CSteamID newSteamID = CSteamID(storage_setSteamID.ullSteamID);
|
||||||
|
//smutils->LogMessage(myself, "Generated name after webclient check: %s", storage_setSteamID.pchName);
|
||||||
|
g_SvWebclientName.SetValue(storage_setSteamID.pchName);
|
||||||
storage_setSteamID.pClient = client;
|
storage_setSteamID.pClient = client;
|
||||||
|
|
||||||
|
//smutils->LogMessage(myself, "SteamID render after webclient check: %s", newSteamID.Render());
|
||||||
g_ConnectClientStorage.replace(newSteamID.Render(), storage_setSteamID);
|
g_ConnectClientStorage.replace(newSteamID.Render(), storage_setSteamID);
|
||||||
g_ConnectClientStorage.remove(aSteamID);
|
g_ConnectClientStorage.remove(aSteamID);
|
||||||
|
|
||||||
if (client && SteamAuthFailed)
|
if (client) //webclient is always nosteamer.
|
||||||
{
|
{
|
||||||
ValidateAuthTicketResponse_t Response;
|
ValidateAuthTicketResponse_t Response;
|
||||||
Response.m_SteamID = newSteamID;
|
Response.m_SteamID = newSteamID;
|
||||||
@ -615,6 +670,7 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Storage.SuppressBeginAuthSession = false;
|
||||||
Storage.pClient = client;
|
Storage.pClient = client;
|
||||||
g_ConnectClientStorage.replace(aSteamID, Storage);
|
g_ConnectClientStorage.replace(aSteamID, Storage);
|
||||||
|
|
||||||
@ -751,6 +807,7 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late)
|
|||||||
bool Connect::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
bool Connect::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||||
{
|
{
|
||||||
GET_V_IFACE_CURRENT(GetEngineFactory, g_pCVar, ICvar, CVAR_INTERFACE_VERSION);
|
GET_V_IFACE_CURRENT(GetEngineFactory, g_pCVar, ICvar, CVAR_INTERFACE_VERSION);
|
||||||
|
GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||||
|
|
||||||
ConVar_Register(0, this);
|
ConVar_Register(0, this);
|
||||||
|
|
||||||
|
|||||||
2
extension/secret.h.example
Normal file
2
extension/secret.h.example
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#define NAME_SALT "your-salt-here"
|
||||||
Loading…
Reference in New Issue
Block a user