From 62da42e9cb46ebc1652bed53cad04fb3040e3c23 Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Tue, 12 Oct 2021 18:55:48 -0500 Subject: [PATCH] fix: remove Mojang service status tracker (fixes #274) See https://github.com/Cryptkeeper/Minetrack/issues/274 --- README.md | 1 - assets/css/main.css | 44 ------------------- assets/html/index.html | 19 +-------- assets/js/app.js | 3 -- assets/js/mojang.js | 30 ------------- assets/js/socket.js | 9 ---- config.json | 2 - docs/CHANGELOG.md | 3 ++ lib/app.js | 4 -- lib/mojang.js | 95 ------------------------------------------ package-lock.json | 4 +- package.json | 2 +- 12 files changed, 7 insertions(+), 209 deletions(-) delete mode 100644 assets/js/mojang.js delete mode 100644 lib/mojang.js diff --git a/README.md b/README.md index af3c52e..b5d5c48 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ This project is not actively supported. Pull requests will be reviewed and merge - 📦 Out of the box included dashboard with various customizable sorting and viewing options. - 📱(Decent) mobile support. - 🕹 Supports both Minecraft Java Edition and Minecraft Bedrock Edition. -- 🚨 [minecraft.net](https://minecraft.net) and [mojang.com](https://mojang.com) services status monitoring to watch for interruptions. ### Community Showcase You can find a list of community hosted instances below. Want to be listed here? Add yourself in a pull request! diff --git a/assets/css/main.css b/assets/css/main.css index 527f19d..874c330 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -137,25 +137,10 @@ header .header-button > span:first-of-type { font-size: 22px; } -header .header-button-group { - display: inline-block; -} - -header .header-button-group:first-of-type { - border-top-left-radius: var(--border-radius); - border-bottom-left-radius: var(--border-radius); -} - -header .header-button-group:last-of-type { - border-top-right-radius: var(--border-radius); - border-bottom-right-radius: var(--border-radius); -} - header .header-button-single { display: none; cursor: pointer; border-radius: var(--border-radius); - margin-right: 20px; } header .header-button-single:hover { @@ -401,35 +386,6 @@ footer a:hover { position: absolute; } -/* Mojang status colors */ - -/* Light theme */ -.mojang-status-online { - background: #87D37C; -} - -.mojang-status-unstable { - background: #f1c40f; -} - -.mojang-status-offline { - background: #DE5749; -} - -@media (prefers-color-scheme: dark) { - .mojang-status-online { - background: #66aa5a; - } - - .mojang-status-unstable { - background: #cc8a4f; - } - - .mojang-status-offline { - background: #A6453B; - } -} - /* Header rows */ @media only screen and (max-width: 1050px) { header { diff --git a/assets/html/index.html b/assets/html/index.html index edd2f55..5f01112 100644 --- a/assets/html/index.html +++ b/assets/html/index.html @@ -42,24 +42,7 @@
Sort By
...
-
Graph Controls
- -
- Sessions -

...

-
-
- Skins -

...

-
-
- Auth -

...

-
-
- API -

...

-
+
Graph Controls
diff --git a/assets/js/app.js b/assets/js/app.js index 7c2afe0..b6fe07b 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2,7 +2,6 @@ import { ServerRegistry } from './servers' import { SocketManager } from './socket' import { SortController } from './sort' import { GraphDisplayManager } from './graph' -import { MojangUpdater } from './mojang' import { PercentageBar } from './percbar' import { FavoritesManager } from './favorites' import { Tooltip, Caption, formatNumber } from './util' @@ -17,7 +16,6 @@ export class App { this.socketManager = new SocketManager(this) this.sortController = new SortController(this) this.graphDisplayManager = new GraphDisplayManager(this) - this.mojangUpdater = new MojangUpdater() this.percentageBar = new PercentageBar(this) this.favoritesManager = new FavoritesManager(this) @@ -72,7 +70,6 @@ export class App { this.socketManager.reset() this.sortController.reset() this.graphDisplayManager.reset() - this.mojangUpdater.reset() this.percentageBar.reset() // Undefine publicConfig, resynced during the connection handshake diff --git a/assets/js/mojang.js b/assets/js/mojang.js deleted file mode 100644 index 498dce9..0000000 --- a/assets/js/mojang.js +++ /dev/null @@ -1,30 +0,0 @@ -const MOJANG_STATUS_BASE_CLASS = 'header-button header-button-group' - -const MOJANG_SERVICE_NAMES = ['Auth', 'Sessions', 'API', 'Skins'] - -export class MojangUpdater { - updateStatus (services) { - for (const name of MOJANG_SERVICE_NAMES) { - if (services[name]) { - this.updateServiceStatus(name, services[name]) - } - } - } - - updateServiceStatus (name, title) { - // HACK: ensure mojang-status is added for alignment, replace existing class to swap status color - document.getElementById(`mojang-status_${name}`).setAttribute('class', `${MOJANG_STATUS_BASE_CLASS} mojang-status-${title.toLowerCase()}`) - document.getElementById(`mojang-status-text_${name}`).innerText = title - } - - reset () { - // Strip any mojang-status-* color classes from all mojang-status classes - document.querySelectorAll('.mojang-status').forEach(function (element) { - element.setAttribute('class', MOJANG_STATUS_BASE_CLASS) - }) - - document.querySelectorAll('.mojang-status-text').forEach(function (element) { - element.innerText = '...' - }) - } -} diff --git a/assets/js/socket.js b/assets/js/socket.js index ece4177..406893e 100644 --- a/assets/js/socket.js +++ b/assets/js/socket.js @@ -63,10 +63,6 @@ export class SocketManager { this._app.addServer(serverId, serverPayload, payload.timestampPoints) }) - if (payload.mojangServices) { - this._app.mojangUpdater.updateStatus(payload.mojangServices) - } - // Init payload contains all data needed to render the page // Alert the app it is ready this._app.handleSyncComplete() @@ -101,11 +97,6 @@ export class SocketManager { break } - case 'updateMojangServices': { - this._app.mojangUpdater.updateStatus(payload) - break - } - case 'historyGraph': { this._app.graphDisplayManager.buildPlotInstance(payload.timestamps, payload.graphData) diff --git a/config.json b/config.json index 39e0c16..327efe7 100644 --- a/config.json +++ b/config.json @@ -4,8 +4,6 @@ "ip": "0.0.0.0" }, "rates": { - "updateMojangStatus": 5000, - "mojangStatusTimeout": 3500, "pingAll": 3000, "connectTimeout": 2500 }, diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7dc4be6..e4b5653 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,6 @@ +**5.6.1** *(Oct 12 2021)* +- Removed Mojang service status display, status.mojang.com/check was disabled by Mojang. See https://github.com/Cryptkeeper/Minetrack/issues/274 + **5.6.0** *(June 7 2021)* - Fixed a regression caused by rendering error fixed in 5.5.9. See https://github.com/Cryptkeeper/Minetrack/issues/257 diff --git a/lib/app.js b/lib/app.js index 2bd7466..2e1daeb 100644 --- a/lib/app.js +++ b/lib/app.js @@ -1,5 +1,4 @@ const Database = require('./database') -const MojangUpdater = require('./mojang') const PingController = require('./ping') const Server = require('./server') const { TimeTracker } = require('./time') @@ -12,7 +11,6 @@ class App { serverRegistrations = [] constructor () { - this.mojangUpdater = new MojangUpdater(this) this.pingController = new PingController(this) this.server = new Server(this) this.timeTracker = new TimeTracker(this) @@ -33,7 +31,6 @@ class App { this.server.listen(config.site.ip, config.site.port) // Allow individual modules to manage their own task scheduling - this.mojangUpdater.schedule() this.pingController.schedule() } @@ -73,7 +70,6 @@ class App { isGraphVisible: config.logToDatabase } })(), - mojangServices: this.mojangUpdater.getLastUpdate(), timestampPoints: this.timeTracker.getServerGraphPoints(), servers: this.serverRegistrations.map(serverRegistration => serverRegistration.getPingHistory()) } diff --git a/lib/mojang.js b/lib/mojang.js deleted file mode 100644 index 37dee30..0000000 --- a/lib/mojang.js +++ /dev/null @@ -1,95 +0,0 @@ -const request = require('request') - -const logger = require('./logger') -const MessageOf = require('./message') - -const config = require('../config') - -const SERVICE_URL_LOOKUP = { - 'session.minecraft.net': 'Sessions', - 'authserver.mojang.com': 'Auth', - 'textures.minecraft.net': 'Skins', - 'api.mojang.com': 'API' -} - -const TITLE_BY_MOJANG_COLOR = { - red: 'Offline', - yellow: 'Unstable', - green: 'Online' -} - -class MojangUpdater { - constructor (app) { - this._app = app - } - - schedule () { - setInterval(this.updateServices, config.rates.updateMojangStatus) - - this.updateServices() - } - - updateServices = () => { - request({ - uri: 'https://status.mojang.com/check', - method: 'GET', - timeout: config.rates.mojangStatusTimeout - }, (err, _, body) => { - if (err) { - logger.log('error', 'Failed to update Mojang services: %s', err.message) - - // Set all services to offline - // This may be incorrect, but if mojang.com is offline, it would never otherwise be reflected - Object.keys(SERVICE_URL_LOOKUP).forEach(url => { - this.handleServiceUpdate(url, 'red') - }) - - this.pushUpdate() - } else { - try { - JSON.parse(body).forEach(service => { - // Each service is formatted as an object with the 0 key being the URL - const url = Object.keys(service)[0] - this.handleServiceUpdate(url, service[url]) - }) - } catch (err) { - logger.log('error', 'Failed to parse Mojang response: %s', err.message) - } - - this.pushUpdate() - } - }) - } - - pushUpdate () { - // Only fire callback when previous state is modified - if (this._hasUpdated) { - this._hasUpdated = false - - this._app.server.broadcast(MessageOf('updateMojangServices', this._services)) - } - } - - getLastUpdate () { - return this._services - } - - handleServiceUpdate (url, color) { - const service = SERVICE_URL_LOOKUP[url] - - if (service) { - const requiredTitle = TITLE_BY_MOJANG_COLOR[color] - - if (!this._services) { - this._services = {} - } - - if (this._services[service] !== requiredTitle) { - this._services[service] = requiredTitle - this._hasUpdated = true - } - } - } -} - -module.exports = MojangUpdater diff --git a/package-lock.json b/package-lock.json index 299c573..b3a6665 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "minetrack", - "version": "5.6.0", + "version": "5.6.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "minetrack", - "version": "5.5.9", + "version": "5.6.1", "license": "MIT", "dependencies": { "finalhandler": "^1.1.2", diff --git a/package.json b/package.json index 72d337c..b927720 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minetrack", - "version": "5.6.0", + "version": "5.6.1", "description": "A Minecraft server tracker that lets you focus on the basics.", "dependencies": { "finalhandler": "^1.1.2",