feat: respect client-supplied version information (#585)

This commit is contained in:
Sainan 2024-12-20 03:11:09 +01:00 committed by GitHub
parent 259bfa1362
commit d824b83cf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 6 deletions

View File

@ -20,6 +20,11 @@ const loginController: RequestHandler = async (request, response) => {
const account = await Account.findOne({ email: loginRequest.email }); //{ _id: 0, __v: 0 }
const nonce = Math.round(Math.random() * Number.MAX_SAFE_INTEGER);
const buildLabel: string =
typeof request.query.buildLabel == "string"
? request.query.buildLabel.split(" ").join("+")
: buildConfig.buildLabel;
if (!account && config.autoCreateAccount && loginRequest.ClientType != "webui") {
try {
const newAccount = await createAccount({
@ -45,7 +50,7 @@ const loginController: RequestHandler = async (request, response) => {
DTLS: DTLS,
IRC: config.myIrcAddresses ?? [config.myAddress],
HUB: HUB,
BuildLabel: buildConfig.buildLabel,
BuildLabel: buildLabel,
MatchmakingBuildId: buildConfig.matchmakingBuildId
};
@ -81,7 +86,7 @@ const loginController: RequestHandler = async (request, response) => {
DTLS: DTLS,
IRC: config.myIrcAddresses ?? [config.myAddress],
HUB: HUB,
BuildLabel: buildConfig.buildLabel,
BuildLabel: buildLabel,
MatchmakingBuildId: buildConfig.matchmakingBuildId
};

View File

@ -2,10 +2,13 @@ import { RequestHandler } from "express";
import worldState from "@/static/fixed_responses/worldState.json";
import buildConfig from "@/static/data/buildConfig.json";
const worldStateController: RequestHandler = (_req, res) => {
const worldStateController: RequestHandler = (req, res) => {
const buildLabel: string =
typeof req.query.buildLabel == "string" ? req.query.buildLabel.split(" ").join("+") : buildConfig.buildLabel;
res.json({
...worldState,
BuildLabel: buildConfig.buildLabel,
BuildLabel: buildLabel,
Time: Math.round(Date.now() / 1000)
});
};

View File

@ -4,8 +4,12 @@ import fs from "fs/promises";
const cacheRouter = express.Router();
cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res) => {
cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (req, res) => {
if (typeof req.query.version == "string" && req.query.version.match(/^\d\d\d\d\.\d\d\.\d\d\.\d\d\.\d\d$/)) {
res.sendFile(`static/data/H.Cache_${req.query.version}.bin`, { root: "./" });
} else {
res.sendFile(`static/data/H.Cache_${buildConfig.version}.bin`, { root: "./" });
}
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises