PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: bastya_elvtars on 01 January, 2005, 15:14:13

Title: ISP Blocker
Post by: bastya_elvtars on 01 January, 2005, 15:14:13
Requested in the other board. Inaccurate, but maybe someone can use it.

-- SimpleHostBlock by bastya_elvtars
-- warning: hostnames do NOT always resolve


blocked=
{
["u-szeged.hu"]=1, -- enter many hostnames, if you set 1, it will be blocked. Set to 0 if you wanna stop blocking it. (hmm this 1 is my hostname ;))

["hostname2"]=0,
}

block_partial=1 -- 1 to block partial ISP's, 0 to not.

partial={ -- should not contain the following chars:+$%[]()
-- rules for syntax are same as above
["VPN"]=1,
["LMFAO"]=0,

}


function NewUserConnected(user)
if tohostname(user.sIP) then
if blocked[tohostname(user.sIP)]==1 then
user:SendData("ISPChk","Your ISP/IP is not allowed here.")
user:Disconnect()
return 1
elseif block_partial==1 then
partialispchk(user)
end
end
end

function partialispchk(user)
local _,_,isp=tohostname(user.sIP)
for a,b in partial do
if b==1 and strfind(isp,a) then
user:SendData("ISPChk","Your ISP/IP is not allowed here.")
user:Disconnect()
return 1
end
end
end