itzg / itzg/docker-minecraft-server
improve autopause port detection
- Dominant language
- Shell
- Stars
- 14.3k
- Forks
- 1.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 31
Description
### Enhancement Type
Improve an existing feature
### Describe the enhancement
Currently, autopause starts with a template `/autopause/knockd-config.cfg` file and then substitutes SERVER_PORT and RCON_PORT in case they've been changed. The config also includes port 19132/udp (the default Bedrock port) just in case someone installs GeyserMC, but if they were to run that on a different port, there's no way for them to make that port change in the knockd config.
Some other plugins also add server ports that ought to prevent or resume from pause, such as the Dynmap plugin with its built-in web server, and there's similarly no easy way to add those ports to the `knockd` config so that connections to the map port (8123 by default) wake up the server.
To handle both of these cases, I wonder if it would be worth just generating the entire `knockd-config.cfg` file dynamically on startup, by having the container ask docker which ports have been mapped into it and adding `knockd` listeners for each one. Anyone who changes a port (such as for GeyserMC), or adds a plugin that needs a new port (such as Dynmap) must necessarily add that port mapping to their `docker-compose.yml`, so it should suffice for `knockd` to just listen on all of those ports (plus RCON).
Ideally (but maybe optionally) it would be great to somehow also detect activity on any such additional ports (such as someone watching Dynmap) to prevent server pause even if no players are connected any more. I'm not sure how best to do that, though, and that maybe should have to be explicitly set (i.e. env `AUTOPAUSE_TCP_PORTS`) rather than being automatic for every port mapped to the container.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with /autopause/knockd-config.cfg and the startup logic that substitutes SERVER_PORT and RCON_PORT. Inspect how ports are mapped in docker-compose.yml and how AUTOPAUSE_TCP_PORTS could fit the proposed behavior. Done means mapped plugin ports can be handled by knockd, with any optional activity detection explicitly defined and tested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, shell
- Domain
- devops, infrastructure, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100