Secrets-of-Sosaria / World

Code repository for the Secrets of Sosaria world
GNU General Public License v2.0
11 stars 10 forks source link

feature: containerisation support #90

Open devOwlish opened 1 month ago

devOwlish commented 1 month ago

The issue

When the server is started in a container or behind NAT, a client can't get past authorization screen. This happens because the game server IP is always a private one, which isn't accessible from outside.

To demonstrate the issue, let's take Orion Client logs ( some lines have been omitted ):

20:22:14:213: CSocket::Connecting to 127.0.0.1:2593 <-- Connect to the "login server"
20:22:14:213: CBaseSocket::Connecting to 127.0.0.1:2593
20:22:29:357: --- ^(15071) r(+46 => 203) Server:: Servers List
20:22:30:558: CBaseSocket::OnCloseConnection
20:22:30:559: CSocket::Connecting to 172.22.0.2:2593 <-- Advertised "game server" IP, which is a virtual one 
20:22:30:559: CBaseSocket::Connecting to 172.22.0.2:2593
20:22:40:618: ERROR!!! Socket connectToHost return error: (2) 'Unknown error'

The solution

To solve the issue, we should be able to enforce S_Address being selected instead of any existing IP discovery, i.e.:

public static string S_Address = "127.0.0.1";
public static bool S_EnforceAddress = true;

which allows the server to be run in Docker locally. In case of running in a VPS/VDS or in a Kubernetes cluster, we can set it to

public static string S_Address = "<IP OF A LOAD BALANCER>";
public static bool S_EnforceAddress = true;

Misc

Also, I've included Dockerfile, docker-compose.yaml, and some changes to .gitignore to make it easier to contribute.

Please let me know if something needs to be changed! Thanks!

devOwlish commented 2 weeks ago

Let's give it a shot