Skip to content

startersclan/prmasterserver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRMasterServer

github-actions github-release docker-image-size

A GameSpy replacement Master Server for Project Reality: BF2. This emulates the GameSpy API in order to keep PR:BF2 playable after the Battlefield 2 GameSpy shutdown.

Features

Supports Battlefield 2's GameSpy implementation. No other games are supported (yet?). If you wish to modify the code and add support for your game, or add any additional features, please feel free to make a fork and submit a pull request.

  • Login Server (Uses SQLite for the database)
    • Creating Accounts
    • Retrieving accounts by username/email (allows multiple accounts per email)
    • Log in
  • Server Browser
    • Server Reporting (Game Server registering with Master Server)
    • Server Retrieval (Client requesting a server list)
    • Supports filters
    • GeoIP
  • CD Key Authentication
    • Accepts all CD Keys with no further checks.

Usage

The docker image includes the binary, dependencies, and the MaxMind GeoIP2 Country database.

# Test run
docker run --rm -it -p 29900:29900/tcp -p 29901:29901/tcp -p 28910:28910/tcp -p 27900:27900/udp -p 29910:29910/udp startersclan/prmasterserver:latest

# Run with support for bf2 and fh2
printf "bf2\nfh2\n" > modwhitelist.txt
docker volume create data-volume
docker run --rm -it -p 29900:29900/tcp -p 29901:29901/tcp -p 28910:28910/tcp -p 27900:27900/udp -p 29910:29910/udp \
    -v $(pwd)/modwhitelist.txt:/app/modwhitelist.txt:ro \
    -v data-volume:/data \
    startersclan/prmasterserver:latest

# Now launch Battlefield 2, and try creating a multiplayer account and logging in and out

FAQ

Q: Error: MaxMind.GeoIP2.Exceptions.AddressNotFoundException: The address 192.168.192.3 is not in the database

∑ A: This error may be safely ignored. The error is seen when the IP of the registering BF2 server is a private IP address instead of a public IP address as seen by PRMasterServer (for example, when using docker). For example:

[2023-11-07 15:34:11.556] [ServerReport] MaxMind.GeoIP2.Exceptions.AddressNotFoundException: The address 192.168.192.3 is not in the database.
at MaxMind.GeoIP2.DatabaseReader.Execute[T](String ipStr, IPAddress ipAddress, String type, Boolean throwOnNullResponse)
at MaxMind.GeoIP2.DatabaseReader.Execute[T](String ipStr, String type, Boolean throwOnNullResponse)
at MaxMind.GeoIP2.DatabaseReader.Country(String ipAddress)
at PRMasterServer.Servers.ServerListReport.ParseServerDetails(IPEndPoint remote, Byte[] data) in /source/PRMasterServer/Servers/ServerListReport.cs:line 304

Setting up the project

  1. Be sure to have Visual Studio 2013 installed. You might be able to compile it using previous versions of Visual Studio or using Mono, but this is untested and may not work.

  2. Open PRMasterServer.sln, and build. This should download via NuGet any extra packages required.

  3. Grab the latest MaxMind GeoIP2 Country database, or use the free GeoLite2 Country database. Put it in the same folder as PRMasterServer.exe.

  4. Create a modwhitelist.txt file containing line separated mod names (i.e. bf2, pr, fh2) to allow servers running these mods to register with the master server. Or, just use % to allow all mods. If you don't have a modwhitelist.txt file, it will default to Project Reality: BF2 mod names (pr and pr!_%).

Tip: % is wildcard, _ is placeholder, ! is escape, # at the start of the line is a comment, empty lines are ignored.

  1. Run PRMasterServer.exe +db LoginDatabase.db3 and it should start up with no errors. You can use an optional +bind xxx.xxx.xxx.xxx paramter to bind the server to a specific network interface, or by default it will bind to all available interfaces.

  2. If there's issues, unlucky, I'm sure you'll be able to figure them out :).

Stuff to do

Of course, no project is ever really complete, there's plenty of other stuff that could be done. Maybe in the future it just might happen.

  • Comment the code so you poor folk can understand the black magic.
  • Manage account protocol (delete accounts, change password, change email).
  • Maybe support some other games than just Battlefield 2. But isn't that the point of open sourcing and putting it on GitHub? If you want it, make a fork and do it ;).

Credits

Luigi Auriemma for reverse engineering the GameSpy protocol and encryption.