itzg / mc-server-runner

A container entry point to manage graceful shutdown of a Minecraft server
Apache License 2.0
33 stars 15 forks source link

Native pause/stop support #19

Open itzg opened 2 years ago

itzg commented 2 years ago

I have some ideas with using https://pkg.go.dev/github.com/google/gopacket/pcapgo , BPF, and adding CAP_BPF capability to the executable at build time.

daniel-lerch commented 1 year ago

This looks really interesting. Could you elaborate a bit more on how you want to implement this feature? Something like craftignite as discussed in itzg/docker-minecraft-server#874?

itzg commented 1 year ago

Basically I'm wanting to bring the minimal bits of knockd into mc-server-runner. Specifically the ability to watch for, but not proxy, incoming TCP packets to port 25565. From what I can tell BPF is the Linux kernel mechanism that seems to be best suited for doing that efficiently.

On the other side of the solution mc-server-runner already knows how to exec the Java process, gracefully stop it, and of course knows whether the server is actively running or not.

itzg commented 1 year ago

Another eBPF library to research: https://github.com/cilium/ebpf