Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ***********************************************************************************
- -- Nick/IP Range Bans *****************************************
- -- ***********************************************************************************
- NICKBANS = {}
- local write_nickbans = function()
- local f = io.open(minetest.get_worldpath()..'/.nickbans', "w")
- f:write(minetest.serialize(NICKBANS))
- io.close(f)
- end
- local gonfile = io.open(minetest.get_worldpath()..'/.nickbans', "r")
- if gonfile then
- local contents = gonfile:read()
- io.close(gonfile)
- if contents ~= nil then
- NICKBANS = minetest.deserialize(contents)
- end
- end
- local default_ban = minetest.ban_player
- function minetest.ban_player(playername)
- NICKBANS[playername] = true
- write_nickbans()
- return default_ban(playername)
- end
- IPRBANS = {}
- local add_ip_range = function(range)
- local ipr = string.split(range,'.')
- if table.getn(ipr) < 3 then return end
- if not IPRBANS[ipr[1]] then IPRBANS[ipr[1]] = {} end
- if not IPRBANS[ipr[1]][ipr[2]] then IPRBANS[ipr[1]][ipr[2]] = {} end
- if not IPRBANS[ipr[1]][ipr[2]][ipr[3]] then IPRBANS[ipr[1]][ipr[2]][ipr[3]] = true end
- end
- --add_ip_range('66.66.66') -- test range
- minetest.register_on_joinplayer(function(player)
- player = player:get_player_name()
- if NICKBANS[player] or string.match(player,"%d%d(%d+)") then -- or string.match(player,"Guest%d%d%d%d")
- minetest.ban_player(player)
- minetest.log("action", player.." banned [nick]")
- end
- local ip = string.split(minetest.get_player_ip(player),'.')
- if IPRBANS[ip[1]] and IPRBANS[ip[1]][ip[2]] and IPRBANS[ip[1]][ip[2]][ip[3]] then
- minetest.ban_player(player)
- minetest.log("action", player.." banned [ip-range]")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement