diff --git a/Dockerfile b/Dockerfile index 275cf219..fae23a04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,6 +52,11 @@ RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ | tar -C /usr/share -zxf - \ && ln -s /usr/share/mc-image-helper-${MC_HELPER_VERSION}/bin/mc-image-helper /usr/bin +# Install modified knockd +ADD https://github.com/Metalcape/knock/releases/download/0.8.1/knock-0.8.1-${TARGETARCH}${TARGETVARIANT}.tar.gz /tmp/knock.tar.gz +RUN tar -xf /tmp/knock.tar.gz -C /usr/local/ && rm /tmp/knock.tar.gz +RUN find /usr/lib -name 'libpcap.so.0.8' -execdir cp '{}' libpcap.so.1 \; + VOLUME ["/data"] WORKDIR /data diff --git a/build/alpine/install-packages.sh b/build/alpine/install-packages.sh index fc2ffb8d..4c116915 100755 --- a/build/alpine/install-packages.sh +++ b/build/alpine/install-packages.sh @@ -21,7 +21,7 @@ apk add --no-cache -U \ rsync \ nano \ sudo \ - knock \ tar \ zstd \ - nfs-utils \ No newline at end of file + nfs-utils \ + libpcap diff --git a/build/ol/install-packages.sh b/build/ol/install-packages.sh index e8eeadf8..eab5e562 100755 --- a/build/ol/install-packages.sh +++ b/build/ol/install-packages.sh @@ -33,6 +33,6 @@ dnf install -y ImageMagick \ unzip \ zstd \ lbzip2 \ - knock + libpcap bash /build/ol/install-gosu.sh diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index f5ed4d01..d7b88225 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -23,7 +23,7 @@ apt-get install -y \ unzip \ zstd \ lbzip2 \ - knockd \ - nfs-common + nfs-common \ + libpcap0.8 -apt-get clean \ No newline at end of file +apt-get clean diff --git a/files/auto/autopause-daemon.sh b/files/auto/autopause-daemon.sh index 1cbfcdbe..be884038 100644 --- a/files/auto/autopause-daemon.sh +++ b/files/auto/autopause-daemon.sh @@ -45,7 +45,7 @@ if isTrue "${DEBUG_AUTOPAUSE}"; then knockdArgs+=(-D) fi -sudo /usr/sbin/knockd "${knockdArgs[@]}" +sudo /usr/local/sbin/knockd "${knockdArgs[@]}" if [ $? -ne 0 ] ; then logAutopause "Failed to start knockd daemon." logAutopause "Probable cause: Unable to attach to interface \"$AUTOPAUSE_KNOCK_INTERFACE\"." diff --git a/files/auto/knockd-config.cfg b/files/auto/knockd-config.cfg index 0334ad05..1c54cc48 100644 --- a/files/auto/knockd-config.cfg +++ b/files/auto/knockd-config.cfg @@ -13,3 +13,4 @@ [unpauseMCServer-bedrock] sequence = 19132:udp command = /auto/resume.sh %IP% + seq_cooldown = 60 diff --git a/files/sudoers-mc b/files/sudoers-mc index 2869c23e..bc0c19cd 100644 --- a/files/sudoers-mc +++ b/files/sudoers-mc @@ -1,2 +1,2 @@ minecraft ALL=(ALL) NOPASSWD:/usr/bin/pkill -minecraft ALL=(ALL) NOPASSWD:/usr/sbin/knockd +minecraft ALL=(ALL) NOPASSWD:/usr/local/sbin/knockd diff --git a/scripts/start-autopause b/scripts/start-autopause index 66fbbe60..59d5c76b 100755 --- a/scripts/start-autopause +++ b/scripts/start-autopause @@ -84,4 +84,9 @@ elif [[ -z "$MAX_TICK_TIME" ]] ; then export MAX_TICK_TIME fi +# seq_cooldown cannot be larger than AUTOPAUSE_TIMEOUT_KN, otherwise the server may +# become paused while knockd is still ignoring packets, preventing players from joining. +let COOLDOWN=$AUTOPAUSE_TIMEOUT_KN/2 +sed -i "s/\(seq_cooldown *= *\).*/\1$COOLDOWN/" /tmp/knockd-config.cfg + /auto/autopause-daemon.sh &