From df72b98d537dd3603ec46b15ed96fe3b230e2cb6 Mon Sep 17 00:00:00 2001 From: Devin Ryan Date: Tue, 1 Mar 2016 19:09:25 -0600 Subject: [PATCH 1/7] Add .DS_Store to gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 19602f6..d3a526f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ node_modules/ .idea/ production/ database.sql -database.sql-journal \ No newline at end of file +database.sql-journal +.DS_Store + From 43c284aa8a36566a43699b73ab3b836b76ffc1fd Mon Sep 17 00:00:00 2001 From: Devin Ryan Date: Tue, 1 Mar 2016 21:09:38 -0600 Subject: [PATCH 2/7] Show supported versions for PC servers The Minetrack daemon will send a different protocol version each time it pings a server. If a server responds with the same protocol version, it is assumed that the version is supported, and it is shown on the page above the server's player count. The list of versions to be tried is stored in config.json. At the moment, 4 versions are checked: - 4 (Minecraft 1.7.2) - 5 (Minecraft 1.7.10) - 47 (Minecraft 1.8) - 107 (Minecraft 1.9) --- app.js | 69 +++++++++++++++++++++++++++++++++++++-------- assets/css/main.css | 16 +++++++++-- assets/js/site.js | 26 +++++++++++++++-- config.json | 11 ++++++++ lib/ping.js | 10 +++---- package.json | 2 +- 6 files changed, 111 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index 9cb6228..8173d8b 100644 --- a/app.js +++ b/app.js @@ -11,6 +11,12 @@ var servers = require('./servers.json'); var networkHistory = []; var connectedClients = 0; +var currentVersionIndex = { + 'PC': 0, + 'PE': 0 +}; +var networkVersions = []; + var graphData = []; var lastGraphPush = []; @@ -18,6 +24,7 @@ function pingAll() { for (var i = 0; i < servers.length; i++) { // Make sure we lock our scope. (function(network) { + var attemptedVersion = config.versions[network.type][currentVersionIndex[network.type]]; ping.ping(network.ip, network.port, network.type, config.rates.connectTimeout, function(err, res) { // Handle our ping results, if it succeeded. if (err) { @@ -29,20 +36,62 @@ function pingAll() { res.favicon = config.faviconOverride[network.name]; } - handlePing(network, res, err); - }); + handlePing(network, res, err, attemptedVersion); + }, attemptedVersion); })(servers[i]); } + + currentVersionIndex['PC']++; + currentVersionIndex['PE']++; + + if (currentVersionIndex['PC'] >= config.versions['PC'].length) { + // Loop around + currentVersionIndex['PC'] = 0; + } + + if (currentVersionIndex['PE'] >= config.versions['PE'].length) { + // Loop around + currentVersionIndex['PE'] = 0; + } } // This is where the result of a ping is feed. // This stores it and converts it to ship to the frontend. -function handlePing(network, res, err) { +function handlePing(network, res, err, attemptedVersion) { + // Log our response. + if (!networkHistory[network.name]) { + networkHistory[network.name] = []; + } + + // Update the version list + if (!networkVersions[network.name]) { + networkVersions[network.name] = []; + } + + // If the result version matches the attempted version, the version is supported + var _networkVersions = networkVersions[network.name]; + if (res) { + if (res.version == attemptedVersion) { + if (_networkVersions.indexOf(res.version) == -1) { + _networkVersions.push(res.version); + } + } else { + // Mismatch, so remove the version from the supported version list + var index = _networkVersions.indexOf(attemptedVersion); + if (index != -1) { + _networkVersions.splice(index, 1); + } + } + } + + // Update the clients var networkSnapshot = { info: { name: network.name, - timestamp: util.getCurrentTimeMs() - } + timestamp: util.getCurrentTimeMs(), + type: network.type + }, + versions: _networkVersions }; if (res) { @@ -53,11 +102,6 @@ function handlePing(network, res, err) { server.io.sockets.emit('update', networkSnapshot); - // Log our response. - if (!networkHistory[network.name]) { - networkHistory[network.name] = []; - } - var _networkHistory = networkHistory[network.name]; // Remove our previous data that we don't need anymore. @@ -72,12 +116,13 @@ function handlePing(network, res, err) { _networkHistory.push({ error: err, result: res, + versions: _networkVersions, timestamp: util.getCurrentTimeMs(), info: { ip: network.ip, port: network.port, type: network.type, - name: network.name + name: network.name, } }); @@ -217,4 +262,4 @@ if (config.logToDatabase) { logger.log('warn', 'Database logging is not enabled. You can enable it by setting "logToDatabase" to true in config.json. This requires sqlite3 to be installed.'); startServices(); -} \ No newline at end of file +} diff --git a/assets/css/main.css b/assets/css/main.css index 37c8c6a..e0d0f5d 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -145,7 +145,7 @@ a { } .server > .column > .rank { - width: 64px; + width: 64px; padding-top: 3px; } @@ -157,6 +157,18 @@ a { margin-bottom: 2px; } +.server > .column > .versions { + min-height: 22px; + padding-bottom: 3px; +} + +.server > .column > .versions > .version { + padding: 1px 5px; + border-radius: 2px; + border: 1px solid #A09E9E; + font-size: 12px; +} + .category-header { margin-bottom: 10px; margin-left: 15px; @@ -246,4 +258,4 @@ h3 { .button:hover { background: #ecf0f1; color: #3498db; -} \ No newline at end of file +} diff --git a/assets/js/site.js b/assets/js/site.js index 97fba3a..64e41d5 100644 --- a/assets/js/site.js +++ b/assets/js/site.js @@ -5,6 +5,15 @@ var historyPlot; var displayedGraphData; var hiddenGraphData = []; +var mcVersions = { + 'PC': { + 4: '1.7.2', + 5: '1.7.10', + 47: '1.8', + 107: '1.9' + } +}; + var isConnected = false; var mojangServicesUpdater; @@ -13,10 +22,21 @@ var sortServersTask; function updateServerStatus(lastEntry) { var info = lastEntry.info; var div = $('#status_' + safeName(info.name)); + var versionDiv = $('#version_' + safeName(info.name)); + + if (lastEntry.versions) { + var versions = ''; + for (var i = 0; i < lastEntry.versions.length; i++) { + versions += '' + mcVersions[lastEntry.info.type][lastEntry.versions[i]] + ' '; + } + versionDiv.html(versions); + } else { + versionDiv.html(''); + } if (lastEntry.result) { var result = lastEntry.result; - var newStatus = '
Players: ' + formatNumber(result.players.online); + var newStatus = 'Players: ' + formatNumber(result.players.online); var listing = graphs[lastEntry.info.name].listing; @@ -36,7 +56,7 @@ function updateServerStatus(lastEntry) { div.html(newStatus); } else { - var newStatus = '
'; + var newStatus = ''; if (findErrorMessage(lastEntry.error)) { newStatus += findErrorMessage(lastEntry.error); @@ -328,7 +348,7 @@ $(document).ready(function() {
\

' + info.name + ' ' + info.type + '

\ ' + info.ip + '\ -
\ +
\ Waiting\
\
\ diff --git a/config.json b/config.json index 70b9641..eaaf70a 100644 --- a/config.json +++ b/config.json @@ -31,5 +31,16 @@ "minigames": "Minigame Networks", "pocket": "Pocket Edition Networks" }, + "versions": { + "PC": [ + 4, + 5, + 47, + 107 + ], + "PE": [ + 0 + ] + }, "categoriesVisible": true } diff --git a/lib/ping.js b/lib/ping.js index 3faa239..bc1bd1e 100644 --- a/lib/ping.js +++ b/lib/ping.js @@ -4,7 +4,7 @@ var mcpc_ping = require('mc-ping-updated'); var util = require('./util'); // This is a wrapper function for mc-ping-updated, mainly used to convert the data structure of the result. -function pingMinecraftPC(host, port, timeout, callback) { +function pingMinecraftPC(host, port, timeout, callback, version) { var startTime = util.getCurrentTimeMs(); mcpc_ping(host, port, function(err, res) { @@ -22,7 +22,7 @@ function pingMinecraftPC(host, port, timeout, callback) { favicon: res.favicon }); } - }, timeout); + }, timeout, version); } // This is a wrapper function for mcpe-ping, mainly used to convert the data structure of the result. @@ -46,12 +46,12 @@ function pingMinecraftPE(host, port, timeout, callback) { }, timeout); } -exports.ping = function(host, port, type, timeout, callback) { +exports.ping = function(host, port, type, timeout, callback, version) { if (type === 'PC') { - pingMinecraftPC(host, port || 25565, timeout, callback); + pingMinecraftPC(host, port || 25565, timeout, callback, version); } else if (type === 'PE') { pingMinecraftPE(host, port || 19132, timeout, callback); } else { throw new Error('Unsupported type: ' + type); } -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 9b4a782..6f1e184 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A Minecraft server tracker that lets you focus on the basics.", "main": "app.js", "dependencies": { - "mc-ping-updated": "0.0.7", + "mc-ping-updated": "0.1.0", "mcpe-ping": "0.0.3", "mime": "^1.3.4", "request": "^2.65.0", From ec49a2c07e35779c44e56485c325e11d95182358 Mon Sep 17 00:00:00 2001 From: Devin Ryan Date: Tue, 1 Mar 2016 21:14:42 -0600 Subject: [PATCH 3/7] Unify formatting in main.css --- assets/css/main.css | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/css/main.css b/assets/css/main.css index e0d0f5d..cad11a5 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -1,16 +1,16 @@ @import url(https://fonts.googleapis.com/css?family=Open+Sans:700,300,400); * { - margin: 0; - padding: 0; + margin: 0; + padding: 0; } body { - background: #3B3738; - color: #FFF; - font-family: "Open Sans", sans-serif; - font-size: 18px; - font-weight: 300 !important; + background: #3B3738; + color: #FFF; + font-family: "Open Sans", sans-serif; + font-size: 18px; + font-weight: 300 !important; } /* Page layout */ @@ -158,12 +158,12 @@ a { } .server > .column > .versions { - min-height: 22px; - padding-bottom: 3px; + min-height: 22px; + padding-bottom: 3px; } .server > .column > .versions > .version { - padding: 1px 5px; + padding: 1px 5px; border-radius: 2px; border: 1px solid #A09E9E; font-size: 12px; From ea5fa03d375111332e5a8a67b8836ef4c57c560f Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Sun, 6 Mar 2016 01:27:47 -0600 Subject: [PATCH 4/7] A few quick frontend tweaks --- assets/css/main.css | 12 ++++++++---- assets/js/site.js | 7 +++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/assets/css/main.css b/assets/css/main.css index cad11a5..b736019 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -146,7 +146,11 @@ a { .server > .column > .rank { width: 64px; - padding-top: 3px; + padding-top: 4px; +} + +.server > .column > .url { + font-size: 16px; } .server > .column > h3 > .type { @@ -158,14 +162,14 @@ a { } .server > .column > .versions { - min-height: 22px; - padding-bottom: 3px; + min-height: 23px; + padding-bottom: 1px; } .server > .column > .versions > .version { padding: 1px 5px; border-radius: 2px; - border: 1px solid #A09E9E; + border: 1px solid #636363; font-size: 12px; } diff --git a/assets/js/site.js b/assets/js/site.js index 64e41d5..8378178 100644 --- a/assets/js/site.js +++ b/assets/js/site.js @@ -21,14 +21,17 @@ var sortServersTask; function updateServerStatus(lastEntry) { var info = lastEntry.info; + var div = $('#status_' + safeName(info.name)); var versionDiv = $('#version_' + safeName(info.name)); if (lastEntry.versions) { var versions = ''; + for (var i = 0; i < lastEntry.versions.length; i++) { versions += '' + mcVersions[lastEntry.info.type][lastEntry.versions[i]] + ' '; } + versionDiv.html(versions); } else { versionDiv.html(''); @@ -347,8 +350,8 @@ $(document).ready(function() {
\
\

