Search
When you go to the Minecraft multiplayer menu, you can see some basic info about a server before you join it, like the version, player count, etc. Your Minecraft client is getting this information by pinging the server, requesting it for its Minecraft info, and the server responds with a packet containing all that info. Note that there's no verification in that process that ensures you're actually using the Minecraft client, the server just responds to whatever requests it gets. That means that you're able to send your own request from any program, not just Minecraft, which is how I'm able to get the information from all the servers in my database.
The next logical step would be creating the database in the first place. I can ping a server with the same method I mentioned before in order to check if it's actually hosting a Minecraft server, and simply repeat that process for every possible IP. Minecraft uses IPv4 addresses to host servers, which can range from 1.0.0.0
to 255.255.255.255
. That means there's 255 * 256^3
, or 4,278,190,080
possible Minecraft server IPs. That's obviously a lot of IPs to go through. When you ping a server, you'll need a certain threshold when you decide that a server has been inactive for too long and must not be a Minecraft server. Usually about 3 seconds works well, but that means to go through every IP it would take 407 years! Luckily, pinging every server individually isn't necessary, since there are tools like Masscan that can send thousands of pings at once to make the process much more efficient, allowing you to ping every IP in under a day. Minecraft Java's default port is 25565
, so I run a Masscan on all IPs on port 25565
to get a list of active IPs, and from there I can ping them as a Minecraft server to get a list of all the active Minecraft servers. My bot constantly goes back over that list to ping the servers and get updated information.