[Mod] SQLite Ban [sban]

Post Reply
User avatar
shivajiva
Member
Posts: 28
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:
  • 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.

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 Wed Apr 22, 2020 15:54, edited 1 time 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: 28
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: 3475
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: 6072
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: 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!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests