Last active
June 9, 2022 05:25
-
-
Save darksunlight/5cccfd3565098310238d17c6d168f37a to your computer and use it in GitHub Desktop.
Minecraft LAN World receiver (nodejs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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