mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-01-31 21:40:38 +00:00
Retrieve live server data
This commit is contained in:
parent
75ac2fe1ab
commit
1ec36bbb6f
5 changed files with 39 additions and 64 deletions
|
@ -1,58 +1 @@
|
||||||
{
|
{"servers":[{"id":3,"description":"Paid by jiriki, Admirable, Amx etc.","dns":"s2.ensl.org","ip":"78.46.36.107","port":"27015","password":"europe","category_id":44},{"id":6,"description":"","dns":"ensl.org","ip":"78.46.36.107","port":"28100","password":"","category_id":44},{"id":7,"description":"","dns":"ensl.org","ip":"78.46.36.107","port":"28200","password":"","category_id":44},{"id":8,"description":"","dns":"ensl.org","ip":"78.46.36.107","port":"28300","password":"","category_id":44},{"id":68,"description":"","dns":"Team Work and Tactics","ip":"94.23.44.64","port":"27019","password":"twats","category_id":44},{"id":82,"description":"Gather Server","dns":"Gather -Paris-","ip":"62.210.206.58","port":"27023","password":"ns2nsl","category_id":44},{"id":83,"description":"","dns":"Gather -Paris- ","ip":"62.210.206.58","port":"27023","password":"ns2nsl","category_id":45},{"id":89,"description":"US Server","dns":"Gather -US-","ip":"50.97.73.146","port":"27023","password":"pug","category_id":45},{"id":90,"description":"","dns":"85.229.112.48","ip":"85.229.112.48","port":"27029","password":"ns2nsl","category_id":45},{"id":91,"description":"","dns":"adm.0ffline.at","ip":"91.206.237.100","port":"27015","password":"ns2nsl","category_id":45},{"id":92,"description":"wat","dns":"lon040.multiplay.co.uk","ip":"85.236.100.182","port":"27015","password":"ns2nsl","category_id":45},{"id":94,"description":"Matches and gathers - Courtesy of ns2.guru","dns":"hodor.ns2.guru","ip":"87.252.1.252","port":"27666","password":"ns2nsl","category_id":45},{"id":95,"description":"Hosted by Kaneh","dns":"158.85.65.172","ip":"158.85.65.172","port":"27019","password":"ns2nsl","category_id":45},{"id":96,"description":"","dns":"37.187.56.111","ip":"37.187.56.111","port":"27115","password":"ns2nsl","category_id":45},{"id":97,"description":"","dns":"rraawwrr.com","ip":"77.174.163.156","port":"27015","password":"ns2nsl","category_id":45},{"id":98,"description":"Owner is Shameless - Ping is good for EU & NA","dns":"208.167.249.165","ip":"208.167.249.165","port":"27015","password":"ns2nsl","category_id":45},{"id":99,"description":"Description","dns":"NSL SERVAH","ip":"192.1.1.1","port":"8000","password":"NSLSLSLS","category_id":45}]}
|
||||||
"servers":[
|
|
||||||
{
|
|
||||||
"id":102,
|
|
||||||
"name":"Wraith::NSL::Amsterdam#1",
|
|
||||||
"description":"OwnerisFurs",
|
|
||||||
"ip":"89.105.209.250",
|
|
||||||
"dns":"89.105.209.250",
|
|
||||||
"port":27020,
|
|
||||||
"password":"ns2nsl"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":103,
|
|
||||||
"name":"NSLMatch-London#2",
|
|
||||||
"description":"OwnerisUWE",
|
|
||||||
"ip":"85.236.102.73",
|
|
||||||
"dns":"85.236.102.73",
|
|
||||||
"port":27215,
|
|
||||||
"password":"ns2nsl"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":104,
|
|
||||||
"name":"NSLMatch-Paris[NS2FR.com]",
|
|
||||||
"description":"OwnerisMGS AdminisSephy",
|
|
||||||
"ip":"62.210.206.58",
|
|
||||||
"dns":"62.210.206.58",
|
|
||||||
"port":27023,
|
|
||||||
"password":"ns2nsl"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":106,
|
|
||||||
"name":"r/ns2pugs#3::Toronto",
|
|
||||||
"description":"OwnerisKaneh",
|
|
||||||
"ip":"158.85.65.172",
|
|
||||||
"dns":"158.85.65.172",
|
|
||||||
"port":27017,
|
|
||||||
"password":"pug"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":107,
|
|
||||||
"name":"r/ns2pugs#1::Dallas",
|
|
||||||
"description":"OwnerisKaneh",
|
|
||||||
"ip":"50.91.73.146",
|
|
||||||
"dns":"50.91.73.146",
|
|
||||||
"port":27015,
|
|
||||||
"password":"pug"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":109,
|
|
||||||
"name":"NSLMatch-NJ USA-(loMe's)",
|
|
||||||
"description":"loMeisOwner",
|
|
||||||
"ip":"107.191.36.140",
|
|
||||||
"dns":"107.191.36.140",
|
|
||||||
"port":40000,
|
|
||||||
"password":"ns2nsl"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -3,6 +3,8 @@
|
||||||
var request = require("request");
|
var request = require("request");
|
||||||
var env = process.env.NODE_ENV || "development";
|
var env = process.env.NODE_ENV || "development";
|
||||||
|
|
||||||
|
const SERVER_CATEGORY = 44;
|
||||||
|
|
||||||
function EnslClient (options) {
|
function EnslClient (options) {
|
||||||
if (!(this instanceof EnslClient)) {
|
if (!(this instanceof EnslClient)) {
|
||||||
return new EnslClient(options);
|
return new EnslClient(options);
|
||||||
|
@ -15,12 +17,28 @@ EnslClient.prototype.getUserById = function (options, callback) {
|
||||||
var id = options.id;
|
var id = options.id;
|
||||||
var url = this.baseUrl + "/api/v1/users/" + id;
|
var url = this.baseUrl + "/api/v1/users/" + id;
|
||||||
|
|
||||||
request({
|
return request({
|
||||||
url: url,
|
url: url,
|
||||||
json: true
|
json: true
|
||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EnslClient.prototype.getServers = function (callback) {
|
||||||
|
var url = this.baseUrl + "/api/v1/servers";
|
||||||
|
|
||||||
|
return request({
|
||||||
|
url: url,
|
||||||
|
json: true
|
||||||
|
}, function (error, _, data) {
|
||||||
|
if (error) return callback(error);
|
||||||
|
return callback(null, {
|
||||||
|
servers: data.servers.filter(function (server) {
|
||||||
|
return server.category_id === SERVER_CATEGORY;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
EnslClient.prototype.getFullAvatarUri = function (url) {
|
EnslClient.prototype.getFullAvatarUri = function (url) {
|
||||||
return this.baseUrl + url;
|
return this.baseUrl + url;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,13 +2,27 @@
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var source = JSON.parse(fs.readFileSync(path.join(__dirname, "../../config/data/servers.json")));
|
var winston = require("winston");
|
||||||
var serverList = source.servers;
|
var client = require(path.join(__dirname, "../ensl/client"))();
|
||||||
|
var serverFile = path.join(__dirname, "../../config/data/servers.json");
|
||||||
|
|
||||||
|
const REFRESH_INTERVAL = 1000 * 60 * 60; // Check every hour
|
||||||
|
|
||||||
function Server () {
|
function Server () {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.list = serverList;
|
Server.updateServerList = function () {
|
||||||
|
client.getServers(function (error, result) {
|
||||||
|
if (error) winston.error("Unable to download server list", error);
|
||||||
|
Server.list = result.servers;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Server.list = JSON.parse(fs.readFileSync(serverFile)).servers;
|
||||||
|
|
||||||
|
Server.updateServerList();
|
||||||
|
|
||||||
|
setInterval(Server.updateServerList, REFRESH_INTERVAL);
|
||||||
|
|
||||||
module.exports = Server;
|
module.exports = Server;
|
||||||
|
|
|
@ -369,7 +369,7 @@ var ServerVoting = React.createClass({
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<tr key={server.id}>
|
<tr key={server.id}>
|
||||||
<td className="col-md-6">{server.name}</td>
|
<td className="col-md-6">{server.description || server.dns}</td>
|
||||||
<td className="col-md-6 text-right">
|
<td className="col-md-6 text-right">
|
||||||
{self.votesForServer(server)} Votes
|
{self.votesForServer(server)} Votes
|
||||||
{voteButton}
|
{voteButton}
|
||||||
|
|
|
@ -467,7 +467,7 @@ var ServerVoting = React.createClass({
|
||||||
React.createElement(
|
React.createElement(
|
||||||
"td",
|
"td",
|
||||||
{ className: "col-md-6" },
|
{ className: "col-md-6" },
|
||||||
server.name
|
server.description || server.dns
|
||||||
),
|
),
|
||||||
React.createElement(
|
React.createElement(
|
||||||
"td",
|
"td",
|
||||||
|
|
Loading…
Reference in a new issue