From 23f5b0cefd5b8578390f7d05765cb996ac2df311 Mon Sep 17 00:00:00 2001 From: Mario Garrido Date: Fri, 4 Jul 2025 15:57:32 +0100 Subject: [PATCH] fix: Check if it is an IP or a hostname --- server/monitor-types/gamedig.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/monitor-types/gamedig.js b/server/monitor-types/gamedig.js index b1fa64347..c0c6dd97f 100644 --- a/server/monitor-types/gamedig.js +++ b/server/monitor-types/gamedig.js @@ -2,6 +2,7 @@ const { MonitorType } = require("./monitor-type"); const { UP, DOWN } = require("../../src/util"); const Gamedig = require("gamedig"); const dns = require("dns").promises; +const net = require('net'); class GameDigMonitorType extends MonitorType { name = "gamedig"; @@ -12,12 +13,12 @@ class GameDigMonitorType extends MonitorType { async check(monitor, heartbeat, server) { heartbeat.status = DOWN; - let host = monitor.hostname; - - if (monitor.gamedigResolveHostToIP) { - host = await this.resolveHostname(monitor.hostname); + if (net.isIP(host) === 0) { + host = await this.resolveHostname(host); } + host = await this.resolveHostname(monitor.hostname); + try { const state = await Gamedig.query({ type: monitor.game,