This is the source code for the Forged Alliance Forever server.
master | develop |
---|---|
Install docker.
Follow the steps to get faf-db setup, the following assumes the db container is called faf-db
and the database is called faf
and the root password is banana
.
The server needs an RSA key to decode uniqueid messages, we've provided an example key in the repo as faf-server.example.pem
. The server expects this to be named faf-server.pem
at runtime, so first copy this
cp faf-server.example.pem faf-server.pem
Then use Docker to build and run the server as follows
docker build -t faf-server .
docker run --link faf-db:db -p 8001:8001 -p 30351:30351 faf-server
Check if the container is running with
docker ps
If you cannot find faf-server
in the list, run docker run
without -d
to see what happens.
If you have a different root password, database name then the default (see config.py), you must pass it over the environment parameter of docker, e.g.
docker run --link faf-db:db -p 8001:8001 -p 30351:30351 -e FAF_DB_PASSWORD=<wanted_password> -e FAF_DB_NAME=<db_name> faf-server
To contribute, please fork this repository and make pull requests to the develop branch.
Use the normal git conventions for commit messages, with the following rules:
- Subject line shorter than 80 characters
- Proper capitalized sentence as subject line, with no trailing period
- For non-trivial commits, always include a commit message body, describing the change in detail
- If there are related issues, reference them in the commit message footer
First make sure you have an instance of faf-db
running as described in the
installation section. Then install the dependencies to a virtual environment
using pipenv:
$ pipenv install --dev
You can start the server in development mode with:
$ pipenv run devserver
Note The pipenv scripts are not meant for production deployment. For
deployment use faf-stack
Some of the tests require the database to be pre-populated with test data. Download
the latest test-data.sql
from [FAForever/db](https://github.com/FAForever/db
into the root of this project, then run:
$ pipenv run tests
You can check for possible unused code with vulture
by running:
$ pipenv run vulture
GPLv3. See the license file.
The protocol is mainly JSON-encoded maps, containing at minimum a command
key, representing the command to dispatch.
The wire format uses QDataStream (UTF-16, BigEndian).
For the lobbyconnection, each message is of the form:
ACTION: QString
With most carrying a footer containing:
LOGIN: QString
SESSION: QString
{command: modvault, type: start}
: show the last 100 mods{command: modvault, type: like, uid: <uid>}
: check if user liked the mod, otherwise increase the like counter{command: modvault, type: download, uid: <uid>}
: notify server about a download (for download counter), does not start the download
{command: social_add, friend|foe: <player_id>}
: Add a friend or foe{command: social_remove, friend|foe: <player_id>}
: Remove a friend or foe
{command: avatar, action: list_avatar}
: Send a list of available avatars{command: avatar, action: select, avatar: <avatar_url>}
: Select a valid avatar for the player
{command: ice_servers}
: Send ICE TURN/STUN servers - Returns:{command: ice_servers, : <ice servers>, date_created: <date token was created in ISO 8601 format>, ttl: <ttl in seconds>}
- [deprecated]
{command: ask_session}
: response with a welcome command and a valid session (can be delayed) {command: hello, version: <...>, login: <...>, password: <...>, unique_id: <...>, (session: <...>)}
: Log in to the server
The stream API is deprecated, but currently the following message types are supported:
PING
: response with aPONG
PONG
: internal state changed to ponged