PDA

View Full Version : [ANY] GeoIP2


Accelerator
10-19-2018, 04:45
GeoIP2 is now included with SourceMod 1.11.6703.

This is a rewritten geoip extension from the SourceMod distribution for the new database format from MaxMind .mmdb.

Installation:
Download latest release version.
Extract all files from the archive with replacement to your game server.
Download last database GeoLite2-City.mmdb (http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz) or GeoLite2-Country.mmdb (http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz) and put to path addons/sourcemod/configs/geoip/
Recompile all plugins that use geoip.inc.


Usage:
// geoip.inc

/**
* @section IP addresses can contain ports, the ports will be stripped out.
*/

/**
* Gets the two character country code from an IP address. (US, CA, etc)
*
* @param ip Ip to determine the country code.
* @param ccode Destination string buffer to store the code.
* @return True on success, false if no country found.
*/
native bool GeoipCode2(const char[] ip, char ccode[3]);

/**
* Gets the three character country code from an IP address. (USA, CAN, etc)
*
* @param ip Ip to determine the country code.
* @param ccode Destination string buffer to store the code.
* @return True on success, false if no country found.
*/
native bool GeoipCode3(const char[] ip, char ccode[4]);

/**
* Gets the two character continent code from an IP address. (EU, AS, etc)
*
* @param ip Ip to determine the continent code.
* @param ccode Destination string buffer to store the code.
* @return True on success, false if no continent found.
*/
native bool GeoipContinentCode(const char[] ip, char ccode[3]);

/**
* Gets the two/three region code from an IP address. (IL, CHE, etc)
*
* @param ip Ip to determine the region code.
* @param ccode Destination string buffer to store the code.
* @return True on success, false if no region found.
*/
native bool GeoipRegionCode(const char[] ip, char ccode[4]);

/**
* Gets the timezone. (max length of output string is 45)
*
* @param ip Ip to determine the timezone.
* @param name Destination string buffer to store the timezone.
* @param maxlength Maximum length of output string buffer.
* @return True on success, false if no timezone found.
*/
native bool GeoipTimezone(const char[] ip, char[] name, int maxlength);

/**
* Gets the full country name. (max length of output string is 45)
*
* @param ip Ip to determine the country code.
* @param name Destination string buffer to store the country name.
* @param maxlength Maximum length of output string buffer.
* @param lang Which language to the output of result the geoip2 lookup.
* @return True on success, false if no country found.
*/
native bool GeoipCountry(const char[] ip, char[] name, int maxlength, const char[] lang = "en");

/**
* Gets the full continent name. (max length of output string is 45)
*
* @param ip Ip to determine the continent code.
* @param name Destination string buffer to store the continent name.
* @param maxlength Maximum length of output string buffer.
* @param lang Which language to the output of result the geoip2 lookup.
* @return True on success, false if no continent found.
*/
native bool GeoipContinent(const char[] ip, char[] name, int maxlength, const char[] lang = "en");

/**
* Gets the full region name. (max length of output string is 45)
*
* @param ip Ip to determine the region code.
* @param name Destination string buffer to store the region name.
* @param maxlength Maximum length of output string buffer.
* @param lang Which language to the output of result the geoip2 lookup.
* @return True on success, false if no region found.
*/
native bool GeoipRegion(const char[] ip, char[] name, int maxlength, const char[] lang = "en");

/**
* Gets the city name. (max length of output string is 45)
*
* @param ip Ip to determine the city code.
* @param name Destination string buffer to store the city name.
* @param maxlength Maximum length of output string buffer.
* @param lang Which language to the output of result the geoip2 lookup.
* @return True on success, false if no city found.
*/
native bool GeoipCity(const char[] ip, char[] name, int maxlength, const char[] lang = "en");

Download: https://github.com/Accelerator74/GeoIP2/releases

ThatKidWhoGames
10-19-2018, 10:03
Thanks for this!!

Bacardi
10-19-2018, 10:32
Nice work OP.

Maxximou5
10-19-2018, 16:08
Excellent!

Accelerator
10-20-2018, 09:18
Updated.

v1.1.0:
- Code optimization
- New natives

Bacardi
11-16-2018, 07:43
Here some news

https://github.com/alliedmodders/sourcemod/pull/914

scorpius2k1
12-20-2019, 16:27
Thanks for this OP!

Here some news

https://github.com/alliedmodders/sourcemod/pull/914

I haven't had any issues with Accelerator74's extension, works great. However, are there any updates on the SourceMod side of things or are we stuck using outdated GeoIP databases if not using this extention?

Apologies for the thread necro.

Thanks!

freak.exe_uLow
01-30-2020, 14:31
Hey Accelerator74, it is no longer possible to download the files "GeoLite2-City.mmdb and GeoLite2-Country.mmdb ".

Accelerator
01-30-2020, 14:40
Register on maxmind (https://www.maxmind.com/en/geolite2/signup) to be able to download new databases

freak.exe_uLow
03-08-2020, 18:21
Register on maxmind (https://www.maxmind.com/en/geolite2/signup) to be able to download new databases

Itīs little bit late but thanks :3

zzhlmy
03-31-2020, 09:14
Register on maxmind (https://www.maxmind.com/en/geolite2/signup) to be able to download new databases

Excuse me, how to use the new GeoIPCity database on server?

Trum
09-24-2020, 15:02
Why am I receiving this error?

L 09/24/2020 - 20:58:32: [SM] Unable to load extension "geoip.ext": Could not find GeoIP2 databases.

I have the GeoIP.dat file inside addons/sourcemod/configs/geoip/. I then restarted the server and the error was thrown.

KadabraZz
09-30-2020, 15:29
Does anyone know how to add any ip to this GeoIP list?

cravenge
10-02-2020, 09:52
Why am I receiving this error?

L 09/24/2020 - 20:58:32: [SM] Unable to load extension "geoip.ext": Could not find GeoIP2 databases.

I have the GeoIP.dat file inside addons/sourcemod/configs/geoip/. I then restarted the server and the error was thrown. Download last database GeoLite2-City.mmdb (http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz) or GeoLite2-Country.mmdb (http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz) and put to path addons/sourcemod/configs/geoip/

gamer_kanelita
10-14-2020, 17:09
I already downloaded it but that database in which exactly should I copy? :llorar::llorar:

Dragokas
10-16-2020, 10:57
in addons/sourcemod/configs/geoip

phathaithaiha
10-22-2020, 05:46
Thanks for share! Greate nice for you! :wink:

fragnichtnach
12-18-2020, 04:40
Download last database GeoLite2-City.mmdb (http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz) or GeoLite2-Country.mmdb (http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz) and put to path addons/sourcemod/configs/geoip/


The link is not working. Don't find a Lite version on maxmind.com.
edit: I've found the files at theior site after logging in.

New problem:
[13] <FAILED> file "geoip.ext.so": Could not find GeoIP2 databases.
The files have been placed into /addons/sourcemod/configs/geoip/. (Same folder as the previous version.)

Why is the extention not seeing the database? Do I have to rename it?

cravenge
12-18-2020, 04:51
The link is not working. Don't find a Lite version on maxmind.com.Register on maxmind (https://www.maxmind.com/en/geolite2/signup) to be able to download new databases

Dragokas
12-18-2020, 09:23
fragnichtnach,
See the updated installation description: https://github.com/dragokas/GeoIP2

fragnichtnach
12-22-2020, 11:32
Okay, thank you. Pretty creepy to request a license key. I would prefer continue to use GeoIPCity. But one of my machines is having problems with opening the GeoIPCity.dat. Do you think this is related to the new policy of maxmind. I don't understand why one machine (the new one) is having problems while the others are working normally.

Dragokas
12-22-2020, 11:49
You need just a free license key, created in the same page, as described:


## Installation
1. Download the latest release version of GeoIPv2 (https://github.com/Accelerator74/GeoIP2/releases).
2. Extract all files from the archive with replacement to your game server.
3. Register on maxmind.com (https://www.maxmind.com/en/geolite2/signup) to be able to download databases,
3a. Go to account https://www.maxmind.com/en/account/ => My License Keys, create a new key.
3b. Go to this page: https://www.maxmind.com/en/accounts/XXXXXX/geoip/downloads by substituting XXXXXX with your account ID,
3c. Download "GeoLite2 Country" and "GeoLite2 City" databases.
4. Put mmdb database files to path `addons/sourcemod/configs/geoip/`
5. Recompile all plugins that use `geoip.inc`.


Also, you need a new geoip.inc provided with the sources, put it in the sourcemod's scripting/include folder, you are using to compile the plugins.

digin
03-04-2021, 21:00
will there be an update for the GeoLite2 ASN?

pan0s
04-15-2021, 14:33
Please provide compiled files...

Accelerator
04-15-2021, 23:20
https://github.com/Accelerator74/sourcemod/releases/tag/geoip2

paulo_crash
04-28-2021, 13:14
https://github.com/Accelerator74/sourcemod/releases/tag/geoip2
Version Windows?

Accelerator
04-29-2021, 04:58
On windows it is more problematic to build sources (visual studio >_>).
Just wait for this pull request (https://github.com/alliedmodders/sourcemod/pull/1245) to be accepted.

Or use the old version of the extension.

paulo_crash
04-29-2021, 08:40
On windows it is more problematic to build sources (visual studio >_>).
Just wait for this pull request (https://github.com/alliedmodders/sourcemod/pull/1245) to be accepted.

Or use the old version of the extension.
OK thanks.

Doubt, in case this GeoIP2 is now coming, will I come, with the SourceMod now? Or do I still need to download the separate extension?

fragnichtnach
06-24-2022, 07:02
OK thanks.

Doubt, in case this GeoIP2 is now coming, will I come, with the SourceMod now? Or do I still need to download the separate extension?
Highly interested in this as well.