Vice City: Multiplayer

Server Development => Community Plugins => Topic started by: Crys on Sep 14, 2015, 08:22 AM

Title: GeoIP
Post by: Crys on Sep 14, 2015, 08:22 AM
Introduction
I got sick of the Squirrel plus SQLite based implementations of GeoIP (so called IP to Country scripts), because they tend to be slow and hard to update, so I made this little plugin, which is a Squirrel binding for libGeoIP. It can load the GeoIP.dat file that could be downloaded from MaxMind's site, which is updated monthly. MaxMind abandoned the old GeoIP.dat format in favor of the new MMDB format, so I've made a script that converts the new GeoLite2 databases' format to the old format. The updated GeoIP database can be downloaded from the link below.

Documentation
You can find the plugin's documentation here (https://git.doszgep.hu/vcmp/geoip/blob/master/README.md).
Every functions and constants provided by the plugin is explained there.

Download
- GeoIP.dat (https://geoip.crys.hu/GeoIP.dat)
- Linux 32 bit (https://git.doszgep.hu/vcmp/geoip/uploads/054b8f889080f1388839940bfca81822/geoip04rel32.so)
- Linux 64 bit (https://git.doszgep.hu/vcmp/geoip/uploads/7e4a893cb1b2d12fc514698de1a696ab/geoip04rel64.so)
- Windows 32 bit (https://git.doszgep.hu/vcmp/geoip/uploads/973417076f89c23c348654e901eb7278/geoip04rel32.dll)
- Windows 64 bit (https://git.doszgep.hu/vcmp/geoip/uploads/abb36f78a2dad2a81a3878797c2860e6/geoip04rel64.dll)
Title: Re: GeoIP
Post by: hotdogcat on Sep 14, 2015, 10:12 AM
Finally, i was waiting this release
Title: Re: GeoIP
Post by: jayant on Sep 14, 2015, 03:48 PM
No more waiting..Thanks Crys :)
Title: Re: GeoIP
Post by: KAKAN on Sep 14, 2015, 05:03 PM
Ahh please release windows version too :(
Title: Re: GeoIP
Post by: Thijn on Sep 14, 2015, 06:25 PM
There's everything you need to know on the link that says "documentation". What else do you need? ...
Title: Re: GeoIP
Post by: KAKAN on Sep 15, 2015, 08:26 AM
Oye Thanks! Btw can u compile it for windows?
Title: Re: GeoIP
Post by: Crys on Sep 15, 2015, 05:33 PM
I'll include windows builds for both of my plugins in the following days.
Title: Re: GeoIP
Post by: Crys on Sep 17, 2015, 04:36 AM
Added Windows builds.
Title: Re: GeoIP
Post by: KAKAN on Sep 17, 2015, 05:21 AM
OMG Thanks a lot bro!
Title: Re: GeoIP
Post by: Eva on Apr 14, 2016, 06:52 PM
Thanks a lot this one works great :)
Title: Re: GeoIP
Post by: KAKAN on Apr 14, 2016, 06:59 PM
Quote from: Ron on Apr 14, 2016, 06:52 PMThanks a lot this one works great :)
Wow! Just wow! Did you read the last post's date even? I don't think that you even care for it.
Title: Re: GeoIP
Post by: Coolkid on Apr 15, 2016, 09:56 PM
Quote from: KAKAN on Apr 14, 2016, 06:59 PM
Quote from: Ron on Apr 14, 2016, 06:52 PMThanks a lot this one works great :)
Wow! Just wow! Did you read the last post's date even? I don't think that you even care for it.
wow just amazing and you will not leave your habit to back comment if he commented on a 7 months post then whats problem with you
Title: Re: GeoIP
Post by: KAKAN on Apr 16, 2016, 08:20 AM
Quote from: Coolkid on Apr 15, 2016, 09:56 PM
Quote from: KAKAN on Apr 14, 2016, 06:59 PM
Quote from: Ron on Apr 14, 2016, 06:52 PMThanks a lot this one works great :)
Wow! Just wow! Did you read the last post's date even? I don't think that you even care for it.
wow just amazing and you will not leave your habit to back comment if he commented on a 7 months post then whats problem with you
-..-
Rules: http://forum.vc-mp.org/?topic=2.0
Read 'em if you haven't already. And read the 2nd rule. I said him so that he won't bump anymore.
Title: Re: GeoIP
Post by: rww on Apr 27, 2016, 08:09 PM
Plugin need update to VCMP 04rel004.
Title: Re: GeoIP
Post by: Eva on May 27, 2016, 09:20 PM
Quote from: KAKAN on Apr 16, 2016, 08:20 AM
Quote from: Coolkid on Apr 15, 2016, 09:56 PM
Quote from: KAKAN on Apr 14, 2016, 06:59 PM
Quote from: Ron on Apr 14, 2016, 06:52 PMThanks a lot this one works great :)
Wow! Just wow! Did you read the last post's date even? I don't think that you even care for it.
wow just amazing and you will not leave your habit to back comment if he commented on a 7 months post then whats problem with you
-..-
Rules: http://forum.vc-mp.org/?topic=2.0
Read 'em if you haven't already. And read the 2nd rule. I said him so that he won't bump anymore.
You consider a thankyou for bump? you gotta be kidding lol. And secondly im not a him nor he...
Title: Re: GeoIP
Post by: KAKAN on May 28, 2016, 03:43 AM
What? :\
Anyways:-
Quote from: rww on Apr 27, 2016, 08:09 PMPlugin need update to VCMP 04rel004.
Neither Thijn is fixing his version of GeoIP :(
Title: Re: GeoIP
Post by: ysc3839 on May 28, 2016, 05:29 AM
Quote from: KAKAN on May 28, 2016, 03:43 AMWhat? :\
Anyways:-
Quote from: rww on Apr 27, 2016, 08:09 PMPlugin need update to VCMP 04rel004.
Neither Thijn is fixing his version of GeoIP :(
I could try to fix it this weekend.
Title: Re: GeoIP
Post by: ysc3839 on May 29, 2016, 04:56 AM
Updated. I haven't tested. No Linux version.
(http://files.thijn.ovh/img/076a4679e940819c7b4ac0211983e723/geoip.zip) (http://files.thijn.ovh/download/076a4679e940819c7b4ac0211983e723/geoip.zip)

Source code: https://bitbucket.org/ysc3839/0.4-geoip/ (https://bitbucket.org/ysc3839/0.4-geoip/)
Title: Re: GeoIP
Post by: DizzasTeR on May 29, 2016, 04:58 AM
Quote from: ysc3839 on May 29, 2016, 04:56 AMNo Linux version.
:( That's what most of us need.
Title: Re: GeoIP
Post by: ysc3839 on May 29, 2016, 05:03 AM
Quote from: Doom_Kill3R on May 29, 2016, 04:58 AM
Quote from: ysc3839 on May 29, 2016, 04:56 AMNo Linux version.
:( That's what most of us need.
Try to compile by yourself.
Title: Re: GeoIP
Post by: DizzasTeR on May 29, 2016, 05:50 AM
I never did compiling of plugins before, neither I'm interested to it, if people post plugins then they should update them, even though its not your responsibility to keep this up to date but just saying.
Title: Re: GeoIP
Post by: . on May 29, 2016, 06:25 AM
Quote from: Doom_Kill3R on May 29, 2016, 05:50 AMI never did compiling of plugins before, neither I'm interested to it...

That's why you don't understand the horrors of it. Especially when it comes to cross platform.
Title: Re: GeoIP
Post by: ysc3839 on May 29, 2016, 06:29 AM
Quote from: Doom_Kill3R on May 29, 2016, 05:50 AMI never did compiling of plugins before, neither I'm interested to it, if people post plugins then they should update them, even though its not your responsibility to keep this up to date but just saying.
The original git repository uses GeoIP library as a git submodule. However, It seems that GeoIP had a big update and there is something wrong when compile the plugin. So I removed the submodule and added libGeoIP code. And then if we want to compile in Linux, we should change the Makefile. But I don't know how to do. :( Wait next weekends, may be I could fix it.
Title: Re: GeoIP
Post by: Thijn on May 29, 2016, 03:46 PM
Both release versions work for me now: http://vcmp.thijn.ovh/builds/
Title: Re: GeoIP
Post by: aXXo on May 30, 2016, 10:20 AM
Quote from: Thijn on May 29, 2016, 03:46 PMBoth release versions work for me now: http://vcmp.thijn.ovh/builds/
Linux 64 bit plugin is not working for me.

The plugin successfully loads:
Loaded plugin: geoip04rel64

However, I dont get the following print on console: (Taken from Windows plugin)
[MODULE]  Loading GeoIP for 0.4 by Crys.
[MODULE]  Loaded GeoIP.dat (GeoIP Country Edition)
Title: Re: GeoIP
Post by: ysc3839 on May 30, 2016, 01:11 PM
Quote from: aXXo on May 30, 2016, 10:20 AM
Quote from: Thijn on May 29, 2016, 03:46 PMBoth release versions work for me now: http://vcmp.thijn.ovh/builds/
Linux 64 bit plugin is not working for me.

The plugin successfully loads:
Loaded plugin: geoip04rel64

However, I dont get the following print on console: (Taken from Windows plugin)
[MODULE]  Loading GeoIP for 0.4 by Crys.
[MODULE]  Loaded GeoIP.dat (GeoIP Country Edition)
I made some changes to the original code. Maybe there's some different with Thijn's code.
Title: Re: GeoIP
Post by: Thijn on May 30, 2016, 03:47 PM
Quote from: ysc3839 on May 30, 2016, 01:11 PM
Quote from: aXXo on May 30, 2016, 10:20 AM
Quote from: Thijn on May 29, 2016, 03:46 PMBoth release versions work for me now: http://vcmp.thijn.ovh/builds/
Linux 64 bit plugin is not working for me.

The plugin successfully loads:
Loaded plugin: geoip04rel64

However, I dont get the following print on console: (Taken from Windows plugin)
[MODULE]  Loading GeoIP for 0.4 by Crys.
[MODULE]  Loaded GeoIP.dat (GeoIP Country Edition)
I made some changes to the original code. Maybe there's some different with Thijn's code.
Yes, I stripped that message. The squirrel calls should work fine though.
Title: Re: GeoIP
Post by: aXXo on May 31, 2016, 05:34 AM
Didn't work,
index geoip_country_name_by_addr not found. The Windows version works fine.
Title: Re: GeoIP
Post by: Thijn on May 31, 2016, 06:02 AM
Weird. I have recompiled the builds again, can you try again?

What OS do you have, 32/64bit?
Title: Re: GeoIP
Post by: Anik on May 31, 2016, 09:05 AM
Quote from: aXXo on May 31, 2016, 05:34 AMDidn't work,
index geoip_country_name_by_addr not found. The Windows version works fine.
I am using @Thijn's plugin And its working fine for me.
Title: Re: GeoIP
Post by: Cool on May 31, 2016, 09:37 AM
Quote from: aXXo on May 31, 2016, 05:34 AMDidn't work,
index geoip_country_name_by_addr not found. The Windows version works fine.
that problem can cause due to wrong paste where you put that change its place may be its works :P
Title: Re: GeoIP
Post by: Thijn on May 31, 2016, 04:16 PM
Quote from: Hercules on May 31, 2016, 09:37 AM
Quote from: aXXo on May 31, 2016, 05:34 AMDidn't work,
index geoip_country_name_by_addr not found. The Windows version works fine.
that problem can cause due to wrong paste where you put that change its place may be its works :P
If it works on windows it aint a copy-paste error.
Title: Re: GeoIP
Post by: DizzasTeR on May 31, 2016, 05:39 PM
It works on Linux x64 now.
Title: Re: GeoIP
Post by: aXXo on Jun 01, 2016, 06:43 AM
Yes, it works. (I was being a noob)
Title: Re: GeoIP
Post by: Crys on Jul 31, 2016, 12:02 PM
I've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.
Title: Re: GeoIP
Post by: Kirollos on Aug 08, 2016, 04:43 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.

Hello, I've managed to compile them for Windows. Link (https://kirollos.rocks/vcmp/geoip04winrel.zip) (You might need vcredist 2015)
Title: Re: GeoIP
Post by: Dagger on Apr 23, 2017, 08:18 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.
Can you please make for windows?
Title: Re: GeoIP
Post by: KAKAN on Apr 23, 2017, 08:28 AM
Quote from: Dagger on Apr 23, 2017, 08:18 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.
Can you please make for windows?
Quote from: Kirollos on Aug 08, 2016, 04:43 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.

Hello, I've managed to compile them for Windows. Link (https://kirollos.rocks/vcmp/geoip04winrel.zip) (You might need vcredist 2015)
???????
Title: Re: GeoIP
Post by: Dagger on May 04, 2017, 04:25 PM
Quote from: KAKAN on Apr 23, 2017, 08:28 AM
Quote from: Dagger on Apr 23, 2017, 08:18 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.
Can you please make for windows?
Quote from: Kirollos on Aug 08, 2016, 04:43 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.

Hello, I've managed to compile them for Windows. Link (https://kirollos.rocks/vcmp/geoip04winrel.zip) (You might need vcredist 2015)
???????
Its not working for me. I have loaded that plugin too.
Title: Re: GeoIP
Post by: Kirollos on May 04, 2017, 07:52 PM
Quote from: Dagger on May 04, 2017, 04:25 PM
Quote from: KAKAN on Apr 23, 2017, 08:28 AM
Quote from: Dagger on Apr 23, 2017, 08:18 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.
Can you please make for windows?
Quote from: Kirollos on Aug 08, 2016, 04:43 AM
Quote from: Crys on Jul 31, 2016, 12:02 PMI've updated the plugin to work with the latest server (Plugin API 2.0). Only Linux builds for now.

Hello, I've managed to compile them for Windows. Link (https://kirollos.rocks/vcmp/geoip04winrel.zip) (You might need vcredist 2015)
???????
Its not working for me. I have loaded that plugin too.

@Dagger
Make sure vcredist 2015 is installed (x86 if you are gonna run x86 server, x64 for otherwise)
https://www.microsoft.com/en-eg/download/details.aspx?id=48145
Title: Re: GeoIP
Post by: ysc3839 on Jun 25, 2018, 03:59 PM
I tested Linux x64 with both v23(04rel004) and v29(04rel006) server. Always get "(null : 0x(nil))".
Maybe geoip library is too old?
Code:
function onConsoleInput(cmd, arg)
{
print(cmd + " " + arg);
if (cmd == "ip")
{
print(geoip_country_code_by_addr(arg));
print(geoip_country_code3_by_addr(arg));
print(geoip_country_name_by_addr(arg));
}
}
Title: Re: GeoIP
Post by: rww on Jun 25, 2018, 08:40 PM
Quote from: ysc3839 on Jun 25, 2018, 03:59 PMI tested Linux x64 with both v23(04rel004) and v29(04rel006) server. Always get "(null : 0x(nil))".
Maybe geoip library is too old?
Code:
function onConsoleInput(cmd, arg)
{
print(cmd + " " + arg);
if (cmd == "ip")
{
print(geoip_country_code_by_addr(arg));
print(geoip_country_code3_by_addr(arg));
print(geoip_country_name_by_addr(arg));
}
}

Here also Linux x64

(http://s5.ifotos.pl/img/fwfwpng_qeraqwa.png)
Title: Re: GeoIP
Post by: ysc3839 on Jun 25, 2018, 10:32 PM
@rww #41 Maybe it's because GeoIP.dat incompatible? Can you upload an old one?
Title: Re: GeoIP
Post by: Crys on Jul 18, 2018, 06:03 PM
I've updated the plugin to work with the latest server. Only Linux builds for now.

UPDATE: Windows builds added.
Title: Re: GeoIP
Post by: =RK=MarineForce on Jul 20, 2018, 09:56 AM
hey bro i can't install this properly. can u help me?


i have downloaded plugin geoip.dat in my server but didn't work don''t sending data into joining server when player join it will show message but not showing .

updated untested
    if (country == null) reutrn "unknow");
Title: Re: GeoIP
Post by: rww on Jul 20, 2018, 10:02 AM
Quote from: =RK=MarineForce on Jul 20, 2018, 09:56 AMhey bro i can't install this properly. can u help me?


i have downloaded plugin geoip.dat in my server but didn't work don''t sending data into joining server when player join it will show message but not showing .

updated untested
    if (country == null) reutrn "unknow");

you have geoip.dat in main server folder?

and put it to onPlayerJoin/onPlayerPart, and check console after join to the server

print("Test geoip: "+geoip_country_name_by_addr(player.IP));
Title: Re: GeoIP
Post by: =RK=MarineForce on Jul 20, 2018, 10:06 AM
https://ibb.co/fcZ68d

function onPlayerJoin( player )
{
print("Test geoip: "+geoip_country_name_by_addr(player.IP));
Stats[ player.ID ] = PlayerClass();
NewTimer( "CheckBan", 1000, 1, player.ID );
Message("[#00CC00]** [#ffffff]"+player.Name+" [#00cc00]Has Joined The Server");
stats[ player.ID ] = PlayerClass();
GetInfo(player);
}
Title: Re: GeoIP
Post by: rww on Jul 20, 2018, 10:48 AM
Quote from: =RK=MarineForce on Jul 20, 2018, 10:06 AMhttps://ibb.co/fcZ68d

function onPlayerJoin( player )
{
print("Test geoip: "+geoip_country_name_by_addr(player.IP));
Stats[ player.ID ] = PlayerClass();
NewTimer( "CheckBan", 1000, 1, player.ID );
Message("[#00CC00]** [#ffffff]"+player.Name+" [#00cc00]Has Joined The Server");
stats[ player.ID ] = PlayerClass();
GetInfo(player);
}

Localhost IP (127.0.0.1) isn't exist on geoip.dat
Title: Re: GeoIP
Post by: Crys on Jul 20, 2018, 08:47 PM
Quote from: rww on Jul 20, 2018, 10:48 AM
Quote from: =RK=MarineForce on Jul 20, 2018, 10:06 AMhttps://ibb.co/fcZ68d

function onPlayerJoin( player )
{
print("Test geoip: "+geoip_country_name_by_addr(player.IP));
Stats[ player.ID ] = PlayerClass();
NewTimer( "CheckBan", 1000, 1, player.ID );
Message("[#00CC00]** [#ffffff]"+player.Name+" [#00cc00]Has Joined The Server");
stats[ player.ID ] = PlayerClass();
GetInfo(player);
}

Localhost IP (127.0.0.1) isn't exist on geoip.dat

Localhost won't work indeed - local IP addresses are not delegated to any entity, so they don't have a country by design. Try it with a remote client's IP address. It works for me:
[MODULE] Loaded GeoIP for 0.4 by Crys.
            >> Loaded GeoIP.dat (GeoIP Country Edition)
[SCRIPT] === GeoIP DEBUG ===
[SCRIPT] - Database info: GEO-106FREE 20180719 Build 1 Copyright (c) 2018 MaxMind Inc All Rights Reserved
[SCRIPT] - Number of countries: 256
[SCRIPT] - Library version: 1.6.12
[SCRIPT] - Character set: UTF-8
[SCRIPT] geoip_country_code_by_addr("78.24.185.47") = "HU"
[SCRIPT] geoip_country_code3_by_addr("78.24.185.47") = "HUN"
[SCRIPT] geoip_country_name_by_addr("78.24.185.47") = "Hungary"

This is the script that I'm using for debugging:
function onScriptLoad() {
    local testIP = "78.24.185.47";
    print("=== GeoIP DEBUG ===");
    print("- Database info: " + geoip_database_info());
    print("- Number of countries: " + geoip_num_countries());
    print("- Library version: " + geoip_lib_version());
    print("- Character set: " + (geoip_charset() == GEOIP_CHARSET_UTF8 ? "UTF-8" : "ISO-8859-1"));
    print("geoip_country_code_by_addr(\"" + testIP + "\") = \"" + geoip_country_code_by_addr(testIP) + "\"");
    print("geoip_country_code3_by_addr(\"" + testIP + "\") = \"" + geoip_country_code3_by_addr(testIP) + "\"");
    print("geoip_country_name_by_addr(\"" + testIP + "\") = \"" + geoip_country_name_by_addr(testIP) + "\"");
}
Title: Re: GeoIP
Post by: =RK=MarineForce on Jul 20, 2018, 09:09 PM
thats why cool :D