To use this write ranges like:
213.112.0.0-213.115.255.255;BBB
-- By IceCoder
-- Checks IP ranges
sBot = "-?-IPGuard-?-"
sRejectMessage = "Sorry, connections from your IP number is not allowed here. This hub is for 10Mbit users only. You are beeing redirected."
Allowip = {}
IpFile = "ip/ipranges.txt"
function Main()
frmHub:RegBot(sBot)
LoadIpList()
end
function NewUserConnected(curUser)
allowed = CheckIP(curUser.sIP)
if allowed == 0 then
curUser:SendData(sBot, sRejectMessage)
curUser:SendData("$ForceMove "..frmHub:GetRedirectAddress())
end
end
function CheckIP(sIP)
local s,e,s1,s2,e1,e2, ipa, ipb
ipa,ipb = ComputeIP(sIP)
for range,ab in Allowip do
_,_,s,e = strfind(range, "(%S+)-(%S+)")
s1,e1 = ComputeIP(s)
s2,e2 = ComputeIP(e)
if (tonumber(s1) <= tonumber(ipa)) and (tonumber(ipa) <= tonumber(s2)) then
SendToAll(sBot, "1 Right")
SendToAll(sBot, e1.." <= "..ipb.." "..ipb.." <= "..e2)
if (tonumber(e1) <= tonumber(ipb)) and (tonumber(ipb) <= tonumber(e2)) then
SendToAll(sBot, "2 Right")
return 1
end
end
end
return 0
end
function ComputeIP(sIP)
local a,b
_,_,a,b = strfind(sIP, "(%d+.%d+).(%d+.%d+)")
return a, b
end
function LoadIpList()
readfrom(IpFile)
while 1 do
local line = read()
if line == nil then
break
else
range = strsub(line, 1, strfind(line, ";")-1)
isp = strsub(line, strfind(line, ";")+1,-1)
Allowip[range] = isp
end
end
readfrom()
end
Little commercial ;),
depending on how many IP-Ranges you have.. above 10
the Logger is the fastest.
other question does your compute function really work?
. matches everything, you need 2 escape it %.
plop
it works but it is a syntax
until you get logger to precompute ranges.. calling it "the fastest" is not really accurate
anyway this doesnt work
nope tezlo its really faster, cause it, searches the IP's by 2^x search...
so like it only needs 10 runs do check if the IP is in 1024 IP-Ranges, beat that with a foreach function...
thats why the Logger is the fastest, IP-Range script around.. precomputing the IP's wouldn't make much difference, anymore.
You are the best c h i l l a !!!!
Good work whit all scripts...!!
Thx m8! ;)
//WickeD
the scripts works but if you write wrong in the txt file it gonna be a syntax
/ lol @ my english
thanks wicked, but wouldn't go so far me the best.. haha, but thanks anyway, first I thaught you were opium because of the little devil ;)..
IceCoder,
I checked you script a little and I haven't tested it but you compute func, is quite cool actually, I think it really works, but I think it will only work like this but dunno, haven't tested, yet..
curUser.sIP
ipa,ipb = ComputeIP(curUser.sIP)
for range,ab in Allowip do
_,_,s,e = strfind(range, "(%S+)-(%S+)")
s1,e1 = ComputeIP(s)
s2,e2 = ComputeIP(e)
if tonumber(s1)<= ipa and ipa <= tonumber(s2) and tonumber(e1)<=ipb and ipb<=tonumber(e2) then
end
end
function ComputeIP(sIP)
local a,b
_,_,a,b = strfind(sIP, "(%d+.%d+).(%d+.%d+)")
return a, b
end
but anyway the logger is faster ;)
but I prefer the compute func from patcezk, which is slightly better to understand and surely works
function ComputeIP(curIP)
local _,_,a,b,c,d = strfind(curIP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
if a and b and c and d then
return a*16777216 + b*65536 + c*256 + d
end
end
Thanks anyway :D
it works but you have to write right ranges in the txt file if you write wrong it gonna be a syntax
Do you know why no one has posted a IP/ISP Script in this forum? ?(
right.. last post on this subject
its not just how many runs..
but also what you need to do in each of them
and precomputing the ranges does make huge difference
i just tested with a table of 200 ranges and..
your raw tSearch performs the same as a plain search on precomputed values
the more ranges the better tSearch performs relatively
and obviously.. tSearch will perform best on a sorted table
edit.. actually logger is the fastest only when you have over 200 ranges
sorry to spoil your illusion but you dont want to lie to these fine people
nope never lie to them.. but you should maybe post the script you used.. or so..
no proof, and we can go on and on and on...
but I cam up with 10 cause then the logger needs,
3 searches for a 10 items big table + 3*2 computings
equals 9 funcs thats less than 10.
well I tested it again the tsearch func.. and let it compute a ip 2 twice with each search... just like the logger does... and results are you can't test it unless you have a real time OS. You got one, then I apologize...
but form the average runs I did... I had some weird results... normal search is about the same up to 100 search entries, my cpu time was always zero.. then on any type of search... above then.. it switches between zero and xE-5 and above 1000 entries then I see a difference between the searchalgo. and a normal search, well as said 100 times before the kernel fucks it up.
ends up to really start a battle we need a real time OS.
hehe tezlo post your script here so we can see :D
did you guys live me?? :O
Can someone post more IP checks here? :O
thx a lot thats the script i m looking for.
i have problem about sending mesages to main chat.
how can i disable it??
i mean how can i disabe for examle:
1 Right
0.0 <= 82.208 82.208 <= 255.255
2 Right
-- By IceCoder
-- Checks IP ranges
sBot = "-?-IPGuard-?-"
sRejectMessage = "Sorry, connections from your IP number is not allowed here. This hub is for 10Mbit users only. You are beeing redirected."
Allowip = {}
IpFile = "ip/ipranges.txt"
function Main()
frmHub:RegBot(sBot)
LoadIpList()
end
function NewUserConnected(curUser)
allowed = CheckIP(curUser.sIP)
if allowed == 0 then
curUser:SendData(sBot, sRejectMessage)
curUser:SendData("$ForceMove "..frmHub:GetRedirectAddress())
end
end
function CheckIP(sIP)
local s,e,s1,s2,e1,e2, ipa, ipb
ipa,ipb = ComputeIP(sIP)
for range,ab in Allowip do
_,_,s,e = strfind(range, "(%S+)-(%S+)")
s1,e1 = ComputeIP(s)
s2,e2 = ComputeIP(e)
if (tonumber(s1) <= tonumber(ipa)) and (tonumber(ipa) <= tonumber(s2)) then
if (tonumber(e1) <= tonumber(ipb)) and (tonumber(ipb) <= tonumber(e2)) then
return 1
end
end
end
return 0
end
function ComputeIP(sIP)
local a,b
_,_,a,b = strfind(sIP, "(%d+.%d+).(%d+.%d+)")
return a, b
end
function LoadIpList()
readfrom(IpFile)
while 1 do
local line = read()
if line == nil then
break
else
range = strsub(line, 1, strfind(line, ";")-1)
isp = strsub(line, strfind(line, ";")+1,-1)
Allowip[range] = isp
end
end
readfrom()
end
----------------------------------------
Thx meumeu :P
This is without:
1 Right
0.0 <= 82.208 82.208 <= 255.255
2 Right
Thats the bot everyone must use i use 10 ranges and no problem it ll grow up later. :D
hehe :D
Hi..
Can some one please post IP Range for/ISP [BBB]
I only want to have 10Mbit in my hub..
TY ppl ..
hello, i need a script which can automatically detect and ban the users who use fake IP . Please anyone post the scripts
suggest you try this one:
--Correct-IP-V.1 for Active users
--Idea by [aDe] , by c h i l l e r
--For TD4
function Main()
frmHub:EnableSearchData(1)
end
function DataArrival(curUser, data)
if (strsub(data, 1, 7) == "$Search") then
_,_,userIP_Port,_ = strfind( data, "$Search%s+(%S+)%s+(.*)" )
_,_,userIP,_ = strfind( userIP_Port, "(%S+):(.*)" )
IsIPnumber = gsub(userIP,"%p", "")
IsIPnumber = tonumber(IsIPnumber)
if IsIPnumber then
if userIP ~= curUser.sIP then
curUser:SendData("Please insert your correct Active IP address : "..curUser.sIP)
curUser:Disconnect()
end
end
end
end
How is it possible to have a Fake ip ? I mean Is it really possible to fake the ip ?
Ive just obtained a new isp contract with 10mb. I wish to allow only 10mb and or over to enter hub.
Ive been looking for ip ranges to add to the text file but have had no luck. Can anyone please assit me.
I just copied the -- By IceCoder
-- Checks IP ranges
omg, IceCoder :D , whats that for script? ;)