The states#
The script gives each server in your port range one of these states.
| State | When |
|---|---|
running |
The server is on. Players reach it directly. |
starting |
The panel reports the server as starting. |
offline |
The server is stopped or stopping. |
suspended |
The server is suspended in the panel. This wins over the others. |
installing |
The server is installing. On Calagopus this is also used while a server is transferring or has any other status, such as restoring a backup. |
Only servers with a port inside portRange are handled. The state is re-read every Check interval (10 seconds by default). A server that was running is checked again after twice that time.
Redirecting players#
The script listens on four ports, one per state. The first is motd.port, which is 4001 by default:
| Port | State |
|---|---|
motd.port (4001) |
offline |
motd.port + 1 (4002) |
suspended |
motd.port + 2 (4003) |
installing |
motd.port + 3 (4004) |
starting |
When a server is not running, the script adds an iptables rule that sends traffic for the port of that server to the matching MOTD port:
iptables -t nat -A PREROUTING -p tcp --dport 25565 -j REDIRECT --to-port 4001
When the server runs, it removes the rule again. When the state changes, for example from starting to running, the old rule is replaced. When a server is deleted or its port leaves the range, its rule is removed. When you stop the script with SIGINT or SIGTERM, it removes all its rules, so players reach the servers directly. Rules left behind by a crash are removed the next time it starts.
When the panel cannot be reached or a key is refused, the script keeps the last known state of each server. A running server is never sent to the offline MOTD because of an API error.
The script answers the Minecraft Java Edition server list ping and a join attempt. A join gets the kick message and the connection ends. It only handles TCP.
By default the script only handles the servers of the node it runs on. Run a copy on every node, or set node to all when it runs on a proxy that handles the ports of every node. See Which node.
Write your messages#
Each state under motd.states has these keys.
| Key | What it is |
|---|---|
version |
The text in the version column of the server list, for example Offline |
protocol |
The protocol number sent to the client. Default 762. |
onlinePlayers |
The number of players shown. Default 0. |
maxPlayers |
The player limit shown. Default 100. |
description |
The MOTD, two lines. |
kickMessage |
The text players see when they try to join. |
Write description and kickMessage as a block with | and use § colour codes. A new line in the block is a new line in Minecraft. Spaces and new lines at the start and end are removed.
description: |
§c§lServer Offline §7| §fYourHost.com
§7This server is currently offline. Come back later!
All four states must be in the file. The script stops at start with Missing MOTD state: <state> when one is missing.
The server icon#
motd.server-icon is the path of a PNG that is shown in the server list, ./server-icon.png by default. Use a 64 by 64 PNG of at most 10 KB. A relative path is relative to the folder of index.js. The icon is read once at start. When the file is not found, the log shows Server icon not loaded from ... and the MOTD is shown without an icon. The icon is the same for all four states.
Exclude eggs#
Servers of an excluded egg never get a MOTD, for example proxies that share your port range. See Settings for Pterodactyl v1 and Settings for Calagopus.