' + info.name + ' ' + info.type + '

\ - ' + info.ip + '\ -
\ + ' + info.ip + '\ +
\ Waiting\
\
\ From 029202d127036bc64bbe1653fef55520fb88c91a Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Sun, 6 Mar 2016 01:30:38 -0600 Subject: [PATCH 5/7] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81f7a6f..c87cabd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,7 @@ - New endpoint (```publicConfig.json```) allows the browser to know system details before the socket connection is established. - New header design to make it less annoying. - Various bug fixes. + +**2.2.0** *(Mar 6th 2016)* +- Added supported versions per network (courtesy of [@forairan](https://github.com/forairan)) +- Updated dependency version of ```mc-ping-updated``` to 0.1.0 From e300081644cf726f52d02a159179956a5221e4d7 Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Sun, 6 Mar 2016 01:31:03 -0600 Subject: [PATCH 6/7] Flip the update order --- CHANGELOG.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c87cabd..a1ff62f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,8 @@ -**2.0.0** *(Feb 1st 2016)* -- Servers are now referenced by their name on the graph controls instead of their IP. -- Servers now display their name on hover instead of their IP. -- Graph controls are now saved and loaded automatically. -- Moved server configuration into servers.json from config.json. +**2.2.0** *(Mar 6 2016)* +- Added supported versions per network (courtesy of [@forairan](https://github.com/forairan)) +- Updated dependency version of ```mc-ping-updated``` to 0.1.0 -**2.1.0** *(Feb 23rd 2016)* +**2.1.0** *(Feb 23 2016)* - You can now categorize servers. Add a "category tag" to their entry in ```servers.json```. - Define the tags in ```config.json```, such as below: @@ -22,6 +20,8 @@ - New header design to make it less annoying. - Various bug fixes. -**2.2.0** *(Mar 6th 2016)* -- Added supported versions per network (courtesy of [@forairan](https://github.com/forairan)) -- Updated dependency version of ```mc-ping-updated``` to 0.1.0 +**2.0.0** *(Feb 1 2016)* +- Servers are now referenced by their name on the graph controls instead of their IP. +- Servers now display their name on hover instead of their IP. +- Graph controls are now saved and loaded automatically. +- Moved server configuration into servers.json from config.json. From 75703db9be3efff83ac6a1cde7d559f41cb3c890 Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Sun, 6 Mar 2016 01:31:19 -0600 Subject: [PATCH 7/7] Become version 2.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f1e184..4659186 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minetrack", - "version": "2.1.0", + "version": "2.2.0", "description": "A Minecraft server tracker that lets you focus on the basics.", "main": "app.js", "dependencies": {