Port server to Linux and add Docker Compose deployment
Rebuilds (not Wine) the login/char/world servers natively for Linux via CMake, and ships a single Docker image plus docker-compose stack (MariaDB + 3 servers) with all settings configurable via .env. Linux portability: - Src/Common/compat.h shims MSVC-only CRT calls (fopen_s, _strdup, strncpy_s, sprintf_s, SYSTEMTIME/GetLocalTime, WSAGetLastError, __cdecl) and adds a case-insensitive/backslash-tolerant path resolver for the Windows-authored STB/AIP data file paths. - Fixed case-sensitive header includes and filenames (charserver.h vs CharServer.h, worldserver.h vs WorldServer.h, ../common vs ../Common). - rose_inet_addr() resolves hostnames (not just literal IPs) for the server-to-server links, so docker-compose service names work. Fixed three real bugs that only crashed on 64-bit Linux (silently tolerated on 32-bit Windows): - CIntStb::LoadSTB had an inverted fopen success/failure check, so STB game data (zones, items, etc.) was never actually loaded. - GenerateCryptTables allocated its pointer table with sizeof(unsigned) instead of sizeof(unsigned*) -- a 1x vs 2x-size heap overflow on 64-bit. - Crypto bit-twiddling relies throughout on signed-overflow-as-wraparound, which is UB in C++; GCC's -O3 exploited it and miscompiled GenerateCryptTables (Release-only crash). Fixed via -fwrapv. Plus smaller fixes: off-by-one array bounds (inventory/storage/sell data), SO_REUSEADDR on server sockets (containers restarting in the same netns hit TIME_WAIT otherwise), and a va_list reused across multiple vprintf/vfprintf calls in Log() that garbled every formatted log line on the Linux ABI. Docker: - CMakeLists.txt builds all three servers + shared Common code. - Dockerfile: multi-stage build, one runtime image for all three servers, server role selected via `command: [login|char|world]`. - docker-compose.yml: MariaDB (auto-imports database sql files/ on first run) + login/char/world (single channel), config rendered from docker/conf/*.conf.tmpl via envsubst at container start. - .env.example documents every setting (ports, server names, rates, inter-server passwords, PUBLIC_HOST for internet-facing deployments). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a320bbe470
commit
764fcb3b3f
37 files changed
+811
-72
No files matched your search
@@ -0,0 +1,25 @@
|
||||
[DATABASE]
|
||||
mysql_host=${DB_HOST}
|
||||
mysql_user=${DB_USER}
|
||||
mysql_pass=${DB_PASSWORD}
|
||||
mysql_database=${DB_NAME}
|
||||
mysql_port=${DB_PORT}
|
||||
|
||||
[SERVERDATA]
|
||||
serverid=1
|
||||
serverip=${PUBLIC_HOST}
|
||||
serverport=${CHAR_PORT}
|
||||
servername=${CHAR_SERVER_NAME}
|
||||
parentid=0
|
||||
accesslevel=100
|
||||
|
||||
[CHARSERVER]
|
||||
deletetime=${CHAR_DELETE_TIME}
|
||||
usethreads=0
|
||||
[server2server]
|
||||
CharsPort=${CHAR_S2S_PORT}
|
||||
|
||||
[PASSWORDS]
|
||||
loginpass=${SHARED_LOGIN_PASS}
|
||||
charpass=${SHARED_CHAR_PASS}
|
||||
worldpass=${SHARED_WORLD_PASS}
|
||||
@@ -0,0 +1,23 @@
|
||||
[DATABASE]
|
||||
mysql_host=${DB_HOST}
|
||||
mysql_user=${DB_USER}
|
||||
mysql_pass=${DB_PASSWORD}
|
||||
mysql_database=${DB_NAME}
|
||||
mysql_port=${DB_PORT}
|
||||
|
||||
[SERVERDATA]
|
||||
serverid=0
|
||||
serverip=${PUBLIC_HOST}
|
||||
serverport=${LOGIN_PORT}
|
||||
servername=${LOGIN_SERVER_NAME}
|
||||
|
||||
[LOGINSERVER]
|
||||
accesslevel=100
|
||||
CreateLoginAccount=${LOGIN_CREATE_ACCOUNT}
|
||||
usethreads=0
|
||||
Testserver=0
|
||||
|
||||
[PASSWORDS]
|
||||
loginpass=${SHARED_LOGIN_PASS}
|
||||
charpass=${SHARED_CHAR_PASS}
|
||||
worldpass=${SHARED_WORLD_PASS}
|
||||
@@ -0,0 +1,43 @@
|
||||
[DATABASE]
|
||||
mysql_host=${DB_HOST}
|
||||
mysql_user=${DB_USER}
|
||||
mysql_pass=${DB_PASSWORD}
|
||||
mysql_database=${DB_NAME}
|
||||
mysql_port=${DB_PORT}
|
||||
|
||||
[SERVERDATA]
|
||||
serverid=2
|
||||
serverip=${PUBLIC_HOST}
|
||||
serverport=${WORLD_PORT}
|
||||
servername=${WORLD_CHANNEL_NAME}
|
||||
maxconnections=${WORLD_MAX_CONNECTIONS}
|
||||
parentid=1
|
||||
|
||||
[WORLDSERVER]
|
||||
accesslevel=100
|
||||
drop_type=2
|
||||
welcome_msg=${WORLD_WELCOME_MSG}
|
||||
autosave=1
|
||||
savetime=${WORLD_SAVE_TIME}
|
||||
mapdelay=10
|
||||
visualdelay=200
|
||||
worlddelay=700
|
||||
partygap=10
|
||||
maxstat=300
|
||||
fairy=1
|
||||
fairystay=45
|
||||
fairywait=30
|
||||
fairytestmode=0
|
||||
playerdmg=100
|
||||
monsterdmg=100
|
||||
cfmode=2
|
||||
|
||||
[server2server]
|
||||
charip=${CHAR_HOST}
|
||||
charport=${CHAR_S2S_PORT}
|
||||
WorldsPort=${WORLD_S2S_PORT}
|
||||
|
||||
[PASSWORDS]
|
||||
loginpass=${SHARED_LOGIN_PASS}
|
||||
charpass=${SHARED_CHAR_PASS}
|
||||
worldpass=${SHARED_WORLD_PASS}
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
: "${DB_HOST:=db}"
|
||||
: "${DB_PORT:=3306}"
|
||||
: "${DB_USER:=rose}"
|
||||
: "${DB_PASSWORD:=change_me}"
|
||||
: "${DB_NAME:=ktrose}"
|
||||
|
||||
: "${PUBLIC_HOST:=127.0.0.1}"
|
||||
: "${CHAR_HOST:=charserver}"
|
||||
|
||||
: "${LOGIN_PORT:=29000}"
|
||||
: "${LOGIN_SERVER_NAME:=ROSE Login}"
|
||||
: "${LOGIN_CREATE_ACCOUNT:=1}"
|
||||
|
||||
: "${CHAR_PORT:=29100}"
|
||||
: "${CHAR_S2S_PORT:=29110}"
|
||||
: "${CHAR_SERVER_NAME:=Server 1}"
|
||||
: "${CHAR_DELETE_TIME:=3600}"
|
||||
|
||||
: "${WORLD_PORT:=29200}"
|
||||
: "${WORLD_S2S_PORT:=29210}"
|
||||
: "${WORLD_CHANNEL_NAME:=Channel 1}"
|
||||
: "${WORLD_MAX_CONNECTIONS:=500}"
|
||||
: "${WORLD_WELCOME_MSG:=Welcome to ROSE}"
|
||||
: "${WORLD_SAVE_TIME:=3600}"
|
||||
|
||||
: "${SHARED_LOGIN_PASS:=789456}"
|
||||
: "${SHARED_CHAR_PASS:=456123}"
|
||||
: "${SHARED_WORLD_PASS:=321654}"
|
||||
|
||||
export DB_HOST DB_PORT DB_USER DB_PASSWORD DB_NAME PUBLIC_HOST CHAR_HOST \
|
||||
LOGIN_PORT LOGIN_SERVER_NAME LOGIN_CREATE_ACCOUNT \
|
||||
CHAR_PORT CHAR_S2S_PORT CHAR_SERVER_NAME CHAR_DELETE_TIME \
|
||||
WORLD_PORT WORLD_S2S_PORT WORLD_CHANNEL_NAME WORLD_MAX_CONNECTIONS \
|
||||
WORLD_WELCOME_MSG WORLD_SAVE_TIME \
|
||||
SHARED_LOGIN_PASS SHARED_CHAR_PASS SHARED_WORLD_PASS
|
||||
|
||||
mkdir -p /data/conf /data/clanmark /var/log/roseserver
|
||||
|
||||
for tmpl in /app/conf-templates/*.conf.tmpl; do
|
||||
name=$(basename "$tmpl" .tmpl)
|
||||
envsubst < "$tmpl" > "/data/conf/$name"
|
||||
done
|
||||
|
||||
# Seed the clan-mark counter file once; charserver opens it "r+b" and fails
|
||||
# if it doesn't already exist.
|
||||
if [ ! -f /data/clanmark/clanmark.cnt ]; then
|
||||
cp -r /app/seed/clanmark/. /data/clanmark/
|
||||
fi
|
||||
|
||||
cd /data
|
||||
|
||||
case "$1" in
|
||||
login)
|
||||
exec /app/bin/loginserver /data/conf/loginserver.conf
|
||||
;;
|
||||
char)
|
||||
exec /app/bin/charserver /data/conf/charserver.conf
|
||||
;;
|
||||
world)
|
||||
exec /app/bin/worldserver /data/conf/worldserver.conf
|
||||
;;
|
||||
*)
|
||||
echo "Usage: entrypoint.sh {login|char|world}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in new issue
Block a user