PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: VidFamne on 13 April, 2004, 15:03:40

Title: GeoIP script
Post by: VidFamne on 13 April, 2004, 15:03:40
Put up this in this forum too, cause I dont know which the right one :)
**Link removed**
Title: thanx !!
Post by: Hades on 14 April, 2004, 03:57:09
Top ten works fine!
...
However geo-ip that i waited so long for doesn't seenm to work in my hub:((
after +Country chatmessage:isn't in our records
Or should i use +Country ?
....
I'm running couple of scripst there possibly there might be a script conflict?
Title:
Post by: VidFamne on 14 April, 2004, 19:05:44
Hi Hades! :)

I dont know what you have expected from the GeoIP script.
But you just type +Country and then the name of a user,
to get the Country user from, and his/hers CountryCode.
Sorry if I've disapponted you.
Title:
Post by: yepyepyep4711 on 14 April, 2004, 20:00:11
GeoIP is working great.

I get the following error on top ten though:

Syntax error: attempt to perform arithmetic on local `min' (a nil value)
stack traceback:
   1:  function `Timemess' at line 283 [file `...ramme\PtokaX-0.330.b15.25.dbg\scripts\Top10.lua']
   2:  function `DataArrival' at line 141 [file `...ramme\PtokaX-0.330.b15.25.dbg\scripts\Top10.lua']
Title:
Post by: VidFamne on 14 April, 2004, 20:18:24
I'm not sure about this, but I think it is when you add the script when you still in the hub.
Then your time will be nil.
To solve this is to reconnect to the hub.
Dont have any other solution for it, yet. ;)
Title:
Post by: xfiles on 14 April, 2004, 20:41:51
Hi VidFamne,

GeoIP is a very usefull script.
I?ve been looking for something like that for months.
Now i found it.  :))
Could you just change a tiny thing!?
At the moment the script sends the message in the main. But i would like to get the message in pm.
Is that possible?
I tryed to change this:  SendToNick   into SendPmToNick.
But it seems not to work.

thx a lot m8
Title:
Post by: VidFamne on 14 April, 2004, 20:56:27
Well, the only one who can see the message, is the one who
typed the command.
So it is as private it can be. :)
And for the SendPmToNick I have to declare a global bot,
and thats unnecessary IMHO.
Title:
Post by: VidFamne on 15 April, 2004, 00:28:49
Ehum, I think I missunderstood you. Sorry :)
Thought you mean i would change the script as it is now.
But feel free to change your script  in your way.
You could put this in function Main();

globals().Bot="GeoIpBot"
frmHub:RegBot(Bot)

and change this;
SendToNick(curUser.sName,"**** "..arg.." isn't in our records****")
and this;
SendToNick(curUser.sName,"**** "..arg.." is sitting on localhost")
and this;
SendToNick(curUser.sName,"**** "..arg.." is from "..C.." and have CountryCode ["..CC.."]")

to this;
SendPmToNick(curUser.sName,Bot,"**** "..arg.." isn't in our records****")
and this;
SendPmToNick(curUser.sName,Bot,"**** "..arg.." is sitting on localhost")
and this;
SendPmToNick(curUser.sName,Bot,"**** "..arg.." is from "..C.." and have CountryCode ["..CC.."]")

 

Good luck :)

Title:
Post by: pHaTTy on 15 April, 2004, 04:49:43
elo just cleaned a little (was very bored) hope ya donnot mind :-)

--By VidFamne (2004-04-07)
--A first try to do a GeoIp-script
--With a very fast search algorithm on big tables :)
--Type +Country and get the Country and CountryCode from an User
--The tGeoIpRange.txt is very big ( about 5.6 MB ) as I have ripped from GeoIPCountryCSV
--Hope its uptodate :)

function Main()
globals().tGeoIpRange={}
globals().tGeoIpRangefile="tGeoIpRange.txt"
dofile(tGeoIpRangefile)
end

function DataArrival(user, data)
data=strsub(data,1,-2)
local s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s*(%S*)" )
if cmd == "+Country" then
if GetItemByName(arg) then
SendToNick(user.sName,"**** "..arg.." isn't in our records****"); return nil;
end;
local compIp = ComputeIP(nick.sIP)
if compIp == 2130706433 then
SendToNick(user.sName,"**** "..arg.." is sitting on localhost");return 1;
else; local C, CC = tSearchCountry(compIp)
SendToNick(user.sName,"**** "..arg.." is from "..C.." and have CountryCode ["..CC.."]")
return nil;
end
end
end

function ComputeIP(IP)
local _,_,a,b,c,d = strfind(IP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
if a and b and c and d then
return a*16777216 + b*65536 + c*256 + d
end
end

----the Binary Search Algo----40

function tSearchCountry(num)
local num = tonumber(num)
local C = ""; local CC = "";
local table=tGeoIpRange
local low = 1; local high = getn(table)

for i = low, high-low+1 do
if  table[i][1] <= num and num <= table[i][2]  then
local C = table[i][4]; local CC = table[i][3]  
elseif table[i][1] > num then; high = floor((high+low)/2)-1
else low = floor((high+low)/2)+1; end
end; return C,CC
end

--------------------------VidFamne
Title:
Post by: VidFamne on 15 April, 2004, 12:44:53
No, I dont mind at all.
Everyone should feel free to code in his own coding style.
You have yours, moNo,tezlo has his and its like a fingerprint you cant escape from. :) Lol...
And I have mine, perhaps a little sloppy and recycled, but I do what I can.
Here it is;
--By VidFamne (2004-04-07)
--A first try to do a GeoIp-script
--With a very fast search algorithm on big tables :)
--Type +Country and get the Country and CountryCode from an User
--The tGeoIpRange.txt is very big ( about 5.6 MB ) as I have ripped from GeoIPCountryCSV,
--with help from RabidWombat's serialisation function
--Hope its uptodate :)




function Main()
globals().tGeoIpRange={}
globals().tGeoIpRangefile="tGeoIpRange.txt"
dofile(tGeoIpRangefile)
end

function DataArrival(curUser, sData)

      sData=strsub(sData,1,-2)
      s,e,cmd,arg = strfind( sData, "%b<>%s+(%S+)%s*(%S*)" )
if (cmd=="+Country") then
  local nick = GetItemByName(arg)
if nick == nil then
SendToNick(curUser.sName,"**** "..arg.." isn't in our records****") return 1 end
local compIp = ComputeIP(nick.sIP)
if compIp==2130706433 then
SendToNick(curUser.sName,"**** "..arg.." is sitting on localhost") return 1 else
local C, CC = tSearchCountry(compIp)
SendToNick(curUser.sName,"**** "..arg.." is from "..C.." and have CountryCode ["..CC.."]") return 1
end
end
end

