Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion nextclient/engine_mini/include/next_engine_mini/nclm_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ constexpr size_t RSA_KEY_LENGTH = 256;
constexpr size_t NCLM_VERIF_PAYLOAD_SIZE = 196;
constexpr size_t NCLM_VERIF_ENCRYPTED_PAYLOAD_SIZE = ((NCLM_VERIF_PAYLOAD_SIZE / RSA_KEY_LENGTH) + 1) * RSA_KEY_LENGTH;

// Tamanho do payload HWID: SHA-256 em hex = 64 caracteres ASCII + null terminator.
constexpr size_t NCLM_HWID_SIZE = 64;

enum class NCLM_C2S {
/*
byte Message header
Expand All @@ -30,7 +33,19 @@ enum class NCLM_C2S {
* Used to tell the server the version of NextClient in use
* when the private key in the client is not configured.
*/
DECLARE_VERSION_REQUEST
DECLARE_VERSION_REQUEST,

/*
* HWID identification — sent AFTER RSA verification is complete.
*
* Payload:
* byte Message header (this opcode = 0x04)
* string 64-char lowercase hex SHA-256 of hardware identifiers
*
* Clients that do not support HWID will never send this opcode.
* The server MUST NOT kick clients that omit it — treat them as "no HWID".
*/
HARDWARE_ID // = 0x04 (sequential after DECLARE_VERSION_REQUEST = 0x03)
};

enum class NCLM_S2C {
Expand Down
9 changes: 8 additions & 1 deletion nextclient/engine_mini/src/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "../common/net_chan.h"
#include "../common/nclm/NclmBodyReader.h"
#include "../common/nclm/NclmBodyWriter.h"
#include "../common/nclm/hwid_collector.h"
#include "../common/nclm/hwid_sender.h"
#include "../graphics/gl_local.h"

void SetCareerAudioState(int state)
Expand All @@ -37,6 +39,8 @@ void CL_Disconnect()
{
OPTICK_EVENT();

hwid::Reset();

eng()->CL_Disconnect.InvokeChained();
}

Expand Down Expand Up @@ -364,13 +368,16 @@ void CL_HandleNclMessage()
{
break;
}

sizebuf_t* msgbuf = &cls->netchan.message;

MSG_WriteByte(msgbuf, clc_ncl_message);
MSG_WriteLong(msgbuf, NCLM_HEADER_OLD);
MSG_WriteByte(msgbuf, (int)NCLM_C2S::VERIFICATION_RESPONSE);
MSG_WriteString(msgbuf, va("%d.%d.%d", g_NextClientVersion.major, g_NextClientVersion.minor, g_NextClientVersion.patch));
MSG_WriteBuf(msgbuf, written_size, result);

hwid::SendToServer(msgbuf);
}
break;
}
Expand Down
Loading