This commit is contained in:
evanpelle
2026-04-29 17:18:22 -06:00
parent 2a76a63e32
commit e5d6096eee
+14 -2
View File
@@ -1,4 +1,5 @@
import ipAnonymize from "ip-anonymize";
import { createHash } from "node:crypto";
import { Logger } from "winston";
import WebSocket from "ws";
import { z } from "zod";
@@ -24,7 +25,7 @@ import {
StampedIntent,
Turn,
} from "../core/Schemas";
import { createPartialGameRecord } from "../core/Util";
import { createPartialGameRecord, replacer } from "../core/Util";
import { archive, finalizeGameRecord } from "./Archive";
import { Client } from "./Client";
import { ClientMsgRateLimiter } from "./ClientMsgRateLimiter";
@@ -1200,7 +1201,18 @@ export class GameServer {
client.reportedWinner = clientMsg.winner;
// Add client vote
const winnerKey = JSON.stringify(clientMsg.winner);
const winnerKey = createHash("sha256")
.update(
JSON.stringify(
{
winner: clientMsg.winner,
allPlayersStats: clientMsg.allPlayersStats,
},
replacer,
),
)
.digest("hex");
if (!this.winnerVotes.has(winnerKey)) {
this.winnerVotes.set(winnerKey, { ips: new Set(), winner: clientMsg });
}