From a3c88dc0c58b086e93b2da0cff3bb69d1c25f0cc Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Thu, 7 May 2020 23:46:59 -0500 Subject: [PATCH] add ability to skip unfurlSrv calls to avoid ping cost --- config.json | 3 +++ lib/ping.js | 5 +++++ main.js | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/config.json b/config.json index 3fd9359..6a4f90a 100644 --- a/config.json +++ b/config.json @@ -9,6 +9,9 @@ "pingAll": 3000, "connectTimeout": 2500 }, + "performance": { + "skipUnfurlSrv": false + }, "logToDatabase": false, "graphDuration": 86400000 } diff --git a/lib/ping.js b/lib/ping.js index 65ea8af..2f8216b 100644 --- a/lib/ping.js +++ b/lib/ping.js @@ -54,6 +54,11 @@ function ping (host, port, type, timeout, callback, version) { } function unfurlSrv (hostname, port, callback) { + if (config.performance && config.performance.skipUnfurlSrv) { + callback(hostname, port) + return + } + dns.resolveSrv('_minecraft._tcp.' + hostname, (_, records) => { if (!records || records.length < 1) { callback(hostname, port) diff --git a/main.js b/main.js index 44d05d4..e972b92 100644 --- a/main.js +++ b/main.js @@ -25,6 +25,10 @@ servers.forEach((server, serverId) => { app.serverRegistrations.push(new ServerRegistration(serverId, server)) }) +if (config.performance && config.performance.skipUnfurlSrv) { + logger.log('warn', '"performance.skipUnfurlSrv" is enabled. Any configured hosts using SRV records may not properly resolve.') +} + if (!config.logToDatabase) { logger.log('warn', 'Database logging is not enabled. You can enable it by setting "logToDatabase" to true in config.json. This requires sqlite3 to be installed.')