dockermcmgr
project
This is a Minecraft server manager that lets you create, edit and delete Minecraft servers.
With this server manager, you can have your Minecraft servers technically open indefinitely.
how it works
open indefinitely ?
the actual servers don't stay open, they are stopped after a week without anyone logging in.
If a server is stopped anyone can join to start it up, no need to ask the admin to reopen it
archived
If a server is no one joins the server for a month (or the administrator decides to do it manually) the server can be archived.
all the server files are compressed using lrzip and the server goes into the Archived state. Even if it's archived, the server can still be accessed by anyone, though it will take longer to start
how does it work
The daemon is the only one listening on the 25565 port and acts as a proxy.
when the client connects to the daemon, it will try to read the handshake packet and extract the server name from the hostname. if the server name is known and the server is up, it will open a connection to the server and send the handshake packet and any following data directly to the requested server.
If, however, the server is offline the actions will depend on the intent given in the handshake.
On a status intent, the server will wait for a 0x00 (status) and a 0x01 (ping) packet. the status response will show the current known state of the server and the last login date
On a login intent, the server will check the current state of the server and if the server is in a state that allows it to start, it will do so and send a disconnect packet informing with a message informing the user wether or not their start request was successful (an error message is shown if it wasn't)
usage
server states
the Minecraft servers don't actually stay open indefinitely, they can be in different states :
- Running
- Stopping
- Stopped
- Archiving
- Archived
- Disabled
A server in the following states can be started at any moment : Stopped, Archived
A disabled server cannot be started or accessed until it is reenabled by the administrator
join a server
Servers are accessed using their name, followed by .mc.tmoron.fr, for example if someone wants to join a server named awesome-server they have to join awesome-server.mc.tmoron.fr and they will routed to this specific server
start a server
There are two ways to start a server:
- the admin can start any server using the
dmmcli (dmm start <name>). - anyone that have the name of the server can start it by simply trying to join the stopped or archived server, they will be disconnected and it will show a message saying that the start request has been sent
cli
to manage the servers a cli is available
dependencies
lrzip
library used
for this project I used the following libraries :
- bollard: to interract with docker
- diesel: interract with a sqlite database
- clap: to parse the command line arguments
- tokio: async and others for things like time, json and regex