Use modified knockd to set a cooldown on port 19132 (#2003)

This commit is contained in:
Metalcape 2023-03-12 19:40:35 +01:00 committed by GitHub
parent e43669d792
commit e217ac503e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 8 deletions

View file

@ -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

View file

@ -21,7 +21,7 @@ apk add --no-cache -U \
rsync \
nano \
sudo \
knock \
tar \
zstd \
nfs-utils
nfs-utils \
libpcap

View file

@ -33,6 +33,6 @@ dnf install -y ImageMagick \
unzip \
zstd \
lbzip2 \
knock
libpcap
bash /build/ol/install-gosu.sh

View file

@ -23,7 +23,7 @@ apt-get install -y \
unzip \
zstd \
lbzip2 \
knockd \
nfs-common
nfs-common \
libpcap0.8
apt-get clean

View file

@ -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\"."

View file

@ -13,3 +13,4 @@
[unpauseMCServer-bedrock]
sequence = 19132:udp
command = /auto/resume.sh %IP%
seq_cooldown = 60

View file

@ -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

View file

@ -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 &