From c26bc6d768b35b98d6623fb777e6b037e3304da4 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 26 Nov 2022 14:11:21 -0700 Subject: [PATCH] More randomness --- index.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a742cbf..16c5b7f 100644 --- a/index.js +++ b/index.js @@ -40,11 +40,19 @@ function splitKeyword(keyword) { default: break; } - return { - "version": data[0], - dlcString, - dlc: data[1], - "tps": data[2] + if (data[0] >= "v1.3.0") { + return { + "version": data[0], + dlcString, + dlc: data[1], + "tps": data[2] + } + } else { // For older versions + console.log(`${colors.magenta(`[DEBUG ${new Date()}]`)} Absolutely ancient server found, ${data}`); + return { + "version": data[0], + "tps": data[1] + } } }; @@ -218,6 +226,13 @@ app.get('/check', (req, res) => { console.log(`${colors.cyan(`[INFO ${new Date()}]`)} ${req.headers["user-agent"]}@${req.ip} requested check server ${req.query.address}`); console.log(`${colors.cyan(`[INFO ${new Date()}]`)} Checking server ${req.query.address}`); Steam.queryGameServerInfo(req.query.address).then(data => { + // Check if server is not running Stormworks, in which case, someone is trying to be funny + if (data.appid != 573090) { + res.status(418).send({ + "error": "A server was found, but it is not running Stormworks" + }); + return; + } data.keywords.split("-") data.address = req.query.address.split(":"); data.serverInfo = splitKeyword(data.keywords); @@ -272,4 +287,6 @@ app.get('/', (req, res) => { }); -app.listen(port, () => console.log(`Listening on port ${port}!`)); \ No newline at end of file +app.listen(port, () => { + console.log(`${colors.cyan(`[INFO ${new Date()}]`)} Server started on port ${port}`); +}); \ No newline at end of file