-
-
Notifications
You must be signed in to change notification settings - Fork 385
Feature: Whitelist overhaul #3107
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
base: general-devel
Are you sure you want to change the base?
Feature: Whitelist overhaul #3107
Conversation
Introduces a class for managing a whitelist of IP addresses and networks, enabling adding, removing, and persisting entries to a file. Whitelist is used to allow or restrict access based on IP, with support for CIDR networks and individual IPs.
Clarifies and adds more private IP range options in the whitelist comments for better configuration guidance
Introduces the whitelist system as a core component and applies it during player IP checks, replacing direct file-based whitelisting calls with a dedicated service to improve clarity and maintainability.
Adds logic to check if the file ends with a newline and inserts one if needed to prevent line concatenation issues.
|
@ACaiCat if you think the code is good, can you add a code review too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and after adding 127.0.0.1 to the whitelist and using /reload, I was not able to whitelist myself.
Also, Terraria doesn't support IPv6.
Maybe you should find someone more professional, but it's not me. |
You are professional |
|
Also, if the whitelist is blank, I think it would be fine to populate it with the example whitelist instead of leaving it blank. e.g., if whitelist is disabled, and is empty, add the default config to it. |
It seems can not be reloaded through |
Enhances the whitelist command to correctly handle parameter input, provides success or error messages based on the addition outcome.
Forgot to check if Terraria itself actually DOES support IPv6... According to a few researches, latest hotfixes have grazed the subject. Hopefully we'll get IPv6 soon 🤞🏻
Introduces a method to reload whitelist data from file, allowing updates without restarting the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other note:
- There's a submodule update that actually reverts 57039ed, probably unwanted.
- The include of
.ideafolder?
Oops, indeed unwanted changes. Lemme fix that right away 😅 |
Oops, should've paid more attention ^^'
Switches to bitwise AND operator to correctly combine add/remove operations with line updates.
|
I test it on my win server, Log: |
By any chance, would you have the repro steps for this one ? Because I can't repro the issue. |
Just try to add a ip through |
|
@THEXN tested it too and got the same error. |
|
Okay. Seems I derped handling the file streams. |
Add a warning message when IPv6 addresses are used in whitelist commands, as IPv6 support isn't implemented yet, and update error message for better clarity on correct command usage
Switches to localized strings for IPv6 warnings and invalid whitelist entry logs.



Overhauled the whitelist system to use a new dedicated service.
This one is memory-based to optimise lookups, rather than accessing the file at each server join for WL comparison.
Added support for in-file comments, by using
#prefix (considered invalid and ignored by parser). Could come in handy for those massive files, or just keeping track of "whose IP is this" cases.Added support for ranges using CIDR notation, to allow for entire subnets to be whitelisted. Particularly useful for LAN parties.
New default for the
whitelist.txtfile looks like this :Resolves #3091.