itzg / docker-minecraft-server

Docker image that provides a Minecraft Server that will automatically download selected version at startup
https://docker-minecraft-server.readthedocs.io/
Apache License 2.0
9.48k stars 1.55k forks source link

Allow multiple knock interfaces #2084

Open florensie opened 1 year ago

florensie commented 1 year ago

Enhancement Type

Improve an existing feature

Describe the enhancement

I'm running my minecraft container in a gluetun network with a port-forward configured on my VPN. The gluetun network provides two network interfaces: eth0 and tun0. Both can be used depending on if I want to connect locally or externally through the VPN, so both need to respond to knocks.

It would be nice if AUTOPAUSE_KNOCK_INTERFACE supported a comma separated list of interfaces. This currently results in the following error being logged:

Selected interface "eth0, tun0" does not exist!

A docker compose configuration with gluetun looks something like this:

version: '3.5'

services:
  gluetun:
    image: qmcgaw/gluetun
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    environment:
      - VPN_SERVICE_PROVIDER=mullvad
      - VPN_TYPE=wireguard
      - WIREGUARD_PRIVATE_KEY=[VPN Provided Private Key]
      - WIREGUARD_ADDRESSES=10.68.0.124/32
      - SERVER_CITIES=Brussels
      - FIREWALL_VPN_INPUT_PORTS=[VPN Provided Port]
    ports:
      - 25565:12345
  minecraft:
    image: itzg/minecraft-server
    restart: unless-stopped
    environment:
      EULA=TRUE
      SERVER_PORT=[VPN Provided Port]
      AUTOPAUSE_KNOCK_INTERFACE=eth0,tun0  # Proposed syntax
    tty: true
    stdin_open: true
    network_mode: "service:gluetun"
florensie commented 1 year ago

It seems like knockd doesn't support listening on multiple interfaces. I've tested spinning up a second daemon in an already running container and that seems to work:

/usr/local/sbin/knockd -c /tmp/knockd-config.cfg -d -i tun0