function ComputeIP(IP)
local _,_,a,b,c,d = strfind(IP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
if a and b and c and d then
return a*16777216 + b*65536 + c*256 + d
end
end

----the Binary Search Algo----40

function tSearchCountry(num)
  local num = tonumber(num)
  local C = ""
  local CC = ""
  local table=tGeoIpRange
  local low=1
  local high=getn(table)

for i = low, high-low+1 do
if  table[i][1] <= num and num <= table[i][2]  then
C = table[i][4]
CC = table[i][3]  
elseif table[i][1] > num then high = floor((high+low)/2)-1
else low = floor((high+low)/2)+1
end
end  
return C,CC
end

--------------------------VidFamne
Title:
Post by: yepyepyep4711 on 15 April, 2004, 13:47:08
wow, this script is using huge amounts of memory :)
the VidFamme version before last had grown to 45 MB.
The last one is already at 30 MB right after starting the script.
Title:
Post by: VidFamne on 15 April, 2004, 23:23:06
Yeah, its a real biggie  :D
I've closed the links, cause I cant host the files anymore :(
Title:
Post by: yepyepyep4711 on 15 April, 2004, 23:30:36
hope the hosting problem is only temporary :(

Any chance to see a version were it wouldn't take so much memory? After I day running it has grown from 30MB to 45MB.

How about loading the txt only when needed, and flushing afterwards?
Title: Problemzz with hosting??
Post by: Hades on 16 April, 2004, 01:10:16
Knock on my PM!!
This script project i will host it on my private site for free!!
Just let me know if u want!
..........
Can someone add some code to it?
So it shows as welcome message at userenter there is
x useras from xxxx
y users from bala bla bla hope u get it!
Title:
Post by: VidFamne on 16 April, 2004, 04:41:10
Yes, Please do :)
here some tiny change to the binary search algo;
----the Binary Search Algo----40

function tSearchCountry(num)
  local num = tonumber(num)
  local C = ""
  local CC = ""
  local table=tGeoIpRange
  local low=1
  local high=getn(table)

for i = low, high-low+1 do
if  table[i][1] <= num and num <= table[i][2]  then
C = table[i][4]
CC = table[i][3]
break end  
if table[i][1] > num then high = floor((high+low)/2)-1
else low = floor((high+low)/2)+1
end
end  
return C,CC
end

--------------------------VidFamne
Title:
Post by: pHaTTy on 16 April, 2004, 04:58:33
QuoteOriginally posted by VidFamne
Yes, Please do :)
here some tiny change to the binary search algo;
----the Binary Search Algo----40

function tSearchCountry(num)
  local num = tonumber(num)
  local C = ""
  local CC = ""
  local table=tGeoIpRange
  local low=1
  local high=getn(table)

for i = low, high-low+1 do
if  table[i][1] <= num and num <= table[i][2]  then
C = table[i][4]
CC = table[i][3]
break end  
if table[i][1] > num then high = floor((high+low)/2)-1
else low = floor((high+low)/2)+1
end
end  
return C,CC
end

--------------------------VidFamne

you might wanna keep the c n cc local, they start local and become global

----the Binary Search Algo----40

function tSearchCountry(num)
local num = tonumber(num)
local C = ""; local CC = ""
local table=tGeoIpRange
local low = 1; local high=getn(table)

for i = low, high-low+1 do if  table[i][1] <= num and num <= table[i][2] then
local C = table[i][4]; local CC = table[i][3]
break; end; if table[i][1] > num then high = floor((high+low)/2)-1
else low = floor((high+low)/2)+1; end;
end; return C,CC
end

--------------------------VidFamne
Title:
Post by: VidFamne on 16 April, 2004, 05:06:58
Yes ofcorse
That Would be an even better improvment.
But sorry to say, its not function properly:(
Thanks anyway Phatty :)
Title:
Post by: tezlo on 16 April, 2004, 15:01:07
no. they dont "become global"
you declare them once as local to the function and they stay that way
and whats with making the code unreadable?
Title:
Post by: pHaTTy on 16 April, 2004, 15:04:58
QuoteOriginally posted by tezlo
no. they dont "become global"
you declare them once as local to the function and they stay that way
and whats with making the code unreadable?

well actually ur wrong i done some testing and they do become global after accidently finding that when writing a script, globally calling a local varaiblethat was localaised in a function, and its not unreadable, i just cant use it when the lines are all the way down the page, sop its a habit to keep everything together

similar locals go together and as for ifs, like to keep em close to the old end if they have sep end, less cr*pcode to look at, and easier for me to read tbh, so if ya cant read that u need ot start practicing

n fact when i run hub later, i will probby make a script to show ya, but tbh im pretty pizzed off atm so ima go...
:)
Title:
Post by: pHaTTy on 16 April, 2004, 15:11:54
QuoteOriginally posted by VidFamne
Yes ofcorse
That Would be an even better improvment.
But sorry to say, its not function properly:(
Thanks anyway Phatty :)

i will run test hub later n see what mistake i made heh
Title:
Post by: tezlo on 16 April, 2004, 15:32:57
right..function test()
local five
five = 5
end

test()
if five == nil then
SendToAll(">> see?!")
end
Title:
Post by: VidFamne on 16 April, 2004, 17:06:44
That was good to hear that it stays local :)
Another thing I was thinking of;
the limit and steps are evaluated only once, before the loop starts, in a for loop, so this must be more adequate? ;
----the Binary Search Algo----40

function tSearchCountry(num)
  local num = tonumber(num)
  local C = ""
  local CC = ""
  local table=tGeoIpRange
  local low=1
  local high=getn(table)

for i = low, getn(table) do
if  table[i][1] <= num and num <= table[i][2]  then
C = table[i][4]
CC = table[i][3]
break end  
if table[i][1] > num then high = floor((high+low)/2)-1
else low = floor((high+low)/2)+1
end
end  
return C,CC
end

--------------------------VidFamne
**Edit; changed it again :)
Title:
Post by: VidFamne on 18 April, 2004, 02:42:17
Tiny change to the binary search algo.
Have removed the local table, cause there is alredy declared an global table, and that's IMHO, enough. :D
Dont know if this gain any performance.
But on my little test hub, I cant see that G.C. rise a singel byte :)--By VidFamne (2004-04-07)
--A first try to do a GeoIp-script
--With a very fast search algorithm on big tables :)
--Type +Country and get the Country and CountryCode from an User
--The tGeoIpRange.txt is very big ( about 5.6 MB ) as I have ripped from GeoIPCountryCSV,
--with help from RabidWombat's serialisation function
--Hope its uptodate :)
--Tiny change in the B.S.Algo :) (2004-04-18)




function Main()
globals().tGeoIpRange={}
globals().tGeoIpRangefile="tGeoIpRange.txt"
dofile(tGeoIpRangefile)
end

function DataArrival(curUser, sData)

      sData=strsub(sData,1,-2)
      s,e,cmd,arg = strfind( sData, "%b<>%s+(%S+)%s*(%S*)" )
if (cmd=="+Country") then
  local nick = GetItemByName(arg)
if nick == nil then
SendToNick(curUser.sName,"**** "..arg.." isn't in our records****") return 1
end
local compIp = ComputeIP(nick.sIP)
if compIp==2130706433 then
SendToNick(curUser.sName,"**** "..arg.." is sitting on localhost") return 1
else
local C, CC = tSearchCountry(compIp)
SendToNick(curUser.sName,"**** "..arg.." is from "..C.." and have CountryCode ["..CC.."]")
return 1
end
end

end

function ComputeIP(IP)
local _,_,a,b,c,d = strfind(IP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
if a and b and c and d then
return a*16777216 + b*65536 + c*256 + d
end
end

----the Binary Search Algo----40

function tSearchCountry(num)
  local num = tonumber(num)
  local C = ""
  local CC = ""
  local low=1
  local high=getn(tGeoIpRange)

for i = low, getn(tGeoIpRange) do
if  tGeoIpRange[i][1] <= num and num <= tGeoIpRange[i][2]  then
C = tGeoIpRange[i][4]
CC = tGeoIpRange[i][3]
break
end  
if tGeoIpRange[i][1] > num then
high = floor((high+low)/2)-1
else low = floor((high+low)/2)+1
end
end  
return C,CC
end

--------------------------VidFamne
Title:
Post by: Xico on 18 April, 2004, 20:48:18
I'm very new to this world, so just a question: where can I find the file "tGeoIpRange.txt" or information to generate it?

This is a very useful script, and a very good shearch rutine.

Thanks
Title:
Post by: xfiles on 18 April, 2004, 23:03:17
Oi Xico,

essa file posso-te mandar se quiseres. Manda-me uma pm ou e-mail.
Esse script ? bom para veres de onde v?m os users e d?-te tamb?m o c?digo do pa?s.
Se tens um Hub aonde o pessoal tem que por o c?digo do pa?s no nick, esse script pode-te ajudar.

Cumprimentos :)
Title:
Post by: Skrollster on 21 April, 2004, 15:35:39
QuoteOriginally posted by (uk-kingdom)pH?tt?
well actually ur wrong i done some testing and they do become global after accidently finding that when writing a script, globally calling a local varaiblethat was localaised in a function, and its not unreadable, i just cant use it when the lines are all the way down the page, sop its a habit to keep everything together

similar locals go together and as for ifs, like to keep em close to the old end if they have sep end, less cr*pcode to look at, and easier for me to read tbh, so if ya cant read that u need ot start practicing

n fact when i run hub later, i will probby make a script to show ya, but tbh im pretty pizzed off atm so ima go...
:)

function test()
local aVariable = "Just a test"
if aVariable then
local aVariable = "Just a test again"
write(aVariable)
end
write(aVariable)
end

test()
write(aVariable)

--> Just a test again
--> Just a test
--> error a nil value
Title:
Post by: Skrollster on 21 April, 2004, 15:45:52
for all out there who wants to update the tGeoIpRange.txt

download the cvs (http://www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip) file from: http://www.maxmind.com/app/geoip_country

use a texteditor that can handle regular expressions and

replace:

^("[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]",)("[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]",)("[0-9]+",)("[0-9]+",)("[A-Z][A-Z0-9]")(,".+")$

with:

{\3\4\5\6},

addthis in the begining of the file:
tGeoIpRange = {
and
}
in the end
Title:
Post by: chill on 21 April, 2004, 19:09:47
hmm.. just looking at the search func, what it actually does is run though the table with from i = 1,getn(table)
I sorta don't see where the bost is ;).
Wonder why nobody noticed, lol.
 you might wanna try this

function tSearch(table,comIP)
local iStart,iEnd,iMid = 1,getn(table),0
while (iStart <= iEnd) do
iMid = floor((iStart+iEnd)/2)
if (table[iMid][1] <= comIP) and (table[iMid][2] >= comIP) then
return table[iMid]
elseif (table[iMid][1] > comIP) then
iEnd = iMid - 1
elseif (table[iMid][1] < comIP) then
iStart = iMid + 1
end
end
return("NOTFOUND")
end
Title:
Post by: Skrollster on 21 April, 2004, 20:53:27
this is just a matter of programing style.. but since it has been a topic here at the forum latly i'd like to show how i would have solved it the same way as chill.. just a diffrent syntax instead of while i use repeat

function tSearch(table,comIP)
local iStart = 1
local iEnd = getn(table)
repeat
iMid = floor((iStart+iEnd)/2)
if (table[iMid][1] <= comIP) and (table[iMid][2] >= comIP) then
return table[iMid]
elseif (table[iMid][1] > comIP) then
iEnd = iMid - 1
elseif (table[iMid][1] < comIP) then
iStart = iMid + 1
end
until iStart <= iEnd
return("NOTFOUND")
end
Title:
Post by: VidFamne on 21 April, 2004, 21:39:50
Quotefor loops are quite a bit faster than while loops, since they have specialized virtual machine instructions
This information was written for Lua, pre v4.0 -- Nick Trout
Title:
Post by: NotRabidWombat on 21 April, 2004, 21:54:10
Yes, but the algorithm itself will make the difference.

Linear searching will take O(n).
Binary searching will take O(lg(n)).

The speed increase in a for loop over a while loop is a constant, which is irrelevant to any time equation.

-NotRabidWombat
Title:
Post by: VidFamne on 21 April, 2004, 22:23:58
QuoteYes, but the algorithm itself will make the difference.
Yes, of course :)

And to chill; I did not  code it like this; i=1,getn(table)
I code it like this; i=low,getn(table)
And thats a hell of a difference
Title:
Post by: NotRabidWombat on 21 April, 2004, 22:35:22
"And to chill; I did not code it like this; i=1,getn(table)
I code it like this; i=low,getn(table)"

They are the same in this case.

for i = low, getn(tGeoIpRange) do

'i' is a number, and therefore all assignments are copies of value, not reference. So you intialize 'i' as low (or 1) and 'i' is incremented until the length of tGeoIpRange. If you change low or high in the for loop, 'i' will not change. So you are performing a linear search.

Makes you miss pointers, eh?

-NotRabidWombat
Title:
Post by: VidFamne on 22 April, 2004, 00:01:59
Yepp, you are absolutly right.  :O
Thank you guys for pointing this out for me :)
I'm still learning alot.
Here then;--By VidFamne (2004-04-07)
--A first try to do a GeoIp-script
--With a very fast search algorithm on big tables :)
--Type +Country and get the Country and CountryCode from an User
--The tGeoIpRange.txt is very big ( about 5.6 MB ) as I have ripped from GeoIPCountryCSV,
--with help from RabidWombat's serialisation function
--Hope its uptodate :)
--Change in the B.S.Algo :) (2004-04-21)




function Main()
globals().tGeoIpRange={}
globals().tGeoIpRangefile="tGeoIpRange.txt"
dofile(tGeoIpRangefile)
end

function DataArrival(curUser, sData)

      sData=strsub(sData,1,-2)
      s,e,cmd,arg = strfind( sData, "%b<>%s+(%S+)%s*(%S*)" )
if (cmd=="+Country") then
  local nick = GetItemByName(arg)
if nick == nil then
SendToNick(curUser.sName,"**** "..arg.." isn't in our records****") return 1
end
local compIp = ComputeIP(nick.sIP)
if compIp==2130706433 then
SendToNick(curUser.sName,"**** "..arg.." is sitting on localhost") return 1
else
local C, CC = tSearchCountry(compIp)
SendToNick(curUser.sName,"**** "..arg.." is from "..C.." and have CountryCode ["..CC.."]")
return 1
end
end

end

function ComputeIP(IP)
local _,_,a,b,c,d = strfind(IP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
if a and b and c and d then
return a*16777216 + b*65536 + c*256 + d
end
end

----the Binary Search Algo----40

function tSearchCountry(num)
  local num = tonumber(num)
  local C = ""
  local CC = ""
  local low=1
  local mid = tonumber(mid)
  local high=getn(tGeoIpRange)

while low <= high  do
mid = floor((low+high)/2)
if  tGeoIpRange[mid][1] <= num and num <= tGeoIpRange[mid][2]  then
C = tGeoIpRange[mid][4]
CC = tGeoIpRange[mid][3]
break
end  
if tGeoIpRange[mid][1] > num then
high = mid-1
else low = mid+1
end
end  
return C,CC
end

--------------------------VidFamne
**Edit; removed some testing code :D
Title:
Post by: VidFamne on 22 May, 2004, 16:29:27
A try to reduce the memory usage of the GeoIP-script.
Download >>here<< (ftp://vidfamne.myftp.org/dl/GeoIP-ver.3.rar) if you feel for it :)
Title:
Post by: chill on 23 May, 2004, 14:07:20
done another version 2.5 MB mem, average search time around 0.7 sec.

would be faster if I could jump to certain bytes of a string, maybe someone knows how, but at least it does not read from disc each query.

hmm I think I'll try strsub, hope its fast on big strings we'll see.

<-GeoIP-> Searched for: 214.0.0.0 Used Time: 1.45 sec
Range: 214.0.0.0-216.0.47.255, Country: United States, Countrycode: US

 <-GeoIP-> Searched for: 40.0.0.0 Used Time: 0.09 sec
Range: 28.0.0.0-40.255.255.255, Country: United States, Countrycode: US

GeoIP by chill (http://www.bbfree.com/cannaforum/index.php?act=Attach&type=post&id=996)
Title:
Post by: VidFamne on 23 May, 2004, 14:26:21
Nice work, chill :)
Think its always a choice between memory-usage and search-time.
My version use about 5.3MB mem and an average search-time at 0.1-0.2 sec. (on my my computer,Duron 1.2GHz, that is)
Hope I test it properly, fingers crossed ;D
Title:
Post by: chill on 23 May, 2004, 14:53:29
great vidfamme, but forget the old one check out this one ;)

[14:46] <-GeoIP-> Serached for: 40.0.0.0 Used Time: 0.00 sec
Range: 28.0.0.0-40.255.255.255, Country: United States, Countrycode: US
[14:47] <-GeoIP-> Searched for: "40.0.0.0" Used Time: 0.00 sec
Range: 28.0.0.0-40.255.255.255, Country: United States, Countrycode: US
[14:47] <-GeoIP-> Searched for: "217.0.0.0" Used Time: 0.00 sec
Range: 217.0.0.0-217.5.129.255, Country: Germany, Countrycode: DE
[14:47] <-GeoIP-> Searched for: "213.0.0.0" Used Time: 0.00 sec
Range: 213.0.0.0-213.0.255.255, Country: Spain, Countrycode: ES

use 5 mb of memory , but only reads from disk at startup.

Geo IP V 002 (http://www.bbfree.com/cannaforum/index.php?act=Attach&type=post&id=997)
Title:
Post by: chill on 23 May, 2004, 20:51:52
last version for today, but this one is already maximum optmised I think.
we'll see how many more to come

geo ip v 003 (http://www.bbfree.com/cannaforum/index.php?act=Attach&type=post&id=1000)
Title:
Post by: VidFamne on 23 May, 2004, 22:20:35
Really nice work chill ;)
Its going to be hard to beat this.
Next step would perhaps be a database in Binary format. If it would be do-able.
Title:
Post by: chill on 24 May, 2004, 18:20:55
thx vidfamne :)

yepp also thaught of extending it, as i like challenges
I'll see what I can come up with.
Title:
Post by: VidFamne on 24 May, 2004, 23:43:51
I come up with this;
mem < 100 KiB , search-time < 0.1 sec.
precompiled database files,
some changes in code,
borrow some ideas from chill :)
Download from the  Script Archive hosted by Optimus, if you like. ;)
Please report if there is some bugs.
Title:
Post by: [PT]CableGuy on 25 May, 2004, 00:47:44
WOW !!!! Awesome !!!  :D
You've manage to accomplish only 100kb    of mem , when in the 1st post of this thread...it was 30Mb   . 8o
Great Stuff and excelent optimization !!! Keep up with you're excelent work. :]
I think this script will be "a key script" for Hub-Link Networks (http://hub-link.sourceforge.net) , in a near future. :P

I've found similar services but some of them have city also.
I mean , the script indicates the IP , Country and the City !!! :))
Is this very dificult ? Were can we get "those kind" of databases ? Am i dreaming loud ?:rolleyes:
Title:
Post by: nEgativE on 25 May, 2004, 04:32:02
Nice work !!! :)
Title:
Post by: chill on 25 May, 2004, 09:16:34
yepp really great :), one big pro for compiling I'd say,  why not now compile the whole table and load it at once, then I guess your script will be unbeatable, but now I think I can forget about the string db, well not quite I'll still do some comparison with, only tbales containing string and see  what usues less mem.
Unfortunatly if you compile a string you don't have that memory effect :(.

cableguy is there a way to compile tables when you just built them? or will hub link only need, sone fixed up tables?
Title:
Post by: chill on 25 May, 2004, 19:40:00
vidfamne, hehe, your code looks dunno... little irritating, I missed the table = nil and the collectgarbage(),

gotta take that pro away again for compiling.

I thaught compiling numbers would bring less memory,
but it doesn't matter, as I just found out, at least now the string db is not totally useless :))).
Title:
Post by: VidFamne on 25 May, 2004, 23:21:51
Hehe, Yeah I thought you missed that, but its the cause of
briging the mem down.
The precompiling, is only for the reading in,
in dofile()-part, so it would be a little, little faster.
Please keep up your good work on string db. :)
Title:
Post by: chill on 25 May, 2004, 23:42:53
Well you got your aim for sure, < 100kb, I guess you can't get below that, and yepp I just coded some morefor string db, take a look in the development section and tell me what you think if you got some time.
Title:
Post by: VidFamne on 27 May, 2004, 00:32:00
Thanks for the praise, [PT]CableGuy.  :))
About the GeoIP City, it wouldnt be any difficulties  to do that,
if we only could find any free database.
But until then its kinda hard.
Title:
Post by: [PT]CableGuy on 27 May, 2004, 01:08:44
QuoteOriginally posted by VidFamne
...But until then its kinda hard....
What i thought... :(
No problem...if i find one free , "ill be back". :D

QuoteOriginally posted by chill
...is there a way to compile tables when you just built them? or will hub link only need, sone fixed up tables?
I didn't understood you're question very wel....sorry.
The main problem is the database size , wich is 2Mb for countrys and 32Mb with citys also.
I think it's best , to use this script in each hub connected to the Hub-Link network.
Otherwise , like an "alternative" (extra) feature of Hub-Link....
...BUT , it all depends on "it's creater" , HaArD  !!!! ;)
Title:
Post by: chill on 27 May, 2004, 10:05:55
oh now i got ya, alright, well I wouldn't care about 32 MB, but my guess is that its way more, but tell me the site where to download the IP-ranges with city, and I'll try to reduce memory used by lua as much as i can.
And maybe split the table like vidfamne does into 10 tables then it will be only a 10th of the reduced memory, we'll see.
Title:
Post by: [PT]CableGuy on 28 May, 2004, 02:42:46
QuoteOriginally posted by chill
...but tell me the site where to download the IP-ranges with city...
:( I'm sorry. "Those" DataBases are NOT for free.
I don't even know how it works since i dont have 100$$$ right now. :(
AnalyseSpider.com - IP-Country-Region-City mapping Database (http://www.analysespider.com/ip2country/IP-COUNTRY-REGION-CITY.html)


This one , claims to have: (199$$$) :(
"Database size 30 MB and contains details of over 140 million of Ip addresses".
Ipmessages.com Country & ISP by IP Address (http://www.ipmessages.com/download/paid/ipisp.asp)


I've found this one and it's free: :D (save it as an html file)
 
     
 
   
     
   

They have flags also !!!! Unfortunatly , no database... :(
Title:
Post by: chill on 28 May, 2004, 11:25:41
I also searched the net, and to have constant access to a updated db, is bets to query the whois databases, since they get updated every day and its for free.
else I think country is enough.
Title:
Post by: [PT]CableGuy on 28 May, 2004, 14:36:56
QuoteOriginally posted by chill
...else I think country is enough....
Well , if were talking about "internacional networks" , i must agree with you. :D

BUT...can you imagine , if in a "nacional hub" , you could discover "real neighboors" in the same hub ?
I mean..."Hey , you are from Lisbon to...probably we could meet sometime ?"  :D

This should be (also) awesome to "design a map" of "nacional users connectivity". :rolleyes:
And use it , to make "nacional statistics" of our users.
I now , i'm probably "thinking loud" and abusing from "you scripters"....
...but ideias come for free and i love to share them. :]

Thanks again , for this amazing script and for all "yours" dedication on this forum.  :D
Title:
Post by: chill on 28 May, 2004, 16:15:45
mem 13 MB
need time to startup at first but then its fast
only reads from disk once

geoIP v 004 (http://www.bbfree.com/cannaforum/index.php?act=Attach&type=post&id=1004)
Title:
Post by: Sudds on 28 May, 2004, 18:06:10
looks good im gonna try it but them memory is alot lol does it use much bandwith?
Sudds
Title:
Post by: chill on 28 May, 2004, 19:38:15
Sudds, if you look up in this thread there is a less memory wasting script, but it reads from disc, each time you query a IP, so you can descide yourself, mem and performance vs. less mem and less performance,
its a choice for what it should do, like if you show users country on connect, I would pick more mem, if you only need it a few times per day I'd choose less mem.

Ahm and the bandwidth used is the text sent, shouldn't be much
Title:
Post by: Herodes on 12 June, 2004, 18:22:42
I was thinking something about this script as I was going throught the thread ....

Would it be possible for the GeoIp tables to be eliminated at a counter progressive way ...

To give what I mean in a better way lets take an example ...

Lets say there is this Public Hub that is based for example in Italy and
it mainly receives users/ips from Italy ...
Shouldn't the ips from China, if not used then
be erased 'gradualy' and at the end if they are not used at some set time period they should be eliminated ...
A simple overwrite of the tables would then be enough to bring them back ...

If a Chinese user logs on then, instead of
the GeoIp info (that would in other case appear),
appears his IP ...
Then for curiosity It could be taken up to the curious to resolve ... :D

Basically I am talking about adaptational GeoIp list.
That adapts by removing "reduntant"(not used) Ip/Ip ranges
 in order to free up mem ..

I hope its clear ..
Title:
Post by: VidFamne on 15 June, 2004, 21:41:15
Here's a little extended GeoIP script.
Its exprimental, so be aware,  it might stress really busy hubs;--GeoIP-script by VidFamne (2004-05-25)
--Type +Country or and get the Country and CountryCode from a User
--Type +TopCountry to get Country Stats.
--Added a small welcome message, which show how many compatriot they've got in hub.
--The GeoIP database is from MaxMind GeoIP database GeoIPCountryCSV


function Main()
tCnumb = {}
f = "GeoIPtables/Cnumb.txt"
OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
dofile(f)
end

function OnExit()
save(f, tCnumb)
end

function DataArrival(curUser, sData)
      local s,e,cmd,arg = strfind( sData, "^%b<>%s+(%S+)%s*(%S*)|$" )
if (cmd=="+TopCountry") then
local curtime = date()
  SendToNick(curUser.sName,"\r\n")
          SendToNick(curUser.sName,"\tTOP COUNTRY\t\t("..curtime..")")
  SendToNick(curUser.sName,strrep("=-",34))
          local Index = sorting(tCnumb)
            for i = 1, Index.n do
              local key = Index[i]
              SendToNick(curUser.sName, "**** "..i.." :   "..format("%-6s %-12s %-6s","~~~",tCnumb[key],key))
              SendToNick(curUser.sName,strrep("-",90))
if i>=15 then break end            
          end
return 1
elseif (cmd=="+Country") then
  local T, nick, compIp = clock(), GetItemByName(arg), 0
if nick then
compIp = ComputeIP(nick.sIP)
elseif strfind(arg,"^%d+%.%d+%.%d+%.%d+") then
compIp = ComputeIP(arg)
else
SendToNick(curUser.sName,"**** "..arg.." isn't in our records****") return 1
end
if compIp==2130706433 then
SendToNick(curUser.sName,"**** "..arg.." is sitting on localhost") return 1
end
local C, CC = tSearchCountry(compIp)
if C == "" then
SendToNick(curUser.sName,"**** "..arg.." isn't in our records****") return 1
else
SendToNick(curUser.sName,"****SearchTime; "..format("%3.2f",(clock()-T)).." sec.")
SendToNick(curUser.sName,"**** "..arg.." is from "..C.." and have CountryCode ["..CC.."]")
return 1
end

end
end

function sorting(table)
  local index = {n=0}
  foreach(table, function(key, value) tinsert(%index, key) end)
  local func = function(a, b) return %table[a] > %table[b] end
  sort(index, func) return index
end

function NewUserConnected(curUser)
local compIp = ComputeIP(curUser.sIP)
local C = tSearchCountry(compIp)
tCnumb[C] = tCnumb[C] or 0
tCnumb[C] = tCnumb[C] + 1
local Countn = tCnumb[C]-1
SendToNick(curUser.sName," Hello "..curUser.sName.."! You're from "..C.." and You have "..Countn.." compatriot in this hub.")
curUser:SendData("Sending you this hubs normal user-command. Right-klick on hub tab or userlist.|$UserCommand 255 7|$UserCommand 0 1|$UserCommand 1 1 Get Country Stats.$<%[mynick]> +TopCountry||")
end

function UserDisconnected(curUser)
local compIp = ComputeIP(curUser.sIP)
local C = tSearchCountry(compIp)
tCnumb[C] = tonumber(tCnumb[C]) - 1
end

function save(f, table)
local f = openfile(f,"w+")
local table = tCnumb
write(f, "tCnumb = {\n")
for key, value in table do
write(f, '\t["'..key..'"] = '..value..',\n')
end
write(f, "\t}")
closefile(f)
end


function tSearch(nr)

  local tGeoIpRangefile = ""
  local nr = tonumber(nr)
  local tTables = { [1] = { [1] = "GeoIPtables/1.lua", [2] = 33996344, [3] = 1081403871 },
         [2] = { [1] = "GeoIPtables/2.lua", [2] = 1081403872, [3] = 2212298751 },
           [3] = { [1] = "GeoIPtables/3.lua", [2] = 2212364288, [3] = 3233791231 },
           [4] = { [1] = "GeoIPtables/4.lua", [2] = 3233791232, [3] = 3262479610 },
           [5] = { [1] = "GeoIPtables/5.lua", [2] = 3262479611, [3] = 3278943819 },
           [6] = { [1] = "GeoIPtables/6.lua", [2] = 3278943820, [3] = 3389026559 },
           [7] = { [1] = "GeoIPtables/7.lua", [2] = 3389026560, [3] = 3480612351 },
           [8] = { [1] = "GeoIPtables/8.lua", [2] = 3480612352, [3] = 3559682095 },
           [9] = { [1] = "GeoIPtables/9.lua", [2] = 3559682096, [3] = 3585048575 },
           [10] = { [1] = "GeoIPtables/10.lua", [2] = 3585048576, [3] = 3737124863 }
 }
for i = 1, 10 do
if nr >= tTables[i][2] and nr <= tTables[i][3] then
tGeoIpRangefile = tTables[i][1]
break
end
end
return tGeoIpRangefile
end



function ComputeIP(IP)
local _,_,a,b,c,d = strfind(IP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
if a and b and c and d then
return a*16777216 + b*65536 + c*256 + d
end
end

----the Binary Search Algo----

function tSearchCountry(num)
  local num = tonumber(num)
  local tGeoIpRangefile = tSearch(num)
  dofile(tGeoIpRangefile)
    if tGeoIpRange == nil then
    return 1 end
  local C = ""
  local CC = ""
  local low=1
  local mid = tonumber(mid)
  local high=getn(tGeoIpRange)

while low <= high  do
mid = floor((low+high)/2)
if  tGeoIpRange[mid][1] <= num and num <= tGeoIpRange[mid][2]  then
C = tGeoIpRange[mid][4]
CC = tGeoIpRange[mid][3]
break
end  
if tGeoIpRange[mid][1] > num then
high = mid-1
else low = mid+1
end
end
    tGeoIpRange = nil
      collectgarbage()
return C,CC
end

--------------------------VidFamne
Title:
Post by: pipdipchip on 16 June, 2004, 09:19:30
Looks nice VidFamne but this is what I get:

[02:16]    TOP COUNTRY      (06/16/04 02:16:15)
[02:16] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[02:16] **** 1 :   ~~~    2            1    
[02:16] ------------------------------------------------------------------------------------------
[02:16] **** 2 :   ~~~    1            1    
[02:16] ------------------------------------------------------------------------------------------
Title:
Post by: VidFamne on 16 June, 2004, 14:20:52
Hi pipdipchip :)
Have you the "old" database-files in the script folder?
Otherwise, please download "GeoIP script ver.4.01"
from the 'Script Archive hosted by Optimus'
and replace 'Countryscript.lua' with this new one.
Sorry for I didnt mention that. ;)
Title:
Post by: VidFamne on 17 June, 2004, 16:20:11
GeoIP script ver.4.11
Updated the 'database files' with over 3000 new ip-ranges
and some changes in code.
Added a welcome message.
Added $Usercommand.
The files is on "Script Archive hosted by Optimus" .
Title:
Post by: nEgativE on 22 June, 2004, 21:58:38
QuoteOriginally posted by VidFamne
GeoIP script ver.4.11
Updated the 'database files' with over 3000 new ip-ranges
and some changes in code.
Added a welcome message.
Added $Usercommand.
The files is on "Script Archive hosted by Optimus" .

ei VidFamne, great work here.. tell me, can i just update the database files ? :)

And.. where are the files ? i just can't find them :| Hehe..
Title:
Post by: VidFamne on 23 June, 2004, 16:32:30
Yes, you can update the 'database files' with the new ones.
But you had to replace the old  "function tSearch(nr)" with the new one.
Can be downloaded >>HERE<< (http://uknnet.com/dl_engine/index.php?subcat=16&PHPSESSID=6695c6fc531b4833b67a9a21710a09f6)
Title:
Post by: nEgativE on 23 June, 2004, 23:06:21
VidFamne, tks.. i decided to run that version 4.11, it's dam good, now.. i just have a lot of syntax erros.. at the function UserDisconnected, this only with fakers that are banned by iprange.. and users without tag i thing .. is there anyway to solve ? :))
Title:
Post by: VidFamne on 23 June, 2004, 23:16:15
Havent think of this ;))
Here is a quickie, dont know if it solve the problem though;function UserDisconnected(curUser)
local compIp = ComputeIP(curUser.sIP)
if compIp then else
return 1 end
local C = tSearchCountry(compIp)
tCnumb[C] = tCnumb[C] - 1
end
use this instead.
Title:
Post by: VidFamne on 14 July, 2004, 02:15:40
Merged Top 10 into GeoIP script, and used RabidWombat's
howto parse commands in the DataArrival() function.
UserCommands wich are sent to user;
Get Country stats.,
TopOnliner,
TopChatter,
TopBanner,
TopKicker,
MyTime,
Get User's Country,
Get User's Time.
And for Operators theres an extra command;
Clean log  ------------to clean out if there is some "orphan items" in the
login- and timetable for varies reasons
Please remove all files in Saves-folder when restart HUB
Dont remove files in Saves-folder when restart SCRIPT
Can be downloaded >>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP+Top_10%20ver.0.1.rar)
Updated the GeoIP database, from MaxMind.
It now contains 64 905 IP-ranges.
Added UserCommand +myip also. :)
Title:
Post by: [PT]CableGuy on 24 August, 2004, 01:03:36
EXCELENT JOB VidFamme  !!!
I'm trully amazed....what can i say ? I'll sure use it in "our" network.Thanks a million !!!
Title:
Post by: VidFamne on 16 September, 2004, 02:14:11
Thanks for the appreciation [PT]CableGuy :)
And >>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP+Top_10%20ver.0.2.rar)  is a new update.
The database from MaxMind now contains  65 502 IP-ranges.
Some minor changes in code as I tried to implement "proper tail calls"
in DataArrival() . Dont know if it gains any performance though.
Title:
Post by: BottledHate on 16 September, 2004, 03:20:28
i get errors when i try to open the rar...

-BH
Title:
Post by: VidFamne on 16 September, 2004, 03:33:53
Sorry, I have corrected the link now.
Please try to download again.
Title:
Post by: UwV on 02 October, 2004, 18:52:49
Very nice, really
 .. but one strange thing i notice ..

[23:50:08] ------------------------------------------------------------------------------------------
[23:50:08] ****  11     ~~~    1            Denmark              
[23:50:08] ------------------------------------------------------------------------------------------
[23:50:08] ****  12     ~~~    1            1                    
[23:50:08] ------------------------------------------------------------------------------------------
[23:50:08] ****  13     ~~~    1            Finland              
[23:50:08] ------------------------------------------------------------------------------------------


what country is 1 ?

 and a request (2 actually)..

is possible to have a version to do only the county thingy.. (no kick/chat/ban/online-stats) and maybe possible to have a option to tag the users with their "..CC.." ?

Title:
Post by: VidFamne on 05 October, 2004, 06:09:40
>>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP%20script%20ver.%204.123.rar)   is the version with only the
country 'thingy' ;D
About  tagging, the nicks or in the description, I think it
would stress the hub to much. I'll have to think about it.
**Edit** a minor bugfix
Title:
Post by: UwV on 05 October, 2004, 08:51:04
hehe thanks ,,,
this verson looks pretty simular to what i run now .. .. exept .. there is a looot of line wich have  -- in front of them .. ;0)
(yes i had already 'stripped' the functions i didn't need  but this is much 'cleaner' )
couldn't find the "old geo-ip script" myself ..
Thank you :0)

about he tag (in description).. it is just that i have seen it done ..
by hawk's latest "monster sccript"
 But .. it's.. compiled :0(
and only works in combination with functions i don't want again from that script ..
Title:
Post by: UwV on 07 October, 2004, 12:34:57
hi VidFrame
i have "downgraded"  to the "upgraded" tt + c v1.422

first on one hub (0.3.3.0 b 15.25 with CB5 as main script) and .. very very happy..
just .. Syntax error: bad argument #1 to `closefile' (invalid file handle)
stack traceback:
   1:  function `closefile' [C]
   2:  method `save' at line 44 [file `Files/Func/fFunc.lua']
   3:  function `OnExit' at line 13 [file 'scripts\top ten + country1.lua']
well i can live with that iwas thinking .. just clean the table myself if i must ..
so i then did the same on an other hub, (0.3.6 TD 4.99 with RC9 as main script)
and i get this .. Syntax Error: attempt to perform arithmetic on a nil value (once in a while..)
-- and loads of these :
Syntax Error: table index is nil
any suggestions ..

P.S. i have tried: yes file/no file , with empty table/no-table/singlevalue in table   etc. etc.
many hub-reboots to try and solve it .. :0(
but no luck yet ..
Title:
Post by: VidFamne on 08 October, 2004, 01:07:55
Oops, :)
realy sloppy coding of me :(
try to change closefile(f)
to
closefile(handle) instead
Have updated the link above.
Title:
Post by: UwV on 11 October, 2004, 17:34:35
Worked for ptokax  b 15.25  :0)

But not for TD4.99
still the same "Err0tic" story ..
Title:
Post by: belea on 16 October, 2004, 19:38:41
nice nice..  

i hope that DB to be always update :)

but a little question.. how can i set this script to allow only .us ppl



Thx
Title:
Post by: VidFamne on 17 October, 2004, 16:09:51
Well, >>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP%20script%20ver.%204.124.rar)  is a little update. :)
It now contains 66 316 IP-ranges, from MaxMind.
Title:
Post by: belea on 17 October, 2004, 18:14:31
Hi there

Do u have a little !help command ?  i want to find the command to let only one country.. :)


Thank you again :)
Title:
Post by: VidFamne on 17 October, 2004, 20:31:20
To allow a specifik country in hub here is
a little mod. of the script I've done >>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP%20script%20ver.%204.125.rar) to allow "ALL" as default or
a CountryCode of your choice, which you must change through the
Usercommand every time you restart script.
Warning this is experimental so I cant guarantee anything ;)
Title:
Post by: belea on 17 October, 2004, 21:43:13
thx man..   i putted my country.. now i wait :)
Title:
Post by: belea on 17 October, 2004, 21:45:57
..but if i want  Belgia how i should put ? +Allow Belgia  ?

Thx :) and plz  reply quickly :D
Title:
Post by: VidFamne on 17 October, 2004, 22:04:56
Dont know what you mean by Belgia?
If you mean Belgium, then put in CountryCode BE
Title:
Post by: belea on 17 October, 2004, 22:33:01
i want only ppl from Belgia to be able to connect on my HUB..  

so i willl set that by using +Allow BE ?

Thx
Title:
Post by: VidFamne on 17 October, 2004, 22:55:18
Yes :)
Title:
Post by: belea on 17 October, 2004, 23:12:33
okey...


now  my all hub its protected by your script..  :)  to be only BE ..  :p

I really hope to work.. i dont know another solution.. and its hard for me to search for all .BE  ips..  

Thx :)
Title:
Post by: belea on 17 October, 2004, 23:15:43
and btw i  have this error



Syntax error: attempt to perform arithmetic on a nil value
stack traceback:
   1:  method `UserDisc' at line 109 [file `Files/Func/fFunc.lua']
   2:  function `OpDisconnected' at line 28 [file `...kaX_0.330_15.25_\scripts\top ten + country1.lua']
   3:  method `Disconnect' [C]
   4:  method `Newcon' at line 82 [file `Files/Func/fFunc.lua']
   5:  function `NewUserConnected' at line 24 [file `...kaX_0.330_15.25_\scripts\top ten + country1.lua']

?
Title:
Post by: VidFamne on 17 October, 2004, 23:37:46
I've updated the script above. Please download again.
Title:
Post by: belea on 18 October, 2004, 00:00:02
well until now.. no errors :)

can  u tell me how often its update this IP base ?

Thx
Title:
Post by: belea on 18 October, 2004, 00:53:08
after a while.. something its show up

Syntax error: attempt to perform arithmetic on a nil value
stack traceback:
   1:  method `UserDisc' at line 109 [file `Files/Func/fFunc.lua']
   2:  function `OpDisconnected' at line 28 [file `...kaX_0.330_15.25_\scripts\top ten + country1.lua']


im sure u will come with an update :)

Thx
Title:
Post by: VidFamne on 18 October, 2004, 01:08:50
Sorry, but I cant find any bugs in script, but it may bee
that an Operator was in hub when you inserted the new script.
Therefore there's an arithmetic failure.
Its what I can come up with for now. :)
Close hub and delete whats in Save folder and restart hub, is my advice.
Title:
Post by: belea on 18 October, 2004, 01:41:51
I tried that..  after i stoped and  run again the scripts

i did not need to much time to see this:

Syntax error: bad argument #1 to `strfind' (string expected, got nil)
stack traceback:

Syntax error: attempt to perform arithmetic on a nil value
stack traceback:
   1:  method `UserDisc' at line 109 [file `Files/Func/fFunc.lua']
   2:  function `OpDisconnected' at line 28 [file `...kaX_0.330_15.25_\scripts\top ten + country1.lua']
   3:  method `Ban' [C]
   4:  method `Newcon' at line 82 [file `Files/Func/fFunc.lua']
   5:  function `NewUserConnected' at line 24 [file `...kaX_0.330_15.25_\scripts\top ten + country1.lua']

And i putted BAN instead Disconnect because i want to see them in !getbanlist..  to see who can not enter :)
..and until now except  the little errors the script do a great job.. :p

 P.S. u did not told me if i can update by myself the IP data base, thx
Title:
Post by: VidFamne on 18 October, 2004, 02:13:20
Try to put; curUser:Ban()
before; curUser:Disconnect()

And about the database, its rather complicated story, to convert to tables.
But it seems to be updated once in 1 or 2 months.
Title:
Post by: belea on 18 October, 2004, 10:30:36
hi there

VidFamne i think u are right..  when i restart my scripts and put another order for scripts..  i have others errors but with others scripts..  i guess its something with my ptokax version..  :)


and until now your script do a great job.. no bans on my ppl... :) and no join from ppl from others countries


Another question..  if in this time 1-2 months i will see my country IPs  that get ban from the script.. i can not modify the DB and add others IPs ?
Title:
Post by: belea on 18 October, 2004, 14:10:59
someone could connect and was no BE ip.. :(

This IP: 217.229.94.89
inetnum:      217.224.0.0 - 217.237.161.47
netname:      DTAG-DIAL15
descr:        Deutsche Telekom AG
country:      DE

and
This IP: 82.84.4.54
inetnum:      82.84.0.0 - 82.84.255.255
netname:      TISCALINET
descr:        Tiscali SpA
descr:        PROVIDER
country:      IT

so maybe a little update or something ? :)

Thx
Title:
Post by: belea on 19 October, 2004, 09:34:37
Hi there


I tried again and pay more attention..

and its seems to do the jobs.. but every time when i restart the scripts i must put +Allow BE :)

I can not set that in the file.. so every time to have only BE ?

Thx..  i really hope to work :D
Title:
Post by: VidFamne on 19 October, 2004, 12:37:21
Change the default value "ALL" to a CountryCode of your choice,
in your case "BE", in function Main().
As a side note; CountryCodes can be found HERE (http://www.maxmind.com/app/iso3166)
Title:
Post by: belea on 20 October, 2004, 19:52:46
Hi there

For 2 days i run my hub using your script to keep others countries out .. and guess what ?  its work perfectlly not even one country in..  or at least i did not saw :)   but only one request..   u can do something so every one could update the IP date base ? :)


P.S. this script will be the only solution for blocking others countries..  like GeoIP for VerilHub ;)

Good job Vid
Title:
Post by: belea on 25 October, 2004, 09:22:49
Hi there

VidFamne plz if u can add a little obtions..  :)

I want to be able to put some IP ranges that do not be cheched..  like 192.168.0.1/24 or 192.168.0.0 - 192.168.0.256

Because right now they are a few IP ranges that are from my country but geoip dont see that...  and until it will be a new update.. i want to put manually those IP ranges..  

Thax man :)
Title:
Post by: VidFamne on 06 December, 2004, 13:03:35
A little update of the GeoIP database, and a little change to code so
cleaning the saves folder are done automagical, when restart hub ( thanx to plop for the tip ;) )
Download >>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP%20script%20ver.%204.126.rar)
About beleas request,
I'm sorry to admit that I havent found any easy solution to this problem.
Maybe another more skilled scripter could do it. ;)
Title:
Post by: bastya_elvtars on 06 December, 2004, 14:37:09
QuoteOriginally posted by VidFamne
A little update of the GeoIP database, and a little change to code so
cleaning the saves folder are done automagical, when restart hub ( thanx to plop for the tip ;) )
Download >>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP%20script%20ver.%204.126.rar)
About beleas request,
I'm sorry to admit that I havent found any easy solution to this problem.
Maybe another more skilled scripter could do it. ;)

im not a skillful scripter, but gonna take a look as its nice how you beat verli ;)
Title:
Post by: chill on 06 December, 2004, 19:38:49
I'd say your too lazy :P
Title:
Post by: Corayzon on 03 January, 2005, 03:40:09
yo guys,

where can the gio ip database be updated for free?

i been looking around for awhile on getting country codes but all these sites want money for the stupid database, or the databases have passwords which cant be entered with the access component =[

cheers in advanced!

matt
Title:
Post by: nEgativE on 03 January, 2005, 12:28:20
QuoteOriginally posted by VidFamne
A little update of the GeoIP database, and a little change to code so
cleaning the saves folder are done automagical, when restart hub ( thanx to plop for the tip ;) )
Download >>HERE<< (ftp://vidfamne.myftp.org/dl/GeoIP%20script%20ver.%204.126.rar)
About beleas request,
I'm sorry to admit that I havent found any easy solution to this problem.
Maybe another more skilled scripter could do it. ;)

Nice, VidFamne.. i think link is off.
Title:
Post by: VidFamne on 08 February, 2005, 00:24:34
Another li'll update of the database.
It now contains 68635 ip ranges.
here (ftp://vidfamne.myftp.org/dl/GeoIP%20script%20ver.%204.127.rar)