-
-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,001 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
services: | ||
palworld: | ||
image: thijsvanloef/palworld-server-docker:latest | ||
restart: unless-stopped | ||
container_name: palworld-server | ||
stop_grace_period: 30s | ||
ports: | ||
- 8211:8211/udp | ||
environment: | ||
SERVER_NAME: "palworld-server-docker by Thijs van Loef" | ||
SERVER_DESCRIPTION: "palworld-server-docker by Thijs van Loef" | ||
SERVER_PASSWORD: "worldofpals" | ||
ADMIN_PASSWORD: "adminPasswordHere" | ||
AUTO_PAUSE_ENABLED: true | ||
AUTO_PAUSE_TIMEOUT_EST: 180 # Time to pause when absent. (sec) | ||
volumes: | ||
- ./palworld:/palworld/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
This script intercepts the communication content with "api.palworldgame.com". | ||
""" | ||
import os | ||
import stat | ||
import logging | ||
|
||
from mitmproxy import http | ||
from mitmproxy.http import Headers | ||
|
||
BASEDIR = "/home/steam/autopause" | ||
REGISTER_JSON_PATH = BASEDIR + "/register.json" | ||
UPDATE_JSON_PATH = BASEDIR + "/update.json" | ||
|
||
class PalIntercept: | ||
def __init__(self): | ||
st = os.stat(BASEDIR) | ||
self.uid = st.st_uid | ||
self.gid = st.st_gid | ||
|
||
def response(self, flow: http.HTTPFlow): | ||
if flow.request.host == "api.palworldgame.com" and flow.request.is_http11 and flow.response.status_code == 200: | ||
if flow.request.path == "/server/register": | ||
with open(REGISTER_JSON_PATH, "wb") as f: | ||
f.write(flow.request.content) | ||
os.chown(REGISTER_JSON_PATH, self.uid, self.gid) | ||
if flow.request.path == "/server/update": | ||
with open(UPDATE_JSON_PATH, "wb") as f: | ||
f.write(flow.request.content) | ||
os.chown(UPDATE_JSON_PATH, self.uid, self.gid) | ||
|
||
|
||
addons = [PalIntercept()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
SCRIPT_DIR=${SCRIPT_DIR:-$(dirname "$(readlink -fn "${0}")")} | ||
#shellcheck source=scripts/helper_functions.sh | ||
source "${SCRIPT_DIR}/helper_functions.sh" | ||
#shellcheck source=scripts/helper_autopause.sh | ||
source "${SCRIPT_DIR}/helper_autopause.sh" | ||
|
||
if ! AutoPauseEx_isEnabled; then | ||
echo "An autopause service has not started yet." | ||
return 1; | ||
fi | ||
|
||
case "${1}" in | ||
"resume") | ||
AutoPauseEx_resume "${2}" | ||
;; | ||
"stop"|"skip") | ||
AutoPauseEx_stopService on "${2}" | ||
;; | ||
"continue") | ||
AutoPauseEx_stopService off "${2}" | ||
;; | ||
*) | ||
echo "Usage: $(basename "${0}") <command> [reason]" | ||
echo "command:" | ||
echo " resume ... resume from paused state" | ||
echo " stop ... stop service" | ||
echo " continue ... continue service" | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# Control the port knock daemon. | ||
# Called only on the server side. | ||
|
||
basedir="/home/steam/autopause" | ||
config="${basedir}/knockd.cfg" | ||
|
||
case "${1}" in | ||
"start") | ||
if [ ! -f "${config}" ]; then | ||
cat - << EOF > "${config}" | ||
[options] | ||
logfile = ${basedir}/knockd.log | ||
interface = ${AUTO_PAUSE_KNOCK_INTERFACE:-eth0} | ||
[resume-by-player] | ||
sequence = ${PORT:-8211}:udp | ||
seq_cooldown = 5 | ||
command = autopause resume "LOGIN from %IP%" | ||
[resume-by-rcon] | ||
sequence = ${RCON_PORT:-25575} | ||
seq_timeout = 1 | ||
command = autopause resume "RCON from %IP%" | ||
tcpflags = syn | ||
[resume-by-rest] | ||
sequence = ${REST_API_PORT:-8212} | ||
seq_timeout = 1 | ||
command = autopause resume "REST_API from %IP%" | ||
tcpflags = syn | ||
EOF | ||
fi | ||
pid=$(pidof knockd) | ||
if [ -n "${pid}" ]; then | ||
echo "Already started knockd ${pid}" | ||
return | ||
fi | ||
knockd -d -c "${config}" -p "${basedir}/knockd.pid" | ||
;; | ||
"stop") | ||
pid=$(pidof knockd) | ||
if [ -z "${pid}" ]; then | ||
echo "Already stopped knockd ${pid}" | ||
return | ||
fi | ||
kill -KILL "${pid}" | ||
;; | ||
*) | ||
echo "Usage: $(basename "${0}") <command>" | ||
echo "command:" | ||
echo " start ... launch knockd" | ||
echo " stop ... kill knockd" | ||
esac |
Oops, something went wrong.