Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoIP not working at all in latest 1.9 #653

Closed
OciXCrom opened this issue Jan 6, 2019 · 14 comments
Closed

GeoIP not working at all in latest 1.9 #653

OciXCrom opened this issue Jan 6, 2019 · 14 comments

Comments

@OciXCrom
Copy link
Contributor

OciXCrom commented Jan 6, 2019

Detected here - https://forums.alliedmods.net/showthread.php?t=297952&page=10

I used this test plugin:

#include <amxmodx>
#include <geoip>

public plugin_init()
{
	register_plugin("GeoIP Test", "1.0", "OciXCrom")
	register_srvcmd("geoip_test", "GeoIP_Test")
}

public GeoIP_Test(id)
{
	new szTemp[45], szIP[32]
	read_argv(1, szIP, charsmax(szIP))

	if(!szIP[0])
	{
		server_print("Please enter a valid IP address.")
		return PLUGIN_HANDLED
	}

	server_print("~~~ AMXX Version %s ~~~", AMXX_VERSION_STR)

	geoip_country(szIP, szTemp, charsmax(szTemp))
	server_print("Country: %s", szTemp)

	geoip_country_ex(szIP, szTemp, charsmax(szTemp))
	server_print("Country [ex]: %s", szTemp)

	geoip_city(szIP, szTemp, charsmax(szTemp))
	server_print("City: %s", szTemp)

	return PLUGIN_HANDLED
}

Results from 1.8.2 and latest 1.9 dev-build using my current IP address (77.29.18.129):

~~~ AMXX Version 1.9.0.5235 ~~~
Country: error
Country [ex]: 
City:

~~~ AMXX Version 1.8.2 ~~~
Country: Macedonia
Country [ex]: Macedonia
City:

Also notice how geoip_country and geoip_country_ex give a different value when they can't detect the country. This can be a problem in some cases.

In addition, I didn't manage to get the city in neither version, testing with different IP addresses from different countries.

@WPMGPRoSToTeMa
Copy link
Contributor

WPMGPRoSToTeMa commented Jan 6, 2019

Also notice how geoip_country and geoip_country_ex give a different value when they can't detect the country. This can be a problem in some cases.

You can check return value of geoip_country_ex call:
@return The result length on successful lookup, 0 otherwise.

@OciXCrom
Copy link
Contributor Author

OciXCrom commented Jan 6, 2019

I usually do checks like that by doing if(szCountry[0]) because the country is already stored in some global variable. This check won't give the same result on both functions. Not a big deal, but I think it would be better if they both did the same thing on failure.

@Arkshine
Copy link
Member

Arkshine commented Jan 6, 2019

geoip_country is deprecated, you should not use it.

To test an IP you can also use the command geoip dump <ip>.
Will check if the last updates did something wrong.

@Arkshine
Copy link
Member

Arkshine commented Jan 6, 2019

@OciXCrom Try to download the latest version of the database. It might be possible that the file you have is corrupted or the structure has changed a little and doesn't work well with the latest lib version. It worked for me it would seem.

@OciXCrom
Copy link
Contributor Author

OciXCrom commented Jan 7, 2019

I tried using the original GeoIP that comes with the AMXX 1.9 package - it didn't work.

I tried replacing the GeoIP files from this thread and it didn't work either.

Typing geoip dump <ip> in a clean 1.9 installation did nothing. Even writing only geoip doesn't print out any information in the console. It's like the module isn't even installed. The command doesn't exist in 1.8.2 either.

However, downloading GeoIP from the above link and putting it in 1.8.2 adds the command and it works. Doing the same in 1.9 adds the command, but it says Either look up failed or no found results.

@Arkshine
Copy link
Member

Arkshine commented Jan 7, 2019

This is not what I'm asking.

I'm asking you to download the latest GeoIP database.

Either: http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz or http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz

Use the AMXX 1.9 GeoIP module with the latest GeoIP database.

@OciXCrom
Copy link
Contributor Author

OciXCrom commented Jan 7, 2019

Yup, downloading the two files fixed both of the problems. I assume they should be included in the AMXX package by default.

@Arkshine
Copy link
Member

Arkshine commented Jan 7, 2019

You don't need both. The country version is the basic and provided by default. The city is not included by default because much larger as size. But you will need this file if you want to use the city-related natives.

The database should be automatically updated each month (if a build is triggered of course).

@OciXCrom
Copy link
Contributor Author

OciXCrom commented Jan 7, 2019

The GeoLite2-Country.mmdb file was updated 4 years ago, if that's what you meant. Anyways, this is a problem for all people who use the latest 1.9, not only for me.

@Arkshine
Copy link
Member

Arkshine commented Jan 7, 2019

It's because you did not update the database from AMXX 1.9. When a build is triggered, if the current saved database is older than one month, it will download and include the latest version. You can check the date. I'm referring to #524.

That's said, it looks like you need a build from this year. I've no idea why.
I hope the issue is not how the buildbot downloads the file and would corrupt it somehow.

@djearthquake
Copy link

djearthquake commented Jan 12, 2019

The reason geoip is not working is it was packed wrong in 1.9. Download a good copy from https://dev.maxmind.com/geoip/geoip2/geolite2. It was packed as filetype (application/x-tar) and should be Binary (application/octet-stream). Another way is to uncompress the packed version but why when you can get a clean copy?

@Arkshine
Copy link
Member

Makes sense: https://github.com/alliedmodders/amxmodx/pull/524/files#diff-c2a5b25b903e6036e1dc98654263b0cfR77

It's originally a copy-paste from SourceMod, but they're still using the old format which is only .gz and not tar.gz. Oopsie.

@abdobiskra
Copy link

This is not what I'm asking.

I'm asking you to download the latest GeoIP database.

Either: http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz or http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz

Use the AMXX 1.9 GeoIP module with the latest GeoIP database.

Hi, link is dead?

@0Ky
Copy link

0Ky commented Dec 22, 2023

I'm having the same issue as #653 (comment) running on Half-Life 11:26:46 Dec 11 2023 (9909) with AMXX and GeoIP v1.9.0.5294. Also, the links @Arkshine provided in #653 (comment) are dead, the URLs require a (free) license key for access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants