From d313a06d5c21f90376a88280324e74de57d10bb6 Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Wed, 25 Aug 2021 09:31:42 +0200 Subject: [PATCH] Optimizations for output handling --- server/model/monitor.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 40abf1f1d..69fc2c917 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -184,12 +184,9 @@ class Monitor extends BeanModel { let dnsRes = await dnsResolve(this.hostname, this.dns_resolve_server, this.dns_resolve_type); bean.ping = dayjs().valueOf() - startTime; - if (this.dns_resolve_type == "A" || this.dns_resolve_type == "AAAA") { + if (this.dns_resolve_type == "A" || this.dns_resolve_type == "AAAA" || this.dns_resolve_type == "TXT") { dnsMessage += "Records: "; - dnsRes.forEach(record => { - dnsMessage += `${record} | `; - }); - dnsMessage = dnsMessage.slice(0, -2) + dnsMessage += dnsRes.join(" | "); } else if (this.dns_resolve_type == "CNAME" || this.dns_resolve_type == "PTR") { dnsMessage = dnsRes[0]; } else if (this.dns_resolve_type == "CAA") { @@ -201,10 +198,7 @@ class Monitor extends BeanModel { dnsMessage = dnsMessage.slice(0, -2) } else if (this.dns_resolve_type == "NS") { dnsMessage += "Servers: "; - dnsRes.forEach(record => { - dnsMessage += `${record} | `; - }); - dnsMessage = dnsMessage.slice(0, -2) + dnsMessage += dnsRes.join(" | "); } else if (this.dns_resolve_type == "SOA") { dnsMessage += `NS-Name: ${dnsRes.nsname} | Hostmaster: ${dnsRes.hostmaster} | Serial: ${dnsRes.serial} | Refresh: ${dnsRes.refresh} | Retry: ${dnsRes.retry} | Expire: ${dnsRes.expire} | MinTTL: ${dnsRes.minttl}`; } else if (this.dns_resolve_type == "SRV") { @@ -212,11 +206,6 @@ class Monitor extends BeanModel { dnsMessage += `Name: ${record.name} | Port: ${record.port} | Priority: ${record.priority} | Weight: ${record.weight} | `; }); dnsMessage = dnsMessage.slice(0, -2) - } else if (this.dns_resolve_type == "TXT") { - dnsRes.forEach(record => { - dnsMessage += `Record: ${record} | `; - }); - dnsMessage = dnsMessage.slice(0, -2) } bean.msg = dnsMessage;