influx-only #2

Merged
Fascinated merged 20 commits from influx-only into master 2024-01-03 08:32:27 +00:00
5 changed files with 16 additions and 49 deletions
Showing only changes of commit 8826a2530a - Show all commits

3
.gitignore vendored

@ -229,5 +229,4 @@ data/db.sqlite-shm
data/db.sqlite-wal data/db.sqlite-wal
data/database-backups data/database-backups
data/config.json data/config.json
data/servers.json

@ -2,73 +2,61 @@
{ {
"name": "WildPrison", "name": "WildPrison",
"ip": "wildprison.net", "ip": "wildprison.net",
"type": "PC", "type": "PC"
"id": 0
}, },
{ {
"name": "Hypixel", "name": "Hypixel",
"ip": "mc.hypixel.net", "ip": "mc.hypixel.net",
"type": "PC", "type": "PC"
"id": 1
}, },
{ {
"name": "CubeCraft", "name": "Cubecraft",
"ip": "play.cubecraft.net", "ip": "play.cubecraft.net",
"type": "PC", "type": "PC"
"id": 2
}, },
{ {
"name": "Mineplex", "name": "Mineplex",
"ip": "mineplex.com", "ip": "mineplex.com",
"type": "PC", "type": "PC"
"id": 3
}, },
{ {
"name": "2b2t", "name": "2b2t",
"ip": "2b2t.org", "ip": "2b2t.org",
"type": "PC", "type": "PC"
"id": 4
}, },
{ {
"name": "AkumaMC", "name": "AkumaMC",
"ip": "akumamc.net", "ip": "akumamc.net",
"type": "PC", "type": "PC"
"id": 5
}, },
{ {
"name": "Wynncraft", "name": "Wynncraft",
"ip": "play.wynncraft.com", "ip": "play.wynncraft.com",
"type": "PC", "type": "PC"
"id": 6
}, },
{ {
"name": "Minehut", "name": "Minehut",
"ip": "minehut.com", "ip": "minehut.com",
"type": "PC", "type": "PC"
"id": 7
}, },
{ {
"name": "Grand Theft Minecraft", "name": "Grand Theft Minecraft",
"ip": "gtm.network", "ip": "gtm.network",
"type": "PC", "type": "PC"
"id": 8
}, },
{ {
"name": "HiveMC", "name": "HiveMC",
"ip": "geo.hivebedrock.network", "ip": "geo.hivebedrock.network",
"type": "PE", "type": "PE"
"id": 9
}, },
{ {
"name": "Purple Prison", "name": "Purple Prison",
"ip": "MCSL.PURPLE.WTF", "ip": "MCSL.PURPLE.WTF",
"type": "PC", "type": "PC"
"id": 10
}, },
{ {
"name": "MinecraftOnline", "name": "MinecraftOnline",
"ip": "minecraftonline.com", "ip": "minecraftonline.com",
"type": "PC", "type": "PC"
"id": 11
} }
] ]

@ -20,7 +20,6 @@ export enum ServerStatus {
} }
type ServerOptions = { type ServerOptions = {
id: number;
name: string; name: string;
ip: string; ip: string;
port?: number; port?: number;
@ -33,11 +32,6 @@ type DnsInfo = {
}; };
export default class Server { export default class Server {
/**
* The ID of the server.
*/
private id: number;
/** /**
* The name of the server. * The name of the server.
*/ */
@ -71,8 +65,7 @@ export default class Server {
hasResolved: false, hasResolved: false,
}; };
constructor({ id, name, ip, port, type }: ServerOptions) { constructor({ name, ip, port, type }: ServerOptions) {
this.id = id;
this.name = name; this.name = name;
this.ip = ip; this.ip = ip;
this.port = port; this.port = port;
@ -106,7 +99,7 @@ export default class Server {
try { try {
influx.writePoint( influx.writePoint(
new Point("playerCount") new Point("playerCount")
.tag("id", this.getID().toString()) .tag("name", this.getName())
.tag("ip", this.getIP().toLowerCase()) .tag("ip", this.getIP().toLowerCase())
.intField("playerCount", response.playerCount) .intField("playerCount", response.playerCount)
.timestamp(response.timestamp) .timestamp(response.timestamp)
@ -163,7 +156,6 @@ export default class Server {
this.favicon = res.favicon; // Set the favicon this.favicon = res.favicon; // Set the favicon
resolve({ resolve({
id: this.getID(),
timestamp: Date.now(), timestamp: Date.now(),
ip: ip, ip: ip,
playerCount: res.players.online, playerCount: res.players.online,
@ -189,7 +181,6 @@ export default class Server {
} }
resolve({ resolve({
id: this.getID(),
timestamp: Date.now(), timestamp: Date.now(),
ip: this.getIP(), ip: this.getIP(),
playerCount: res.currentPlayers, playerCount: res.currentPlayers,
@ -199,15 +190,6 @@ export default class Server {
}); });
} }
/**
* Returns the ID of the server.
*
* @returns the ID
*/
public getID(): number {
return this.id;
}
/** /**
* Returns the name of the server. * Returns the name of the server.
* *

@ -15,7 +15,6 @@ export default class ServerManager {
logger.info("Loading servers"); logger.info("Loading servers");
for (const configServer of Servers) { for (const configServer of Servers) {
const server = new Server({ const server = new Server({
id: configServer.id,
ip: configServer.ip, ip: configServer.ip,
name: configServer.name, name: configServer.name,
type: configServer.type as ServerType, type: configServer.type as ServerType,

@ -1,5 +1,4 @@
export type Ping = { export type Ping = {
id: number;
timestamp: number; timestamp: number;
ip: string; ip: string;
playerCount: number; playerCount: number;