4 Commits

Author SHA1 Message Date
838ffc497a chore: bump version to 1.5.0 2024-10-09 22:00:11 +03:00
502029869a style: use "node:" prefix for imports 2024-10-09 21:59:16 +03:00
e3e7e293ed fix: use vanilla ping format 2024-10-09 21:57:37 +03:00
88ad92e59d chore: add example for single server ping 2024-10-09 21:55:01 +03:00
4 changed files with 10 additions and 4 deletions

5
example/single.js Normal file
View File

@ -0,0 +1,5 @@
import { pingBedrock } from "../index.js";
const host = "mc.nevertime.su";
const ping = await pingBedrock(host);
console.log(ping);

View File

@ -5,7 +5,8 @@
'use strict';
import dgram from 'dgram';
import dgram from 'node:dgram';
import crypto from 'node:crypto'
const MAGIC = "00ffff00fefefefefdfdfdfd12345678";
const START_TIME = new Date().getTime();
@ -21,7 +22,7 @@ const createUnconnectedPingFrame = (timestamp) => {
buffer.writeUInt8(0x01, 0); // Packet ID
buffer.writeBigInt64LE(BigInt(timestamp), 1); // Timestamp
Buffer.from(MAGIC, "hex").copy(buffer, 9); // OFFLINE_MESSAGE_DATA_ID (Magic)
buffer.writeBigInt64LE(BigInt(0), 25); // Client GUID
Buffer.from(crypto.randomBytes(8)).copy(buffer, 25); // Client GUID
return buffer;
};

View File

@ -5,7 +5,7 @@
'use strict';
import net from 'net';
import net from 'node:net';
import varint from './varint.js';
/**

View File

@ -1,6 +1,6 @@
{
"name": "@minescope/mineping",
"version": "1.4.1",
"version": "1.5.0",
"description": "Ping both Minecraft Bedrock and Java servers.",
"main": "index.js",
"types": "types/index.d.ts",