[Mod] Advanced Ban [advancedban] [0.3]

Post Reply
User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

[Mod] Advanced Ban [advancedban] [0.3]

by srifqi » Post

Hi!
This mod will ban player based on its username, not its IP address.

Features
- Ban based on its username, not its IP address
- Add banned username manually to "bannedplayerlist.txt" (default)

Usage (chat command cheatsheet)

Check ban for a player
/abancheck <player name>

Simple ban/unban (require "ban" privilege)
/aban <player name>
/unaban <player name>

Ban with kick (requires "ban" and "kick" privileges)
/abankick <player name>

Ban/unban with its IP (requires "ban" privilege)
/aban+ <player name>
/unaban+ <player name>

See README.

GitHub: https://github.com/srifqi/advancedban
Downloads: License: MIT License
Dependencies: (none)

No need for screenshot. :P
Last edited by srifqi on Thu Aug 08, 2019 16:40, edited 4 times in total.
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
Krock
Developer
Posts: 4648
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: [Mod] Advanced Ban [advancedban] [0.1]

by Krock » Post

How is this better than the default ban mod?
Someone could get banned with the troll account and simply join with an other one.

Also, how about using

Code: Select all

minetest.register_on_prejoinplayer(function(player)
     return "You have been banned"
end)
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Pitriss
Member
Posts: 254
Joined: Mon Aug 05, 2013 17:09
GitHub: Pitriss
IRC: pitriss
In-game: pitriss
Location: Czech republic, Bohumin

Re: [Mod] Advanced Ban [advancedban] [0.1]

by Pitriss » Post

maybe you can make your command shorter..:)

for example /aban and add /akickban (/akban respectively) which will also kick player after banning him:)
I reject your reality and substitute my own. (A. Savage, Mythbusters)
I'm not modding and/or playing minetest anymore. All my mods were released under WTFPL. You can fix/modify them yourself. Don't ask me for support. Thanks.

User avatar
Hybrid Dog
Member
Posts: 2828
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: [Mod] Advanced Ban [advancedban] [0.1]

by Hybrid Dog » Post

Krock wrote:How is this better than the default ban mod?
Someone could get banned with the troll account and simply join with an other one.
The default ban allows players to join again with the same name, just with another ip address.
viewtopic.php?p=45428#p45428

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
WebWolf
Member
Posts: 15
Joined: Thu Jun 19, 2014 05:00

Re: [Mod] Advanced Ban [advancedban] [0.1]

by WebWolf » Post

Hi all,

srifqi, thank you for your mod advancedban. It is really very useful.
Some players have dynamic IP (it means a bad player is able to change his IP just pressing a button in his modem) and in this way they can enter any server with any kind of banning mod with a new username *and* a new IP, without beeing banned. So, it seems your mod is a good option to be used alone (if some admins or the owner are able to play in the server sometimes, and watch / ban the bad players).
Of course other mods like xban (extended ban) and future_ban are also useful (for an automatic control, using IP), depending on the server (and the presence of admins in the server).

Anyway, I changed some lines in the code and I'd like to share with other people, for those who could eventually use it.
Instead of the code:

Code: Select all

minetest.register_on_joinplayer(function(player)
	if file_exists(minetest.get_worldpath()..DIR_DELIM..FILE_NAME) == true then
		local list = io.open(minetest.get_worldpath()..DIR_DELIM..FILE_NAME, "r")
		for username in list:lines() do
				local name = player:get_player_name()
				if name == username then
					minetest.after(0.1, function()
						minetest.kick_player(name, BAN_MESSAGE) -- kick player
					end)
				end
			end
		list:close()
	end
end)


I changed to:

Code: Select all

minetest.register_on_prejoinplayer(function(name, ip)
local lname = name:lower()
	if file_exists(minetest.get_worldpath()..DIR_DELIM..FILE_NAME) == true then
		local list = io.open(minetest.get_worldpath()..DIR_DELIM..FILE_NAME, "r")
			for username in list:lines() do
				if lname == username:lower() then --lname and username variables are in lowercase (so that the admin or server owner doesn't need to worry about typing BadGuy or badguy as an username; the script accepts all variations automatically)
					return BAN_MESSAGE -- This line uses the same ban message configured at the beginning of the mod
					--return "Sorry, this username is not available anymore. Please use another username (and play using one username only). Also, please do not use badnames or offensive names. Thank you." --This is just an idea for another ban message...
				end
			end
		list:close()
	end
end)
Basically the validation is done using "minetest.register_on_prejoinplayer" instead "minetest.register_on_joinplayer" (in other words, before the player logs in or enters the server).
It seems this change brings 3 interesting changes (faster and easier for the admins, and more productive for the server):
1) As the bad (banned) player is not able to log in (without need to be kicked after he joins), messages like "# player BadGuy entered the server" and (after being kicked) "# player BadGuy left the server", causing less span (unnecessary messages) in chat (what is good for all the players who are online and also for the server)
2) The validation is done before the player logs in, with (hopefully) some milliseconds in less time (that is, the server doesn't need to load all the player stuff like skin and items, probably using less CPU work in the server side).
3) There is a better psychological impact for the bad player: he is not able to enter the server (even for a few seconds before being kicked) and see the buildings, the spawn, the chat (conversation) or any other image inside the world in the server.

Additionaly, the lname and username variables are in lowercase (so that the admin or server owner doesn't need to worry about typing BadGuy or badguy as an username; the script accepts all variations automatically).

Well, just an idea. I hope it can be useful for other friends here. :)
If something is wrong, please correct or don't consider my post.

Regards,
WebWolf

P.S.: December, 29... Happy New Year 2015 for all people in this forum, including your family and friends.

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

UPDATE: [Mod] Advanced Ban [advancedban] [0.1.1]

by srifqi » Post

Released 0.1.1! (Banned Player Handling Update)
Changes:
  • Better banned player handling (Thanks, Krock and WebWolf!)
  • Shorter chat command for /advancedban -> /aban
  • Add new chat command /abankick that allows to kick after added to list
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

UPDATE: [Mod] Advanced Ban [advancedban] [0.2]

by srifqi » Post

Released 0.2! (Unban Update)
Changes:
  • Add method to unban player
  • Add chat command shortcut to ban IP
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
poikilos
Member
Posts: 67
Joined: Thu Feb 18, 2016 13:45
GitHub: Poikilos
In-game: Poikilos

Re: [Mod] Advanced Ban [advancedban] [0.1]

by poikilos » Post

Krock wrote:How is this better than the default ban mod?
Someone could get banned with the troll account and simply join with an other one.

Also, how about using

Code: Select all

minetest.register_on_prejoinplayer(function(player)
     return "You have been banned"
end)
This mod is still useful in at least one case where keeping the person out is not guaranteed:
  • usernames that are against a server's code of conduct
...and at least two uses where keeping the person out is guaranteed (barring social/computer security issues):
  • whitelist servers can ban temporarily regardless of changing ip (my case)
  • whitelist servers can permanently or semi-permanently record a ban (as opposed to just removing the username from the whitelist and risking another admin will re-add them unknowingly)
I am aware that security is often not regarded as a big thing in Minetest (at least that's the way it seems--considering protection is not as advanced as Mine...:ahem:...another popular sandbox game with a rather young community which often has script kiddies and lesser skilled players who use their hacks), but:
  • Due to people being able to change their IP, a whitelisted server is the only way to guarantee user access control (barring password being guessed/obtained, or other social engineering--but I won't give people ideas :) ).
  • xban2 can allow banning an IP (like the default ban) but un-banning a username, but not banning only a username--hence it provides no helpful features for whitelisted servers other than unblocking people who have a duplicate external IP (and also, xban2 is bugged and noone wants to fix it--a random set of people get banned on a LAN party if one username is banned, even when the server is on the same LAN--I'm not sure whether this can happen when everything is on the WAN)
Due to these two facts, this is the most trustworthy ban mod (in combination with a whitelist).

Thanks for the mod, srifqi!

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

UPDATE: [Mod] Advanced Ban [advancedban] [0.2.1]

by srifqi » Post

Released 0.2.1! (0.2.1 Update)
Change:
  • Bugfix: Only save latest banned user name.
The bug was the inability to save more than one user name.
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

UPDATE: [Mod] Advanced Ban [advancedban] [0.3]

by srifqi » Post

Released 0.3! (0.3 Update)
Changes:
  • Relicense to MIT License.
  • Update to Minetest 5.0.0 Modding API.
  • Add ability to check ban for a player.
  • Clean up code, texts, and descriptions.
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
56independent_actual
Member
Posts: 452
Joined: Sun May 23, 2021 16:10
IRC: independent56
In-game: 56independent
Location: Girona Province
Contact:

Re: [Mod] Advanced Ban [advancedban] [0.1]

by 56independent_actual » Post

Krock wrote:
Thu Dec 25, 2014 09:18
How is this better than the default ban mod?
My sister and i share the same network but my sister keeps on being annoying, so it is important to ban her based on username.
Warnig: Al my laguage ekscept English is bad, includig Hungarian (magyàränoлиски), Spanish (esпagnyoл), and Russian (рÿсскïанöл).

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests