1
0
mirror of synced 2024-11-12 01:10:47 +01:00

fix bug, and block connection outside mt6

This commit is contained in:
Shiroi Kitsu 2023-03-28 18:22:05 +07:00
parent c60e329935
commit a7941a5619
14 changed files with 118 additions and 89 deletions

View File

@ -13,6 +13,7 @@
"scratchType": 0,
"giveMeterReward": 0,
"newCardsBanned": 0,
"revisionCheck": 1,
"enableScreenshot": 0
}
}

View File

@ -54,6 +54,11 @@ export interface GameOptions {
// and prevent new card registration
newCardsBanned: number; // 1 is on, 0 is off
// revision check
// set this option to 1 will block not matched revision
// and from connecting to the server
revisionCheck: number; // 1 is on, 0 is off
// revision check
// set this option to 1 to enable screenshot feature
enableScreenshot: number; // 1 is on, 0 is off

View File

@ -81,7 +81,7 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.LoadCarResponse.encode(msg);
// Send the response
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -94,6 +94,7 @@ export default class CarModule extends Module {
// Create the Car
let createCar = await carFunctions.createCar(body);
let tune = createCar.tune;
let itemId = createCar.itemId;
let carInsert = createCar.carInsert;
// Check if user's other car have unique window sticker
@ -105,7 +106,7 @@ export default class CarModule extends Module {
let additionalInsert = getCarTune.additionalInsert;
// Check created car and item used
let checkCreatedCars = await carFunctions.checkCreatedCar(body, carInsert);
let checkCreatedCars = await carFunctions.checkCreatedCar(body, carInsert, itemId);
if(checkCreatedCars.cheated === true)
{
let msg = {
@ -119,7 +120,7 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.CreateCarResponse.encode(msg);
// Send the response
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return;
}
@ -160,7 +161,7 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.CreateCarResponse.encode(msg);
// Send the response
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -226,7 +227,7 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.UpdateCarResponse.encode(msg);
// Send the response
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
}
}

View File

@ -17,6 +17,7 @@ export async function createCarWithItem(userItemId: number)
}
});
let tune = 0;
let itemId = item.itemId;
console.log('Item deleted!');
@ -80,7 +81,7 @@ export async function createCarWithItem(userItemId: number)
}
break;
}
console.log(`Item category was ${item.category} and item game ID was ${item.itemId}`);
console.log(`Item category was ${item.category} and item game ID was ${itemId}`);
return { tune }
return { tune, itemId }
}

View File

@ -308,6 +308,7 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
// 1: Basic Tune (600 HP)
// 2: Fully Tuned (840 HP)
let tune = 0;
let itemId = 0;
// If a user item has been used
if (body.userItemId)
@ -315,6 +316,7 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
let carUtilFunctions = await car_tune.createCarWithItem(body.userItemId);
tune = carUtilFunctions.tune;
itemId = carUtilFunctions.itemId;
}
// Other cases, may occur if item is not detected as 'used'
// User item not used, but car has 740 HP by default
@ -400,7 +402,7 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
lastPlayedPlaceId: 1, // Server Default
};
return { carInsert, tune, user }
return { carInsert, tune, user, itemId }
}
@ -670,7 +672,7 @@ export async function updateCarCustomWing(body: wm.protobuf.UpdateCarRequest)
// Remove Used Ticket
export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: any)
export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: any, itemId: number)
{
let cheated: boolean = false;
@ -698,7 +700,6 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
137, // NDERC
138, // UF31
139, // GS130
143, // 928GT
];
let carVisualModelWithoutItem = [
@ -719,10 +720,6 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
125, // P400S
126, // DIABLO
133, // PS13
137, // NDERC
138, // UF31
139, // GS130
143, // 928GT
];
// Check if user item id is not set and its a special car
@ -747,16 +744,15 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
}
}
// Get the item id
let item = await prisma.userItem.findFirst({
where: {
userItemId: body.userItemId
}
});
let itemId = item?.itemId || -1;
// Check if user item id is set and its a special car created from ticket
if(car.visualModel === 130)
if(car.visualModel === 122)
{
if(itemId < 7 || itemId > 15)
{
cheated = true;
}
}
else if(car.visualModel === 130)
{
if(itemId < 22 || itemId > 27)
{
@ -770,13 +766,6 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
cheated = true;
}
}
else if(car.visualModel === 122)
{
if(itemId < 7 || itemId > 15)
{
cheated = true;
}
}
else if(car.visualModel === 137)
{
if(itemId !== 37)
@ -786,14 +775,14 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
}
else if(car.visualModel === 138)
{
if(itemId !== 38)
if(itemId !== 39)
{
cheated = true;
}
}
else if(car.visualModel === 139)
{
if(itemId !== 39)
if(itemId !== 38)
{
cheated = true;
}

View File

@ -158,7 +158,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.SaveGameResultResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -207,7 +207,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.LoadGameHistoryResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -223,7 +223,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.SaveChargeResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -245,7 +245,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.SaveScreenshotResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
}
}

View File

@ -68,7 +68,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadGhostBattleInfoResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -97,7 +97,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadStampTargetResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -174,7 +174,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.SearchCarsByLevelResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -266,7 +266,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadGhostDriveDataResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -328,7 +328,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.RegisterGhostTrailResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -390,7 +390,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.GhostTrail.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -496,7 +496,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadPathsAndTuningsResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -515,7 +515,7 @@ export default class GhostModule extends Module {
let message = wmsrv.wm.protobuf.LockCrownResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
}
}

View File

@ -378,7 +378,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadGhostCompetitionInfoResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -699,7 +699,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.GhostCompetitionTarget.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
}
}

View File

@ -76,7 +76,7 @@ export default class ResourceModule extends Module {
let message = wm.wm.protobuf.PlaceList.encode({places});
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
// Get Ranking data for attract screen (TA, Ghost, VS)
@ -103,7 +103,7 @@ export default class ResourceModule extends Module {
let message = wmsrv.wm.protobuf.Ranking.encode({lists});
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -123,7 +123,7 @@ export default class ResourceModule extends Module {
let message = wmsrv.wm.protobuf.CrownList.encode( {crowns} );
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -184,7 +184,7 @@ export default class ResourceModule extends Module {
let message = wm.wm.protobuf.FileList.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -206,7 +206,7 @@ export default class ResourceModule extends Module {
let message = wmsrv.wm.protobuf.GhostList.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
}
}

View File

@ -49,7 +49,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.RegisterSystemInfoResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -70,7 +70,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -89,7 +89,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.PingResponse.encode(ping);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -110,7 +110,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.RegisterSystemStatsResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -135,7 +135,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.UpdateEventModeSerialResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -156,7 +156,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.SubmitClientLogResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
}
}

View File

@ -36,7 +36,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadTerminalInformationResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -91,7 +91,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -148,7 +148,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -177,7 +177,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -300,7 +300,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.CarSummary.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -360,7 +360,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.SaveTerminalResultResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -440,7 +440,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadScratchInformationResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -469,7 +469,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.TurnScratchSheetResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -598,7 +598,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.SaveScratchSheetResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -1033,7 +1033,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadGhostCompetitionRankingResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -1098,7 +1098,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.RegisterOpponentGhostResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -1144,7 +1144,7 @@ export default class TerminalModule extends Module {
});
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -1163,7 +1163,7 @@ export default class TerminalModule extends Module {
let message = wmsrv.wm.protobuf.LoadUnreceivedUserItemsResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -1181,7 +1181,7 @@ export default class TerminalModule extends Module {
let message = wmsrv.wm.protobuf.CheckItemReceivableCarsResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
*/
}

View File

@ -60,7 +60,7 @@ export default class TimeAttackModule extends Module {
let message = wm.wm.protobuf.LoadTimeAttackRecordResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return;
}
@ -83,7 +83,7 @@ export default class TimeAttackModule extends Module {
let message = wm.wm.protobuf.LoadTimeAttackRecordResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
}
}

View File

@ -68,7 +68,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return;
}
@ -93,7 +93,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return;
}
@ -199,7 +199,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return;
}
@ -587,7 +587,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -643,7 +643,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.CreateUserResponse.encode(msg);
// Send response to client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -694,7 +694,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadDriveInformationResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -710,7 +710,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
@ -730,7 +730,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.StartTransferResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -749,7 +749,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.GrantCarRightResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -768,7 +768,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.AskAccessCodeResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -787,7 +787,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.ParticipateInInviteFriendCampaignResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
});
@ -805,7 +805,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.ConsumeUserItemResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res);
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
})
*/
}

View File

@ -1,11 +1,12 @@
import { Response } from "express";
import Long from "long";
import { Writer } from "protobufjs";
import { Config } from "../../config";
import Long from "long";
// sendResponse(message, res): Void
// Sends the server response to the client
export function sendResponse(message: Writer, res: Response)
export function sendResponse(message: Writer, res: Response, rawHeaders: string, rawHeaders2: string)
{
// Get the end of the message
let end = message.finish();
@ -17,8 +18,39 @@ export function sendResponse(message: Writer, res: Response)
.header('Content-Length', end.length.toString())
.status(200);
// Send the response to the client
r.send(Buffer.from(end));
// Revision Check
let revisionCheck = Config.getConfig().gameOptions.revisionCheck || 1;
// Revision Check is enabled
if(revisionCheck === 1)
{
// Get the Revision
let getProtobufRev;
if(rawHeaders.includes('application/x-protobuf')) // application/x-protobuf; revision=number_here
{
getProtobufRev = rawHeaders.split('; ');
}
else
{
getProtobufRev = rawHeaders2.split('; ');
}
let protobufRev = getProtobufRev[1].split('='); // array 0 = content type, array 1 = protobuf revision
// Connect to the server if the Revision is match
if(protobufRev[1] === "8053")
{
// Send the response to the client
r.send(Buffer.from(end));
}
// else{} Prevent connecting to the server
}
// Just send it
else
{
// Send the response to the client
r.send(Buffer.from(end));
}
}