-
Notifications
You must be signed in to change notification settings - Fork 68
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
Use a SQL database for bans #725
Comments
A major problem with SQLite is handling network range bans. |
Absolutely - in this case, a server network should use a remote database such as MySQL. SQLite is just a 'works out of the box' solution for most servers. Unrelated, but I also want to add that it's highly likely that SQLite and MySQL can use the same set of queries from pique. |
@lokka30 You might be misinterpreting; by network range they mean CIDR range. Not sure how MySQL would help in this regard; do you have any specific schema or built-in functions in mind? |
Ah, thank you for the clarification. I'm unsure how these would be stored - perhaps IP ranges could be stored as strings whilst specific IPs would be stored in bits, both columns are nullable but one is guaranteed to be present.
|
Having SQLite as a ban backend would be nice, it's very portable and fast, and Python has built-in support for it through the sqlite3 module. To implement this while keeping backwards compatibility and avoiding spaghetti code, I think it would be best to add a new config option specifying a module+class string in the config (example: For compat, I think we could keep |
@lokka30 for the database structure, I would suggest this:
Only |
The problem with it is kind of that we have to be able to look up wherher an IP is in any of the ranges efficiently. That's kind of hard without native support in the db. |
Thanks for your input utf and nota I believe MySQL and Postgres have native support for IP addresses including IPV4 and IPV6 in the same field. The I don't believe SQLite has this kind of type, which may make it less/un-suitable for this application For backwards compatibility, is there an issue in having all servers migrate to the DB if we end up choosing a stable flatfile solution? Of course if this ends up only being a remote DB feature then txt will have to remain as default. |
The flat file is simple enough that writing migrations for it wouldn't be hard. I remember this originally being motivated by how long it takes to save the DB to a json file, which we I think somewhat mitigated by moving it to another thread? So another option here would be to simply continue keeping an index in memory, and only use the db for actually saving things. |
Forcibly moving away from the flatfile is certainly an option. Potentially the added difficulty for inexperienced users can be alleviated through recommending a 'flavour' of the current docker compose config recommended to also run a MariaDB service. That way you have a running server out of the box. |
I don't personally think it makes sense to run a database just for bans for 99% of people. Basically anyone except aloha. |
I suggest SQLite as the default just so servers can run out of the box.
For those running multiple servers referencing the same bans list, MySQL could be made available as a choice of database.
Hopefully this addition would help or mostly solve issues such as #114 and #619.
The text was updated successfully, but these errors were encountered: