Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions build/alpine/install-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apk add --no-cache -U \
rsync \
nano \
sudo \
knock \
tar \
zstd \
nfs-utils
nfs-utils \
libpcap
2 changes: 1 addition & 1 deletion build/ol/install-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ dnf install -y ImageMagick \
unzip \
zstd \
lbzip2 \
knock
libpcap

bash /build/ol/install-gosu.sh
6 changes: 3 additions & 3 deletions build/ubuntu/install-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ apt-get install -y \
unzip \
zstd \
lbzip2 \
knockd \
nfs-common
nfs-common \
libpcap0.8

apt-get clean
apt-get clean
2 changes: 1 addition & 1 deletion files/auto/autopause-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\"."
Expand Down
1 change: 1 addition & 0 deletions files/auto/knockd-config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
[unpauseMCServer-bedrock]
sequence = 19132:udp
command = /auto/resume.sh %IP%
seq_cooldown = 60
2 changes: 1 addition & 1 deletion files/sudoers-mc
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions scripts/start-autopause
Original file line number Diff line number Diff line change
Expand Up @@ -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 &