mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
C is portable, they lied lyingly like a liar
This commit is contained in:
parent
78b30802bb
commit
056355d8ed
1 changed files with 3 additions and 4 deletions
|
|
@ -247,7 +247,7 @@ static int IsExternalAddress (const void *p)
|
||||||
// Generate a message for an authenticating client to sign, with some guarantees about who we are.
|
// Generate a message for an authenticating client to sign, with some guarantees about who we are.
|
||||||
void GenerateChallenge(uint8_t *buf)
|
void GenerateChallenge(uint8_t *buf)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
UINT64 now = time(NULL);
|
||||||
csprng(buf, sizeof(&buf)); // Random noise as a baseline, but...
|
csprng(buf, sizeof(&buf)); // Random noise as a baseline, but...
|
||||||
memcpy(buf, &now, sizeof(now)); // Timestamp limits the reuse window.
|
memcpy(buf, &now, sizeof(now)); // Timestamp limits the reuse window.
|
||||||
memcpy(buf + sizeof(now), &ourIP, sizeof(ourIP)); // IP prevents captured signatures from being used elsewhere.
|
memcpy(buf + sizeof(now), &ourIP, sizeof(ourIP)); // IP prevents captured signatures from being used elsewhere.
|
||||||
|
|
@ -273,16 +273,15 @@ void GenerateChallenge(uint8_t *buf)
|
||||||
// Don't sign anything that wasn't generated just for us!
|
// Don't sign anything that wasn't generated just for us!
|
||||||
shouldsign_t ShouldSignChallenge(uint8_t *message)
|
shouldsign_t ShouldSignChallenge(uint8_t *message)
|
||||||
{
|
{
|
||||||
time_t then, now;
|
UINT64 then, now;
|
||||||
UINT32 claimedIP, realIP;
|
UINT32 claimedIP, realIP;
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
memcpy(&then, message, sizeof(then));
|
memcpy(&then, message, sizeof(then));
|
||||||
memcpy(&claimedIP, message + sizeof(then), sizeof(claimedIP));
|
memcpy(&claimedIP, message + sizeof(then), sizeof(claimedIP));
|
||||||
CONS_Printf("servernode: %d\n", servernode);
|
|
||||||
realIP = I_GetNodeAddressInt(servernode);
|
realIP = I_GetNodeAddressInt(servernode);
|
||||||
|
|
||||||
if (abs(now - then) > 60*5)
|
if ((max(now, then) - min(now, then)) > 60*5)
|
||||||
return SIGN_BADTIME;
|
return SIGN_BADTIME;
|
||||||
|
|
||||||
if (realIP != claimedIP && IsExternalAddress(&realIP))
|
if (realIP != claimedIP && IsExternalAddress(&realIP))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue