From 4da1341aa50af2b93b6d1e95a1cbdb6d02234c64 Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Sat, 26 Aug 2023 21:27:32 +0800 Subject: [PATCH] Fix: Improve dnsMessage handling (#3614) --- server/model/monitor.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 0eab5732d..1cea35533 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -581,13 +581,13 @@ class Monitor extends BeanModel { let dnsRes = await dnsResolve(this.hostname, this.dns_resolve_server, this.port, this.dns_resolve_type); bean.ping = dayjs().valueOf() - startTime; - if (this.dns_resolve_type === "A" || this.dns_resolve_type === "AAAA" || this.dns_resolve_type === "TXT") { + if (this.dns_resolve_type === "A" || this.dns_resolve_type === "AAAA" || this.dns_resolve_type === "TXT" || this.dns_resolve_type === "PTR") { dnsMessage += "Records: "; dnsMessage += dnsRes.join(" | "); - } else if (this.dns_resolve_type === "CNAME" || this.dns_resolve_type === "PTR") { - dnsMessage = dnsRes[0]; + } else if (this.dns_resolve_type === "CNAME") { + dnsMessage += dnsRes[0]; } else if (this.dns_resolve_type === "CAA") { - dnsMessage = dnsRes[0].issue; + dnsMessage += dnsRes[0].issue; } else if (this.dns_resolve_type === "MX") { dnsRes.forEach(record => { dnsMessage += `Hostname: ${record.exchange} - Priority: ${record.priority} | `; @@ -605,7 +605,7 @@ class Monitor extends BeanModel { dnsMessage = dnsMessage.slice(0, -2); } - if (this.dnsLastResult !== dnsMessage) { + if (this.dnsLastResult !== dnsMessage && dnsMessage !== undefined) { R.exec("UPDATE `monitor` SET dns_last_result = ? WHERE id = ? ", [ dnsMessage, this.id