Skip to content

Conversation

@Veritania
Copy link

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

public static readonly Command RelayOpen = new Command
{
Text = "relayOpen",
AccessLevel = AccessLevel.admin
};
public static readonly Command RelayClose = new Command
{
Text = "relayClose",
AccessLevel = AccessLevel.admin
};

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

if (_relayStateService.State.Equals(RelayState.OpenForAdminsOnly) && !account.AccessLevel.IsAdminOrGm())
{
throw new PerpetuumException(ErrorCodes.RelayIsClosedForPublic);
}

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

_relayStateService.State = RelayState.OpenForAdminsOnly;

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.

  • Login with your regular account, as a sanity check. Logout again.
  • Login with your Admin Account, and enter the game with a character.
  • #secure a chat channel, and then run the #relayclose command.
    • The server should no longer accept logins from normal accounts
  • Logout of Admin Account
  • Attempt to login with a normal account.
  • You should see "error_RelayIsClosedForPublic"
  • Log back in on your Admin Account, and in a #secure chat channel run the #relayopen command.
  • Logout of Admin Account
  • Attempt a login from the normal account, you should successfully get in now.

This allows for admins to call #relayclose or #relayopen in a #secure chat channel, to "block" the LOGIN attempts from non-admin level accounts.
@Veritania Veritania added the enhancement New feature or request label Mar 26, 2021
@Veritania Veritania requested a review from MikeJeffers March 26, 2021 23:53
@Veritania Veritania marked this pull request as ready for review March 27, 2021 00:04
Copy link

@MikeJeffers MikeJeffers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work :)

@Veritania Veritania merged commit d062c51 into Development Mar 27, 2021
@Veritania Veritania mentioned this pull request Mar 27, 2021
@MikeJeffers MikeJeffers deleted the veritania/server-dev-only-mode branch April 11, 2021 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request P21

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants