fix: remove Mojang service status tracker (fixes #274)

See https://github.com/Cryptkeeper/Minetrack/issues/274
This commit is contained in:
Nick Krecklow 2021-10-12 18:55:48 -05:00
parent 154de228aa
commit 62da42e9cb
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94
12 changed files with 7 additions and 209 deletions

@ -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!

@ -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 {

@ -42,24 +42,7 @@
<div class="header-possible-row-break column-right">
<div id="sort-by" class="header-button header-button-single"><span class="icon-sort-amount-desc"></span> Sort By<br><strong id="sort-by-text">...</strong></div>
<div id="settings-toggle" class="header-button header-button-single"><span class="icon-gears"></span> Graph Controls</div>
<div class="header-button header-button-group" title="Sessions" id="mojang-status_Sessions">
<span class="icon-globe"></span><strong>Sessions</strong>
<p class="mojang-status-text" id="mojang-status-text_Sessions">...</p>
</div>
<div class="header-button header-button-group" title="Skins" id="mojang-status_Skins">
<span class="icon-street-view"></span><strong>Skins</strong>
<p class="mojang-status-text" id="mojang-status-text_Skins">...</p>
</div>
<div class="header-button header-button-group" title="Auth" id="mojang-status_Auth">
<span class="icon-lock"></span><strong>Auth</strong>
<p class="mojang-status-text" id="mojang-status-text_Auth">...</p>
</div>
<div class="header-button header-button-group" title="API" id="mojang-status_API">
<span class="icon-code"></span><strong>API</strong>
<p class="mojang-status-text" id="mojang-status-text_API">...</p>
</div>
<div id="settings-toggle" class="header-button header-button-single" style="margin-left: 20px;"><span class="icon-gears"></span> Graph Controls</div>
</div>
</header>

@ -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

@ -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 = '...'
})
}
}

@ -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)

@ -4,8 +4,6 @@
"ip": "0.0.0.0"
},
"rates": {
"updateMojangStatus": 5000,
"mojangStatusTimeout": 3500,
"pingAll": 3000,
"connectTimeout": 2500
},

@ -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

@ -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())
}

@ -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

4
package-lock.json generated

@ -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",

@ -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",