Merge pull request #36 from Cryptkeeper/forairan-master
forairan-master
This commit is contained in:
commit
cf5e51682a
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,4 +3,6 @@ node_modules/
|
|||||||
.idea/
|
.idea/
|
||||||
production/
|
production/
|
||||||
database.sql
|
database.sql
|
||||||
database.sql-journal
|
database.sql-journal
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
16
CHANGELOG.md
16
CHANGELOG.md
@ -1,10 +1,8 @@
|
|||||||
**2.0.0** *(Feb 1st 2016)*
|
**2.2.0** *(Mar 6 2016)*
|
||||||
- Servers are now referenced by their name on the graph controls instead of their IP.
|
- Added supported versions per network (courtesy of [@forairan](https://github.com/forairan))
|
||||||
- Servers now display their name on hover instead of their IP.
|
- Updated dependency version of ```mc-ping-updated``` to 0.1.0
|
||||||
- Graph controls are now saved and loaded automatically.
|
|
||||||
- Moved server configuration into servers.json from config.json.
|
|
||||||
|
|
||||||
**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```.
|
- You can now categorize servers. Add a "category tag" to their entry in ```servers.json```.
|
||||||
- Define the tags in ```config.json```, such as below:
|
- Define the tags in ```config.json```, such as below:
|
||||||
|
|
||||||
@ -21,3 +19,9 @@
|
|||||||
- New endpoint (```publicConfig.json```) allows the browser to know system details before the socket connection is established.
|
- 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.
|
- New header design to make it less annoying.
|
||||||
- Various bug fixes.
|
- Various bug fixes.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
69
app.js
69
app.js
@ -11,6 +11,12 @@ var servers = require('./servers.json');
|
|||||||
var networkHistory = [];
|
var networkHistory = [];
|
||||||
var connectedClients = 0;
|
var connectedClients = 0;
|
||||||
|
|
||||||
|
var currentVersionIndex = {
|
||||||
|
'PC': 0,
|
||||||
|
'PE': 0
|
||||||
|
};
|
||||||
|
var networkVersions = [];
|
||||||
|
|
||||||
var graphData = [];
|
var graphData = [];
|
||||||
var lastGraphPush = [];
|
var lastGraphPush = [];
|
||||||
|
|
||||||
@ -18,6 +24,7 @@ function pingAll() {
|
|||||||
for (var i = 0; i < servers.length; i++) {
|
for (var i = 0; i < servers.length; i++) {
|
||||||
// Make sure we lock our scope.
|
// Make sure we lock our scope.
|
||||||
(function(network) {
|
(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) {
|
ping.ping(network.ip, network.port, network.type, config.rates.connectTimeout, function(err, res) {
|
||||||
// Handle our ping results, if it succeeded.
|
// Handle our ping results, if it succeeded.
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -29,20 +36,62 @@ function pingAll() {
|
|||||||
res.favicon = config.faviconOverride[network.name];
|
res.favicon = config.faviconOverride[network.name];
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePing(network, res, err);
|
handlePing(network, res, err, attemptedVersion);
|
||||||
});
|
}, attemptedVersion);
|
||||||
})(servers[i]);
|
})(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 is where the result of a ping is feed.
|
||||||
// This stores it and converts it to ship to the frontend.
|
// 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 = {
|
var networkSnapshot = {
|
||||||
info: {
|
info: {
|
||||||
name: network.name,
|
name: network.name,
|
||||||
timestamp: util.getCurrentTimeMs()
|
timestamp: util.getCurrentTimeMs(),
|
||||||
}
|
type: network.type
|
||||||
|
},
|
||||||
|
versions: _networkVersions
|
||||||
};
|
};
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
@ -53,11 +102,6 @@ function handlePing(network, res, err) {
|
|||||||
|
|
||||||
server.io.sockets.emit('update', networkSnapshot);
|
server.io.sockets.emit('update', networkSnapshot);
|
||||||
|
|
||||||
// Log our response.
|
|
||||||
if (!networkHistory[network.name]) {
|
|
||||||
networkHistory[network.name] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var _networkHistory = networkHistory[network.name];
|
var _networkHistory = networkHistory[network.name];
|
||||||
|
|
||||||
// Remove our previous data that we don't need anymore.
|
// Remove our previous data that we don't need anymore.
|
||||||
@ -72,12 +116,13 @@ function handlePing(network, res, err) {
|
|||||||
_networkHistory.push({
|
_networkHistory.push({
|
||||||
error: err,
|
error: err,
|
||||||
result: res,
|
result: res,
|
||||||
|
versions: _networkVersions,
|
||||||
timestamp: util.getCurrentTimeMs(),
|
timestamp: util.getCurrentTimeMs(),
|
||||||
info: {
|
info: {
|
||||||
ip: network.ip,
|
ip: network.ip,
|
||||||
port: network.port,
|
port: network.port,
|
||||||
type: network.type,
|
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.');
|
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();
|
startServices();
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:700,300,400);
|
@import url(https://fonts.googleapis.com/css?family=Open+Sans:700,300,400);
|
||||||
|
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: #3B3738;
|
background: #3B3738;
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
font-family: "Open Sans", sans-serif;
|
font-family: "Open Sans", sans-serif;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 300 !important;
|
font-weight: 300 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Page layout */
|
/* Page layout */
|
||||||
@ -145,8 +145,12 @@ a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.server > .column > .rank {
|
.server > .column > .rank {
|
||||||
width: 64px;
|
width: 64px;
|
||||||
padding-top: 3px;
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server > .column > .url {
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.server > .column > h3 > .type {
|
.server > .column > h3 > .type {
|
||||||
@ -157,6 +161,18 @@ a {
|
|||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.server > .column > .versions {
|
||||||
|
min-height: 23px;
|
||||||
|
padding-bottom: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server > .column > .versions > .version {
|
||||||
|
padding: 1px 5px;
|
||||||
|
border-radius: 2px;
|
||||||
|
border: 1px solid #636363;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.category-header {
|
.category-header {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
@ -246,4 +262,4 @@ h3 {
|
|||||||
.button:hover {
|
.button:hover {
|
||||||
background: #ecf0f1;
|
background: #ecf0f1;
|
||||||
color: #3498db;
|
color: #3498db;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,15 @@ var historyPlot;
|
|||||||
var displayedGraphData;
|
var displayedGraphData;
|
||||||
var hiddenGraphData = [];
|
var hiddenGraphData = [];
|
||||||
|
|
||||||
|
var mcVersions = {
|
||||||
|
'PC': {
|
||||||
|
4: '1.7.2',
|
||||||
|
5: '1.7.10',
|
||||||
|
47: '1.8',
|
||||||
|
107: '1.9'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var isConnected = false;
|
var isConnected = false;
|
||||||
|
|
||||||
var mojangServicesUpdater;
|
var mojangServicesUpdater;
|
||||||
@ -12,11 +21,25 @@ var sortServersTask;
|
|||||||
|
|
||||||
function updateServerStatus(lastEntry) {
|
function updateServerStatus(lastEntry) {
|
||||||
var info = lastEntry.info;
|
var info = lastEntry.info;
|
||||||
|
|
||||||
var div = $('#status_' + safeName(info.name));
|
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 += '<span class="version">' + mcVersions[lastEntry.info.type][lastEntry.versions[i]] + '</span> ';
|
||||||
|
}
|
||||||
|
|
||||||
|
versionDiv.html(versions);
|
||||||
|
} else {
|
||||||
|
versionDiv.html('');
|
||||||
|
}
|
||||||
|
|
||||||
if (lastEntry.result) {
|
if (lastEntry.result) {
|
||||||
var result = lastEntry.result;
|
var result = lastEntry.result;
|
||||||
var newStatus = '<br />Players: ' + formatNumber(result.players.online);
|
var newStatus = 'Players: ' + formatNumber(result.players.online);
|
||||||
|
|
||||||
var listing = graphs[lastEntry.info.name].listing;
|
var listing = graphs[lastEntry.info.name].listing;
|
||||||
|
|
||||||
@ -36,7 +59,7 @@ function updateServerStatus(lastEntry) {
|
|||||||
|
|
||||||
div.html(newStatus);
|
div.html(newStatus);
|
||||||
} else {
|
} else {
|
||||||
var newStatus = '<br /><span class="color-red">';
|
var newStatus = '<span class="color-red">';
|
||||||
|
|
||||||
if (findErrorMessage(lastEntry.error)) {
|
if (findErrorMessage(lastEntry.error)) {
|
||||||
newStatus += findErrorMessage(lastEntry.error);
|
newStatus += findErrorMessage(lastEntry.error);
|
||||||
@ -327,8 +350,8 @@ $(document).ready(function() {
|
|||||||
</div>\
|
</div>\
|
||||||
<div class="column" style="width: 220px;">\
|
<div class="column" style="width: 220px;">\
|
||||||
<h3>' + info.name + ' <span class="type">' + info.type + '</span></h3>\
|
<h3>' + info.name + ' <span class="type">' + info.type + '</span></h3>\
|
||||||
<span class="color-gray">' + info.ip + '</span>\
|
<span class="color-gray url">' + info.ip + '</span>\
|
||||||
<br />\
|
<div id="version_' + safeName(info.name) + '" class="versions"><span class="version"></span></div>\
|
||||||
<span id="status_' + safeName(info.name) + '">Waiting</span>\
|
<span id="status_' + safeName(info.name) + '">Waiting</span>\
|
||||||
</div>\
|
</div>\
|
||||||
<div class="column" style="float: right;">\
|
<div class="column" style="float: right;">\
|
||||||
|
11
config.json
11
config.json
@ -31,5 +31,16 @@
|
|||||||
"minigames": "Minigame Networks",
|
"minigames": "Minigame Networks",
|
||||||
"pocket": "Pocket Edition Networks"
|
"pocket": "Pocket Edition Networks"
|
||||||
},
|
},
|
||||||
|
"versions": {
|
||||||
|
"PC": [
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
47,
|
||||||
|
107
|
||||||
|
],
|
||||||
|
"PE": [
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
"categoriesVisible": true
|
"categoriesVisible": true
|
||||||
}
|
}
|
||||||
|
10
lib/ping.js
10
lib/ping.js
@ -4,7 +4,7 @@ var mcpc_ping = require('mc-ping-updated');
|
|||||||
var util = require('./util');
|
var util = require('./util');
|
||||||
|
|
||||||
// This is a wrapper function for mc-ping-updated, mainly used to convert the data structure of the result.
|
// 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();
|
var startTime = util.getCurrentTimeMs();
|
||||||
|
|
||||||
mcpc_ping(host, port, function(err, res) {
|
mcpc_ping(host, port, function(err, res) {
|
||||||
@ -22,7 +22,7 @@ function pingMinecraftPC(host, port, timeout, callback) {
|
|||||||
favicon: res.favicon
|
favicon: res.favicon
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, timeout);
|
}, timeout, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a wrapper function for mcpe-ping, mainly used to convert the data structure of the result.
|
// 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);
|
}, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.ping = function(host, port, type, timeout, callback) {
|
exports.ping = function(host, port, type, timeout, callback, version) {
|
||||||
if (type === 'PC') {
|
if (type === 'PC') {
|
||||||
pingMinecraftPC(host, port || 25565, timeout, callback);
|
pingMinecraftPC(host, port || 25565, timeout, callback, version);
|
||||||
} else if (type === 'PE') {
|
} else if (type === 'PE') {
|
||||||
pingMinecraftPE(host, port || 19132, timeout, callback);
|
pingMinecraftPE(host, port || 19132, timeout, callback);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unsupported type: ' + type);
|
throw new Error('Unsupported type: ' + type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "minetrack",
|
"name": "minetrack",
|
||||||
"version": "2.1.0",
|
"version": "2.2.0",
|
||||||
"description": "A Minecraft server tracker that lets you focus on the basics.",
|
"description": "A Minecraft server tracker that lets you focus on the basics.",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mc-ping-updated": "0.0.7",
|
"mc-ping-updated": "0.1.0",
|
||||||
"mcpe-ping": "0.0.3",
|
"mcpe-ping": "0.0.3",
|
||||||
"mime": "^1.3.4",
|
"mime": "^1.3.4",
|
||||||
"request": "^2.65.0",
|
"request": "^2.65.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user