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
@@ -45,7 +45,6 @@ CServerSocket::~CServerSocket( )
|
||||
bool CServerSocket::StartServer( )
|
||||
{
|
||||
//struct sockaddr_in ain;
|
||||
int test;
|
||||
sock = socket( AF_INET, SOCK_STREAM, 0 );
|
||||
if (sock == INVALID_SOCKET)
|
||||
{
|
||||
@@ -59,16 +58,16 @@ bool CServerSocket::StartServer( )
|
||||
Log(MSG_ERROR, "setsockopt:SO_KEEPALIVE" );
|
||||
}
|
||||
setsockopt(sock, IPPROTO_TCP,TCP_NODELAY,(const char*)&optval,sizeof(optval));
|
||||
// Lets a restarted server (docker restart, crash-loop) rebind immediately
|
||||
// instead of failing on a TIME_WAIT socket from its own previous run.
|
||||
setsockopt(sock, SOL_SOCKET,SO_REUSEADDR,(const char*)&optval,sizeof(optval));
|
||||
ain.sin_family = AF_INET;
|
||||
ain.sin_addr.s_addr = INADDR_ANY;
|
||||
ain.sin_port = htons( port );
|
||||
memset(&(ain.sin_zero), '\0', 8);
|
||||
if ( bind( sock, (const sockaddr*)&ain, sizeof( struct sockaddr ) ) )
|
||||
{
|
||||
|
||||
Log( MSG_FATALERROR, "Could not bind socket" );
|
||||
std::cout <<"socket " << sock << std::endl;
|
||||
std::cin >> test;
|
||||
closesocket( sock );
|
||||
sock = INVALID_SOCKET;
|
||||
return false;
|
||||
@@ -94,6 +93,7 @@ bool CServerSocket::StartServer( )
|
||||
Log(MSG_ERROR, "setsockopt:SO_KEEPALIVE" );
|
||||
}
|
||||
setsockopt(sckISC, IPPROTO_TCP,TCP_NODELAY,(const char*)&optval,sizeof(optval));
|
||||
setsockopt(sckISC, SOL_SOCKET,SO_REUSEADDR,(const char*)&optval,sizeof(optval));
|
||||
sain.sin_family = AF_INET;
|
||||
sain.sin_addr.s_addr = INADDR_ANY;
|
||||
sain.sin_port = htons( Config.CharsPort);//29110 );
|
||||
@@ -125,7 +125,7 @@ bool CServerSocket::StartServer( )
|
||||
return false;
|
||||
}
|
||||
aina.sin_family = AF_INET;
|
||||
aina.sin_addr.s_addr = inet_addr(Config.CharIP);//( "127.0.0.1" );
|
||||
aina.sin_addr.s_addr = rose_inet_addr(Config.CharIP);//( "127.0.0.1" );
|
||||
aina.sin_port = htons( Config.CharPort);//29110 );
|
||||
if ( connect( sckISC, (const sockaddr*)&aina, sizeof( aina ) ) == SOCKET_ERROR ) {
|
||||
Log( MSG_ERROR, "Could not connect to ISC (WSK2 ERROR: %i)", WSAGetLastError( ) );
|
||||
@@ -146,6 +146,7 @@ bool CServerSocket::StartServer( )
|
||||
Log(MSG_ERROR, "setsockopt:SO_KEEPALIVE" );
|
||||
}
|
||||
setsockopt(sckISCII, IPPROTO_TCP,TCP_NODELAY,(const char*)&optval,sizeof(optval));
|
||||
setsockopt(sckISCII, SOL_SOCKET,SO_REUSEADDR,(const char*)&optval,sizeof(optval));
|
||||
sain.sin_family = AF_INET;
|
||||
sain.sin_addr.s_addr = INADDR_ANY;
|
||||
sain.sin_port = htons( Config.WorldsPort );//29210 );
|
||||
|
||||
Reference in new issue
Block a user