fix: Check if it is an IP or a hostname

This commit is contained in:
Mario Garrido 2025-07-04 15:57:32 +01:00
parent 4367d5686f
commit 23f5b0cefd

View file

@ -2,6 +2,7 @@ const { MonitorType } = require("./monitor-type");
const { UP, DOWN } = require("../../src/util"); const { UP, DOWN } = require("../../src/util");
const Gamedig = require("gamedig"); const Gamedig = require("gamedig");
const dns = require("dns").promises; const dns = require("dns").promises;
const net = require('net');
class GameDigMonitorType extends MonitorType { class GameDigMonitorType extends MonitorType {
name = "gamedig"; name = "gamedig";
@ -12,12 +13,12 @@ class GameDigMonitorType extends MonitorType {
async check(monitor, heartbeat, server) { async check(monitor, heartbeat, server) {
heartbeat.status = DOWN; heartbeat.status = DOWN;
let host = monitor.hostname; if (net.isIP(host) === 0) {
host = await this.resolveHostname(host);
if (monitor.gamedigResolveHostToIP) {
host = await this.resolveHostname(monitor.hostname);
} }
host = await this.resolveHostname(monitor.hostname);
try { try {
const state = await Gamedig.query({ const state = await Gamedig.query({
type: monitor.game, type: monitor.game,