OpenPerpetuum / PerpetuumServer

The Open Perpetuum Project's fork of the Perpetuum Standalone Server
https://openperpetuum.com
Other
44 stars 21 forks source link

Issue 257: Server "Admins only" mode #290

Closed Veritania closed 3 years ago

Veritania commented 3 years ago

Summary

This is a step on the path to solve #257 This change hooks up two new admin commands for the in-game chat => #relayclose and #relayopen They require accessLevel of admin https://github.com/OpenPerpetuum/PerpetuumServer/blob/bd606e24b869e1b91673c39c8ddbf7d34cf07006/src/Perpetuum/Commands.cs#L1054-L1064

By default the server is starting in "relayopen" mode, meaning it is open to the public and anyone can join. (This is unchanged behaviour)

Once an admin has #secured a channel and then ran the #relayclose command, normal players are no longer able to login to the server.

This is thanks to the flow of our Sign In handler https://github.com/OpenPerpetuum/PerpetuumServer/blob/bd606e24b869e1b91673c39c8ddbf7d34cf07006/src/Perpetuum.RequestHandlers/SignInRequestHandler.cs#L31-L34

RelayClose, only closes it to the public (and not entirely for everyone) by setting the RelayState as such:

https://github.com/OpenPerpetuum/PerpetuumServer/blob/bd606e24b869e1b91673c39c8ddbf7d34cf07006/src/Perpetuum.RequestHandlers/RelayClose.cs#L17

Caveats

Closing the relay has zero effect on normal players who already passed the login screen -> Meaning if they are sitting on Character Select or is in game, they can continue playing.

This will only block new attempts to log on to the server.

How to test

Requires 2 game accounts One that is a regular account, and one that is of accessLevel Admin (tool or game, either works)

Apply the changes from this PR, then run the server.