[Mod] SQLite Ban [sban]

Post Reply
User avatar
shivajiva
Member
Posts: 32
Joined: Fri Nov 27, 2015 09:41
In-game: shivajiva

[Mod] SQLite Ban [sban]

by shivajiva » Post

A mod based on the concepts introduced by xban2, expanding on them by using an sql database instead of a serialised table file.
This approach to ban management:
  • Offers API access to useful functions.
  • Improves the robustness of the data.
  • Grants an enhanced view of player accounts and ban records.
  • Provides tiered access to player record information.
  • Provides an option for automatic ban expiration.
  • Provides the capability to pre-emptively ban players.
  • Offers increased accessibility via SSH connections to the database with your
    favourite database management gui.
  • Can preserve existing bans by importing records from Minetest or xban2.
Installation requirements
This mod depends on the lua module lsqlite3 (https://github.com/LuaDist/lsqlite3) A thin wrapper for the SQLite database engine.
The preferred method is to use luarocks to install it. (https://luarocks.org/)

Download zip file
Browse code on Github

License: MIT license

Commands

The mod provides the following chat console commands. These commands require the ban privilege. The ban_admin and server privileges extend the functionality of some commands.

bang

Launches a GUI. Comprehensive management of bans via a user interface for in-game convenience. On launch the interface shows a hotlist containing the last 10 players to join. Use search to find a player if they are not currently in the list. Multiple record pages are shown if available, accessible via the arrows.

Usage: /bang

ban

Bans a player permanently.

Usage: /ban <name_or_ip> <reason>

Example: /ban Steve Some reason.

The server privilege enables the pre-emptive banning of player names or IP addresses for which the server has no current record.

tempban

Bans a player temporarily.

Usage: /tempban <name_or_ip> <time> <reason>

Example: /tempban Steve 2D Some reason.

The time parameter is a string in the format <count> <unit>, where <unit> is either s for seconds, m for minutes, h for hours, D for days, W for weeks, M for months, or Y for years. If the unit is omitted, it is assumed to mean seconds. For example, 42 means 42 seconds, 1337m means 1337 minutes, and so on. You can chain more than one such group and they will add up. For example, 1Y3M3D7h will ban for 1 year, 3 months, 3 days and 7 hours.

unban

Unbans a player.

Usage: /unban <name_or_ip> <reason>

Example: /unban Steve Some reason.

Note: this command requires an unban reason.

ban_record

Displays player record and ban record.

Usage: /ban_record <name_or_ip>

Example: /ban_record Steve

This prints the player record and ban record for a player. The records are printed to the chat console with one entry per line.

The player record includes names and, if the user has the ban_admin privilege, IP addresses used by the player. The number of records displayed is limited to 10 by default to prevent chat console spam, and can be adjusted through the sban.display_max setting in minetest.conf.

The ban record includes a list of all ban related actions performed on the player under any known name or IP address. This includes the time a ban came into effect, the expiration time (if applicable), the reason, and the source of the ban.

Note: records of players with the server privilege can only be viewed by other players with the server privilege.

See the readme file for details of the admin commands and settings

Download zip file
Browse code on Github
Last edited by shivajiva on Fri Dec 10, 2021 13:41, edited 2 times in total.

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: [MOD] SQLite Ban [sban]

by ExeterDad » Post

Oh I am so happy with you!
I've actually been trying to roll my own version of what you just posted! I'll be testing as soon as humanly possible. I've already been working (learning actually) with the lsqlite3 module so your module choice couldn't be more perfect for me.

User avatar
shivajiva
Member
Posts: 32
Joined: Fri Nov 27, 2015 09:41
In-game: shivajiva

Re: [MOD] SQLite Ban [sban]

by shivajiva » Post

you should find this interesting, I've kept it clean and simple to serve as a reasonable example. You might like sauth also, I thought I'd hand roll an auth handler using lsqlite3 library, you can find it here

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: [MOD] SQLite Ban [sban]

by ExeterDad » Post

Heh heh! This is like Christmas! Now two things off my list I wanted to tackle. It's like you've seen my TODO list or something :)
I do know one thing, your code will be a excellent learning tool for me. I was poking around the code in sban and drooling because your examples answered many questions I had while trying to figure out how to use the module in Minetest. I'll be rewriting much of what I've done (unrelated mod) as your implementation is superior to mine.

Thanks!

BBmine
Member
Posts: 3476
Joined: Sun Jul 12, 2015 22:51
GitHub: BBmine
IRC: BBmine
In-game: Baggins
Location: USA

Re: [MOD] SQLite Ban [sban]

by BBmine » Post

This has all the features any ban mod should have!

User avatar
ManElevation
Member
Posts: 896
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation
Location: Madrid,Spain

Re: [MOD] SQLite Ban [sban]

by ManElevation » Post

BBmine wrote:This has all the features any ban mod should have!
exacly! +1
My Public Mods! Discord: Rottweiler Games#3368

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [MOD] SQLite Ban [sban]

by rubenwardy » Post

After a very quick bug fix by shivajiva, I can confirm that this mod is working perfectly for me. Thanks for this. Database all the things!
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Lejo
Member
Posts: 718
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: [Mod] SQLite Ban [sban]

by Lejo » Post

I'm currently dockerizing my server.
Because of lsqlite3 I sadly couldn't use the official minetest docker server image, but needed to create an own one.
You can find the minetest server image with lsqlite3 on the Docker Hub or the Dockerfile for it on Github

Just wanted to drop this here if anybody needs the same.

User avatar
shivajiva
Member
Posts: 32
Joined: Fri Nov 27, 2015 09:41
In-game: shivajiva

Re: [Mod] SQLite Ban [sban]

by shivajiva » Post

If you use the sban mod you should update asap to fix a few important issues I came across, if you updated the database last time there is no need to run it again and any orphaned records will be shown in the server log file once sban loads for you to deal with appropriately e.g. cross reference the id shown in the log to the player and then ban that player using any of their nicks, if you have had trouble banning them previously!

If you are not using it and run a public server then I'd love to know why not! Feel free to let me know what decisions made you choose to use an alternative.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests