use name to identify servers not ip

This commit is contained in:
Lee
2024-01-03 08:27:33 +00:00
parent 56a75560e8
commit 8826a2530a
5 changed files with 16 additions and 49 deletions

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

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

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