mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
Fix: Improve dnsMessage handling (#3614)
This commit is contained in:
parent
e765e6a1b8
commit
4da1341aa5
|
@ -581,13 +581,13 @@ class Monitor extends BeanModel {
|
||||||
let dnsRes = await dnsResolve(this.hostname, this.dns_resolve_server, this.port, this.dns_resolve_type);
|
let dnsRes = await dnsResolve(this.hostname, this.dns_resolve_server, this.port, this.dns_resolve_type);
|
||||||
bean.ping = dayjs().valueOf() - startTime;
|
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 += "Records: ";
|
||||||
dnsMessage += dnsRes.join(" | ");
|
dnsMessage += dnsRes.join(" | ");
|
||||||
} else if (this.dns_resolve_type === "CNAME" || this.dns_resolve_type === "PTR") {
|
} else if (this.dns_resolve_type === "CNAME") {
|
||||||
dnsMessage = dnsRes[0];
|
dnsMessage += dnsRes[0];
|
||||||
} else if (this.dns_resolve_type === "CAA") {
|
} else if (this.dns_resolve_type === "CAA") {
|
||||||
dnsMessage = dnsRes[0].issue;
|
dnsMessage += dnsRes[0].issue;
|
||||||
} else if (this.dns_resolve_type === "MX") {
|
} else if (this.dns_resolve_type === "MX") {
|
||||||
dnsRes.forEach(record => {
|
dnsRes.forEach(record => {
|
||||||
dnsMessage += `Hostname: ${record.exchange} - Priority: ${record.priority} | `;
|
dnsMessage += `Hostname: ${record.exchange} - Priority: ${record.priority} | `;
|
||||||
|
@ -605,7 +605,7 @@ class Monitor extends BeanModel {
|
||||||
dnsMessage = dnsMessage.slice(0, -2);
|
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 = ? ", [
|
R.exec("UPDATE `monitor` SET dns_last_result = ? WHERE id = ? ", [
|
||||||
dnsMessage,
|
dnsMessage,
|
||||||
this.id
|
this.id
|
||||||
|
|
Loading…
Reference in a new issue