mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-07 18:05:59 +00:00
Merge branch 'main' into patterned-territory
This commit is contained in:
@@ -20,7 +20,7 @@ import {
|
||||
Turn,
|
||||
} from "../core/Schemas";
|
||||
import { createGameRecord } from "../core/Util";
|
||||
import { ServerConfig } from "../core/configuration/Config";
|
||||
import { GameEnv, ServerConfig } from "../core/configuration/Config";
|
||||
import { GameType } from "../core/game/Game";
|
||||
import { archive } from "./Archive";
|
||||
import { Client } from "./Client";
|
||||
@@ -132,6 +132,25 @@ export class GameServer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.config.env() === GameEnv.Prod) {
|
||||
// Prevent multiple clients from using the same account in prod
|
||||
const conflicting = this.activeClients.find(
|
||||
(c) =>
|
||||
c.persistentID === client.persistentID &&
|
||||
c.clientID !== client.clientID,
|
||||
);
|
||||
if (conflicting !== undefined) {
|
||||
this.log.error("client ids do not match", {
|
||||
clientID: client.clientID,
|
||||
clientIP: ipAnonymize(client.ip),
|
||||
clientPersistentID: client.persistentID,
|
||||
existingIP: ipAnonymize(conflicting.ip),
|
||||
existingPersistentID: conflicting.persistentID,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove stale client if this is a reconnect
|
||||
const existing = this.activeClients.find(
|
||||
(c) => c.clientID === client.clientID,
|
||||
@@ -148,10 +167,10 @@ export class GameServer {
|
||||
return;
|
||||
}
|
||||
existing.ws.removeAllListeners("message");
|
||||
this.activeClients = this.activeClients.filter(
|
||||
(c) => c.clientID !== client.clientID,
|
||||
);
|
||||
this.activeClients = this.activeClients.filter((c) => c !== existing);
|
||||
}
|
||||
|
||||
// Client connection accepted
|
||||
this.activeClients.push(client);
|
||||
client.lastPing = Date.now();
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ const frequency = {
|
||||
FaroeIslands: 1,
|
||||
FalklandIslands: 1,
|
||||
Baikal: 1,
|
||||
Halkidiki: 1,
|
||||
};
|
||||
|
||||
interface MapWithMode {
|
||||
|
||||
@@ -196,7 +196,7 @@ app.post(
|
||||
async function fetchLobbies(): Promise<number> {
|
||||
const fetchPromises: Promise<GameInfo | null>[] = [];
|
||||
|
||||
for (const gameID of publicLobbyIDs) {
|
||||
for (const gameID of new Set(publicLobbyIDs)) {
|
||||
const controller = new AbortController();
|
||||
setTimeout(() => controller.abort(), 5000); // 5 second timeout
|
||||
const port = config.workerPort(gameID);
|
||||
@@ -211,6 +211,7 @@ async function fetchLobbies(): Promise<number> {
|
||||
.catch((error) => {
|
||||
log.error(`Error fetching game ${gameID}:`, error);
|
||||
// Return null or a placeholder if fetch fails
|
||||
publicLobbyIDs.delete(gameID);
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
+1
-1
Submodule src/server/gatekeeper updated: 1f14b7a526...f5f7e6362f
Reference in New Issue
Block a user