PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: nEgativE on 14 March, 2005, 11:44:04

Title: IP Range Script
Post by: nEgativE on 14 March, 2005, 11:44:04
Hi there, could someone help with this script ?
I think it's well converted, but it doesn't work for me..

Tks in advance


-- Made By Nightlitch

Bot = "Cop"

Ranges = {}

function Main()

LoadIps()
end

function LoadIps()
local tmp = 0
local handle = io.open("Data/CLP.Ranges.dat","r")
line = handle:read()
while line do
tmp = tmp + 1
local s,e,ipr1,ipr2 = string.find(line,"(%S+)|(%S+)")
if ipr2 == nil then
SendToAll(Bot,"Error on line "..line)
end
local s,e,ipa1,ipb1,ipc1,ipd1 = string.find(ipr1, "(%d*).(%d*).(%d*).(%d*)")
local s,e,ipa2,ipb2,ipc2,ipd2 = string.find(ipr2, "(%d*).(%d*).(%d*).(%d*)")
si1 = CheckNumber(ipa1)..CheckNumber(ipb1)..CheckNumber(ipc1)..CheckNumber(ipd1)
si2 = CheckNumber(ipa2)..CheckNumber(ipb2)..CheckNumber(ipc2)..CheckNumber(ipd2)
Ranges[si1] = si2
line = handle:read()
end

end

function Blocked(userip)
local s,e,range1,range2,range3,range4 = string.find(userip,"(%d+).(%d+).(%d+).(%d+)")
checker = CheckNumber(range1)..CheckNumber(range2)..CheckNumber(range3)..CheckNumber(range4)

--SendToAll(Bot,"IP-Test..."..checker)

for i,p in Ranges do
local s,e,xstart = string.find(i, "(%d*)")
local s,e,xend = string.find(p, "(%d*)")

if checker > xstart and checker < xend then
collectgarbage()
io.flush()
return 1
else
end
end
end

function CheckNumber(number)
numbera = tonumber(number)
if numbera < 10 then
numbera = "00"..number
elseif numbera < 100 then
numbera = "0"..number
else
numbera = number
end
return numbera
end

function ChatArrival(User, Data)
if string.sub(data, 1, 8) == "$Version" then
if Blocked(user.sIP) == 1 then
user:SendData(Bot, "DC:CLP - IP Range Banido no Hub.")
user:SendData(Bot,""..user.sName..", d?vidas.. contacte-nos em: servidor.dc@gmail.com")
user:TimeBan(300)
user:Disconnect()
end
end
end

Title:
Post by: Madman on 14 March, 2005, 12:01:18
not tested...

change the ChatArrival to this
function VersionArrival(User, Data)
if Blocked(user.sIP) == 1 then
user:SendData(Bot, "DC:CLP - IP Range Banido no Hub.")
user:SendData(Bot,""..user.sName..", d?vidas.. contacte-nos em: [EMAIL]servidor.dc@gmail.com[/EMAIL]")
user:TimeBan(300)
user:Disconnect()
end
end
Title:
Post by: nEgativE on 14 March, 2005, 12:09:58
i guess not :(
Title:
Post by: Jelf on 14 March, 2005, 12:40:39
Try this one, I previously posted/converted HERE (http://board.univ-angers.fr/thread.php?threadid=3662&boardid=28&sid=0f16ec3b7b973d14af03b0a74ed5b0c7)
You would need a Guarding.P2P file to block IP's obviously.
Title:
Post by: nEgativE on 14 March, 2005, 13:43:59
QuoteOriginally posted by Jelf
Try this one, I previously posted/converted HERE (http://board.univ-angers.fr/thread.php?threadid=3662&boardid=28&sid=0f16ec3b7b973d14af03b0a74ed5b0c7)
Its based on the same script.
You would need a Ranges.DAT file to block IP's obviously

Hi Jelf, i'll try that one :)
What is the format of Ranges.dat file ? i tried a few but i get this syntax: Guardian.lua:68: table index is nil
Title:
Post by: Jelf on 14 March, 2005, 14:02:49
Whooops, I meant Guarding.P2P file placed in a folder named Guard.

The script with Ranges.Dat I did convert but it used the same resources so I deleted it and stuck with this one.

The format for Guarding.P2P file is peerguardian which is alot easier to find than the Ranges.dat one.

Hope this helps
Title:
Post by: nEgativE on 14 March, 2005, 16:53:16
Sorry, i did not understoud.. i meant how is the file edited, the IPs.. like

127.0.0.0|127.0.0.255
or
127.0.0.0-127.0.0.255

i had tried a few.. but with no sucess :(
Title:
Post by: Jelf on 14 March, 2005, 20:03:33
Ok like this

RIAA.NL AP2P:212.241.48.0-212.241.48.127

I get the list using Blocklist manager