Page 1 of 1

[Mod] Advanced Ban [advancedban] [0.3]

Posted: Wed Dec 24, 2014 14:25
by srifqi
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

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

Posted: Thu Dec 25, 2014 09:18
by Krock
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)

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

Posted: Thu Dec 25, 2014 16:50
by Pitriss
maybe you can make your command shorter..:)

for example /aban and add /akickban (/akban respectively) which will also kick player after banning him:)

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

Posted: Fri Dec 26, 2014 22:55
by Hybrid Dog
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

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

Posted: Mon Dec 29, 2014 05:43
by WebWolf
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.

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

Posted: Mon Dec 29, 2014 10:16
by srifqi
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

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

Posted: Wed May 27, 2015 06:54
by srifqi
Released 0.2! (Unban Update)
Changes:
  • Add method to unban player
  • Add chat command shortcut to ban IP

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

Posted: Wed Oct 03, 2018 17:52
by poikilos
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!

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

Posted: Thu Feb 07, 2019 12:46
by srifqi
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.

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

Posted: Thu Aug 08, 2019 16:35
by srifqi
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.

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

Posted: Mon Jul 11, 2022 16:17
by 56independent_actual
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.