misc.mcserver: more debug
This commit is contained in:
parent
1cbdda7c2d
commit
e8dbdb94a1
1 changed files with 9 additions and 5 deletions
|
@ -759,7 +759,11 @@ mcserver.callback = async function (msg, line) {
|
||||||
const port = split[1] ?? 25565;
|
const port = split[1] ?? 25565;
|
||||||
|
|
||||||
const data = await new Promise((resolve, reject) => {
|
const data = await new Promise((resolve, reject) => {
|
||||||
const timeout = setTimeout(() => resolve("timeout"), 10000);
|
logger.verbose("mcserver", "querying", ip, port);
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
logger.verbose("mcserver", "timeout");
|
||||||
|
resolve("timeout");
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
const client = net.createConnection({
|
const client = net.createConnection({
|
||||||
host: ip,
|
host: ip,
|
||||||
|
@ -767,18 +771,18 @@ mcserver.callback = async function (msg, line) {
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
});
|
});
|
||||||
client.on("connect", function () {
|
client.on("connect", function () {
|
||||||
logger.debug("mcserver", "connect");
|
logger.verbose("mcserver", "connect");
|
||||||
client.write(HANDSHAKE_PACKET);
|
client.write(HANDSHAKE_PACKET);
|
||||||
});
|
});
|
||||||
let totalData = Buffer.alloc(0);
|
let totalData = Buffer.alloc(0);
|
||||||
client.on("data", function (data) {
|
client.on("data", function (data) {
|
||||||
totalData = Buffer.concat([totalData, data]);
|
totalData = Buffer.concat([totalData, data]);
|
||||||
logger.debug("mcserver", "data", data.length, totalData.length);
|
logger.verbose("mcserver", "data", data.length, totalData.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("close", function (err) {
|
client.on("close", function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.debug("mcserver", "close with error", err);
|
logger.verbose("mcserver", "close with error", err);
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
const dataAsString = totalData.toString().trim();
|
const dataAsString = totalData.toString().trim();
|
||||||
|
@ -789,7 +793,7 @@ mcserver.callback = async function (msg, line) {
|
||||||
dataAsString.lastIndexOf("}") + 1
|
dataAsString.lastIndexOf("}") + 1
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
logger.debug("mcserver", "close", json);
|
logger.verbose("mcserver", "close", json);
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
return resolve(json);
|
return resolve(json);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue