Multiplayer server made in python for a simple pvp online pirate game. The game itself can be found on another repository here.
- Setup python 2.7.x on your machine from here
- Install the pycryptodome package
- Clone the repository
- Start server using
py .
in the project folder - Run the game client from this repository here
I made this project as a prove of concept to make a solid realtime multiplayer server in python. This project was made around 2016 and updated it recently to make it work with all recent updates.
Player accounts are managed with a simple SQLite database, which can be found in the data folder. This database can easilly be edited with any SQLite browser, accounts can also be made using the cli commands.
The game will connect to the server directly using a TCP connection and will need to do a custom handshake to make the connection secure.
The game will setup and generate RSA credentials and share the public key with the server. The pipeline is now secure but it's only one-way and it's slow. That's why the server will now generate a random key for AES encryption. The server will share this key using the RSA pipeline with the game client and now both parties can communicate securely.
For higher performance the game will also use a peer-to-peer setup between players. The server will share a random key with the game client, which the client has to send back to the server's UDP endpoint. This way the server will get the know UDP endpoint of the client, which is later shared with other players. When the game starts, the players will get eachothers UDP endpoints and are able to send communicate to eachother directly.
After running the server, you can still communicate with the server in the same cli. There are some pre-defined commands which might be usefull during testing.
register [username] [password]
list players
list rooms
save
exit
- Setup tests
- Move to external login provider
- Destroy all data properly