Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated whitelists #23985

Merged
merged 36 commits into from
Aug 27, 2024
Merged

Automated whitelists #23985

merged 36 commits into from
Aug 27, 2024

Conversation

Simyon264
Copy link
Contributor

@Simyon264 Simyon264 commented Jan 12, 2024

About the PR

This PR adds automatic whitelists based on conditions defined in a prototype.

Why / Balance

Resolves #19606.

Technical details

This PR adds a blacklist table to the DB and the coresponding commands for managing the blacklist.
I also added a new prototype PlayerConnectionWhitelist which is used to define whitelists. That prototype contains an Array of WhitelistCondition conditions. Every WhitelistCondition contains 2 DataFields and a Function to check if the player is allowed to connect. The 2 DataFields are the following:
BreakIfConditionSuccess: If the condition passes, the next conditions will not be checked and the player will be able to connect.
BreakIfConditionFail: If the condition fails, the player will be denied and the next conditions will not be checked.

Media

image
image
image

  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

This removes some CVars related for whitelists, the legacy whitelists are used by default when whitelist.enabled is set to true. Use whitelist.prototypeList to define which whitelists should be used. Currently implemented whitelists are: mrpWhitelist and basicWhitelist.

@Simyon264 Simyon264 marked this pull request as ready for review January 13, 2024 12:39
@github-actions github-actions bot added the Status: Needs Review This PR requires new reviews before it can be merged. label Jan 13, 2024
@Simyon264 Simyon264 changed the title Better whitelists Automated whitelists Jan 13, 2024
Copy link
Contributor

@Chief-Engineer Chief-Engineer left a comment

Choose a reason for hiding this comment

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

Overall, it looks like it would work for WizDen's needs, but changes could be made to improve readability of the prototype, and to make the system more flexible, potentially allowing it to be easier to use for other things in the future.

Adding support for playtime based ranges for the note condition is probably the thing that'd have the biggest impact on the effectiveness of the system for WizDen

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a terminology nitpick, but to keep things flexible, I'd avoid using the term whitelist/blacklist. It's all just conditions or rules that contribute to an overall blacklist or whitelist system, using terminology that doesn't describe any of the conditions as a whitelist or blacklist can encourage people who make changes in the future to keep the design flexible.

It's not the "Minimum number of players required for this whitelist to be active", it's the "Minimum number of players required for this condition to match", because if the condition can be used flexibly enough, then it can be used as a whitelist or a blacklist

Content.Server.Database/Model.cs Show resolved Hide resolved
@metalgearsloth
Copy link
Contributor

@Simyon264 you working on this famalams.

@metalgearsloth metalgearsloth added Status: Awaiting Changes This PR needs its reviews addressed or changes to be made in order to be merged. and removed Status: Needs Review This PR requires new reviews before it can be merged. labels Feb 1, 2024
@Simyon264
Copy link
Contributor Author

Yes. I am still working on it.

@github-actions github-actions bot added the Merge Conflict This PR currently has conflicts that need to be addressed. label Feb 20, 2024
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
Content.Server/Connection/ConnectionManager.cs Outdated Show resolved Hide resolved
@metalgearsloth metalgearsloth added Status: Awaiting Changes This PR needs its reviews addressed or changes to be made in order to be merged. and removed Status: Needs Review This PR requires new reviews before it can be merged. labels Jun 19, 2024
@github-actions github-actions bot removed the Merge Conflict This PR currently has conflicts that need to be addressed. label Jun 26, 2024
@Simyon264 Simyon264 requested a review from PJB3005 July 5, 2024 11:25
@github-actions github-actions bot added Status: Needs Review This PR requires new reviews before it can be merged. and removed Status: Awaiting Changes This PR needs its reviews addressed or changes to be made in order to be merged. labels Jul 5, 2024
Copy link
Contributor

@Chief-Engineer Chief-Engineer left a comment

Choose a reason for hiding this comment

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

Sorry for not catching this earlier. It seems like there are some quirks with the manual whitelist/blacklist conditions.

It's very possible that I'm missing something, partly because I'm just looking at the changes on GitHub, but it looks like the manual whitelist/blacklist conditions have opposite behavior based on someone's status in the list. I understand why this would have been done, but I think both of these should act as a "is the person on the list" check instead for two reasons:

  1. A long term goal would be to allow arbitrary lists to be made so that servers can create as many manual lists as they want for whatever purpose they have, potentially even using those lists for other things unrelated to connections. Having conditions work as being list membership now will prevent having to make changes in the future that either break YAML configs or require workarounds.
  2. I think it makes the rules clearer in the YAML. ConditionManualBlacklist allow seems weird. It might also help to append Membership to the conditions, but that'd increase the name length quite a bit.

Resources/Prototypes/whitelists.yml Outdated Show resolved Hide resolved
Resources/Prototypes/wizardsDenWhitelists.yml Outdated Show resolved Hide resolved
Resources/Prototypes/wizardsDenWhitelists.yml Outdated Show resolved Hide resolved
@Simyon264
Copy link
Contributor Author

A long term goal would be to allow arbitrary lists to be made so that servers can create as many manual lists as they want for whatever purpose they have, potentially even using those lists for other things unrelated to connections. Having conditions work as being list membership now will prevent having to make changes in the future that either break YAML configs or require workarounds.

Something like this? @Chief-Engineer

  - !type:ConditionMembership
    list: whitelist # Which list the player needs to be a part of
    requiredMembershipTime: 120 # Must be a member for 2 hours
    action: Allow
  - !type:ConditionAlwaysMatch
    action: Deny # Not a member, deny connection

@Chief-Engineer
Copy link
Contributor

A long term goal would be to allow arbitrary lists to be made so that servers can create as many manual lists as they want for whatever purpose they have, potentially even using those lists for other things unrelated to connections. Having conditions work as being list membership now will prevent having to make changes in the future that either break YAML configs or require workarounds.

Something like this? @Chief-Engineer

  - !type:ConditionMembership
    list: whitelist # Which list the player needs to be a part of
    requiredMembershipTime: 120 # Must be a member for 2 hours
    action: Allow
  - !type:ConditionAlwaysMatch
    action: Deny # Not a member, deny connection

Yes, except I'm not sure that requiredMembershipTime would be too useful unless the lists were automatically generated

@github-actions github-actions bot added the Merge Conflict This PR currently has conflicts that need to be addressed. label Jul 11, 2024
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the Merge Conflict This PR currently has conflicts that need to be addressed. label Jul 11, 2024
@github-actions github-actions bot added the Merge Conflict This PR currently has conflicts that need to be addressed. label Aug 9, 2024
Copy link
Contributor

github-actions bot commented Aug 9, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Member

@PJB3005 PJB3005 left a comment

Choose a reason for hiding this comment

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

I'll fix these issues myself real quick.

Comment on lines 52 to 53
Dictionary<NetUserId, List<IAdminRemarksRecord>> cacheRemarks = new();
Dictionary<NetUserId, List<PlayTime>> cachePlaytime = new();
Copy link
Member

Choose a reason for hiding this comment

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

Why are you storing this keyed on user ID if this function only runs for a single user at once?

return await _db.GetBlacklistStatusAsync(data.UserId);
}

private async Task<bool> CheckConditionNotesDateRange(ConditionNotesDateRange conditionNotes, List<IAdminRemarksRecord> remarks)
Copy link
Member

Choose a reason for hiding this comment

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

These don't need to be async

Comment on lines 279 to 284
if (bans.Count > 0)
{
var firstBan = bans[0];
var message = firstBan.FormatBanMessage(_cfg, _loc);
return (ConnectionDenyReason.Ban, message, bans);
}
Copy link
Member

Choose a reason for hiding this comment

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

Screwed up merge xd

@github-actions github-actions bot removed the Merge Conflict This PR currently has conflicts that need to be addressed. label Aug 27, 2024
@PJB3005 PJB3005 merged commit f92ef41 into space-wizards:master Aug 27, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review This PR requires new reviews before it can be merged.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Automated whitelists
4 participants