mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-18 23:34:04 +02:00
fix: Check if it is an IP or a hostname
This commit is contained in:
parent
4367d5686f
commit
23f5b0cefd
1 changed files with 5 additions and 4 deletions
|
@ -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,
|
||||||
|
|
Loading…
Add table
Reference in a new issue