mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
Merge branch 'feature/updated-gamedig-implementation' into feature/update-gamedig-v2
This commit is contained in:
commit
f553681aea
16
package-lock.json
generated
16
package-lock.json
generated
|
@ -32,7 +32,7 @@
|
|||
"express-basic-auth": "~1.2.1",
|
||||
"express-static-gzip": "~2.1.7",
|
||||
"form-data": "~4.0.0",
|
||||
"gamedig": "^4.2.0",
|
||||
"gamedig": "^5.0.1",
|
||||
"html-escaper": "^3.0.3",
|
||||
"http-cookie-agent": "~5.0.4",
|
||||
"http-graceful-shutdown": "~3.1.7",
|
||||
|
@ -8665,13 +8665,13 @@
|
|||
"integrity": "sha512-et9Aq4wlD0cExXEO3r3LWiEEjOzsnG5l/0YSqza7FZLoJqunNT6DedkAXAdeOqAqStkRQahQiPFjx2WCg4SOtg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"gbxremote": "^0.2.1",
|
||||
"got": "^12.1.0",
|
||||
"got": "^13.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"long": "^5.2.0",
|
||||
"minimist": "^1.2.6",
|
||||
"punycode": "^2.1.1",
|
||||
"long": "^5.2.3",
|
||||
"minimist": "^1.2.8",
|
||||
"punycode": "^2.3.0",
|
||||
"seek-bzip": "^2.0.0",
|
||||
"varint": "^6.0.0"
|
||||
},
|
||||
|
@ -8679,7 +8679,7 @@
|
|||
"gamedig": "bin/gamedig.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
"node": ">=16.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/gauge": {
|
||||
|
@ -9015,7 +9015,7 @@
|
|||
"responselike": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.16"
|
||||
"node": ">=16"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sindresorhus/got?sponsor=1"
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
"express-basic-auth": "~1.2.1",
|
||||
"express-static-gzip": "~2.1.7",
|
||||
"form-data": "~4.0.0",
|
||||
"gamedig": "^4.2.0",
|
||||
"gamedig": "^5.0.1",
|
||||
"html-escaper": "^3.0.3",
|
||||
"http-cookie-agent": "~5.0.4",
|
||||
"http-graceful-shutdown": "~3.1.7",
|
||||
|
@ -211,4 +211,4 @@
|
|||
"wait-on": "^7.2.0",
|
||||
"whatwg-url": "~12.0.1"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ const version = require("../../package.json").version;
|
|||
const apicache = require("../modules/apicache");
|
||||
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
||||
const { DockerHost } = require("../docker");
|
||||
const Gamedig = require("gamedig");
|
||||
const { GameDig } = require("gamedig");
|
||||
const jwt = require("jsonwebtoken");
|
||||
const crypto = require("crypto");
|
||||
const { UptimeCalculator } = require("../uptime-calculator");
|
||||
|
@ -696,7 +696,7 @@ class Monitor extends BeanModel {
|
|||
}
|
||||
} else if (this.type === "gamedig") {
|
||||
try {
|
||||
const state = await Gamedig.query({
|
||||
const state = await GameDig.query({
|
||||
type: this.game,
|
||||
host: this.hostname,
|
||||
port: this.port,
|
||||
|
|
|
@ -2,31 +2,36 @@ const { log } = require("../../src/util");
|
|||
const { Settings } = require("../settings");
|
||||
const { sendInfo } = require("../client");
|
||||
const { checkLogin } = require("../util-server");
|
||||
const GameResolver = require("gamedig/lib/GameResolver");
|
||||
const { games } = require("gamedig");
|
||||
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
let gameResolver = new GameResolver();
|
||||
let gameList = null;
|
||||
|
||||
/**
|
||||
* Get a game list via GameDig
|
||||
* @returns {object[]} list of games supported by GameDig
|
||||
* @returns {Object} list of games supported by GameDig
|
||||
*/
|
||||
function getGameList() {
|
||||
if (gameList == null) {
|
||||
gameList = gameResolver._readGames().games.sort((a, b) => {
|
||||
if ( a.pretty < b.pretty ) {
|
||||
return -1;
|
||||
}
|
||||
if ( a.pretty > b.pretty ) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
return gameList;
|
||||
let gamelist = [];
|
||||
gamelist = Object.keys(games).map(key => {
|
||||
const item = games[key];
|
||||
return {
|
||||
keys: [ key ],
|
||||
pretty: item.name,
|
||||
options: item.options,
|
||||
extra: item.extra || {}
|
||||
};
|
||||
});
|
||||
gamelist.sort((a, b) => {
|
||||
if ( a.pretty < b.pretty ) {
|
||||
return -1;
|
||||
}
|
||||
if ( a.pretty > b.pretty ) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return gamelist;
|
||||
}
|
||||
|
||||
module.exports.generalSocketHandler = (socket, server) => {
|
||||
|
|
Loading…
Reference in a new issue