Skip to content

Instantly share code, notes, and snippets.

@darksunlight
Last active June 9, 2022 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darksunlight/5cccfd3565098310238d17c6d168f37a to your computer and use it in GitHub Desktop.
Save darksunlight/5cccfd3565098310238d17c6d168f37a to your computer and use it in GitHub Desktop.
Minecraft LAN World receiver (nodejs)
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');
socket.bind(4445, '0.0.0.0');
socket.on("message", (data, rinfo) => {
const [, desc, port] = data.toString().match(/^\[MOTD\](.*)\[\/MOTD\]\[AD\](\d+)\[\/AD]$/);
console.log(`someone opened a lan world at ${rinfo.address}:${port} (${desc})`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment