VeriorPies / MineCloud

An AWS CDK project to set up an almost free on-demand multiplayer server (Minecraft, Terraria, and more...) for a Discord community in just a few minutes
MIT License
292 stars 15 forks source link

Create get_connection_count_udp_template.sh #43

Closed yxliaoyx closed 1 year ago

yxliaoyx commented 1 year ago

This command runs tcpdump, a network traffic analyzer, with a timeout of 300 seconds (-c 1 means to capture only one packet) and filters for UDP traffic on port 25565. The stderr output of tcpdump is redirected to /dev/null.

The if statement checks whether the mcCons variable is empty using the -z operator. If it is empty, it means that there are no current connections to the server, so the function returns 0.

If the mcCons variable is not empty, it means that there is at least one current connection to the server, so the function returns 1.