From c6083ea0624058951079e568c6e3af48a6f11bb1 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Fri, 2 Aug 2024 12:34:14 -0600 Subject: [PATCH] misc.mcserver: more srv resolving logic --- src/modules/misc/mcserver.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/misc/mcserver.js b/src/modules/misc/mcserver.js index 2ad0cbd..741e0d7 100644 --- a/src/modules/misc/mcserver.js +++ b/src/modules/misc/mcserver.js @@ -2,7 +2,7 @@ const Command = require("../../lib/command.js"); const logger = require("../../lib/logger.js"); const net = require("node:net"); -const {resolveSrv} = require("node:dns/promises"); +const {resolveCname, resolveSrv} = require("node:dns/promises"); function readVarInt(data) { var result = 0; @@ -193,10 +193,13 @@ mcserver.callback = async function (msg, line) { const port = split[1] ?? 25565; try { - const addrs = await resolveSrv(ip); + const addrs = await resolveSrv("_tcp." + ip); if (addrs.length > 0) { const mcAddr = addrs.find((a) => a.port == port); if (mcAddr?.name) ip = mcAddr.name; + } else { + const addrs = await resolveCname("_tcp." + ip); + if (addrs.length > 0) ip = addrs[0]; } } catch { // noop