Support

Admin Tools

#31793 AdminTools Geographic Blocking feature is not working!

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by on Thursday, 24 October 2019 17:17 CDT

rokkhit
Hi,
AdminTools Geographic Blocking feature is not working.
* I have already gone through ticket no. 24279 – geographical blocking not working.
I am aware that GeoLite2 free database is not precise enough.
However, I think that this is not a database-precision problem. I think that it is an issue with the implementation of this feature within AdminTools itself.

It looks as if this feature is unable to read the GeoLite2 free database itself.

Why?

Because of the following line in the notice:

Your server reports your IP as 60.146.107.174 and MaxMind's GeoIP library reports your location as ,

The GeoIP library should produce a location, but it did not.

Please refer to the attached screenshot for details.

Please look to matter and let me know your opinion.

Best regards,
Rokkhit.

nicholas
Akeeba Staff
Manager
First of all, I object to your assumption that our software doesn’t work. This is not conducive to helping you. I have good reasons to believe that your assumption is false, least of all is that I’m seeing my GeoIP location in my email now that I logged in to reply to your ticket. Having a contrarian starting position implies that you are unwilling to accept that the problem may lie outside our software. This makes it impossible for me to assist you in locating the root cause even if it’s outside our control and help you address it. If you are, however, willing to consider that appearances can be deceiving, have an open mind and are willing to let me help you please read on.

First, I’d like to present my arguments for reasonably disputing your claim that our software does not work.

The geographic database features are provided by the GeoIP plugin which is a simple interface to MaxMind’s PHP library for using their GeoIP databases. To be specific, the code that converts the IP address to a country and continent (the MaxMind GeoIP library for PHP) is written by MaxMind itself, not Akeeba Ltd. We only wrote a plugin which acts as a wrapper (an interface) to it. We did that because Joomla requires installing a Joomla extension to make a third party library available to it. Moreover, our code handles the update of the GeoIP database file, something that MaxMind’s code does not. So, whenever you are thinking about what happens when converting an IP to geographic information: it is MaxMind’s code, not Akeeba’s code, doing it.

We of course use the GeoIP plugin on our own sites, including this one you’re filing the ticket on. We log in to our sites multiple times every day and we receive emails confirming our location — like I did a few minutes ago and I see that my IP is correct, just like my detected country and continent. Same goes for security exceptions which I personally monitor. Furthermore, the same plugin is used by our subscriptions system to determine the country of new clients. It is also used in other cases where we are logging IP addresses, such as downloads that I monitor (I need to know where downloads come from so I can figure out which downloads need to be on a speedier but more expensive CDN). As a result I have thousands more data points every single day than you do in total and the unequivocal conclusion is that our GeoIP plugin and MaxMind’s library code work within the operating parameters MaxMind gives. That is to say, GeoIP is correct for 19 out of 20 cases.

Furthermore, this feature is so prominent and necessary for our own site that it gets its own set of automated tests. This is part of the integration test suite that runs every time before we release a new version of Admin Tools. We automatically spin up new Joomla sites, Admin Tools and the GeoIP plugin are installed, enabled and configured and a variety of scenarios is acted upon these sites. Some of the scenarios include auto-blocking IPs, GeoIP blocking and confirming that the IP to country and territory is working (using a set of IPs from long-standing IPv4 blocks of major ISPs across the world). If something breaks we know before we release our software. If I see something weird I run the tests even if we’re not expected to release Admin Tools anytime soon.

That said, there are many things which could go wrong with GeoIP, none of which is actually under the control of Akeeba Ltd and are not bugs in our software.

The first obvious issue is whether your server reports the correct IP address. Based on your feedback this is not a problem in your case so I’m not going to provide a three page long diatribe on everything that can go wrong on that front :)

If you have not installed or enabled the GeoIP plugin yet, do so now (our software asks you to). If the plugin is not enabled the GeoIP feature will not work. In these two cases you would, indeed, get an empty geolocation result like the one you say you are getting. At no point in your ticket do I see you saying that you have installed and enabled the plugin.

Also, the plugin is not enough. It is just an interface to MaxMInd’s code. You need to update the GeoIP database that is included with it. In fact, the database file included with it is at this point about three years old and severely out of date. If you just installed the plugin follow the documentation instructions for updating its database. If your database is out of date and your IP is unrecognized it would indeed result in an empty geolocation result. The latest version of MaxMind’s GeoIP database does report your IP as being from Japan, I just checked.

If you are doing a manual update remember to extract (NOT rename) the GZipped database file. If you only have the .mmdb.gz file it won’t work. If you rename the .mmdb.gz file to have an .mmdb extension it won’t work. If you use gunzip or a respectable GUI tool supporting .gz files such as 7-Zip to extract the .mmdb.gz file to a .mmdb file it will work. If you use the integrated update it does that for you.

If you use the integrated update it is possible that your host blocks the download and results in a zero-length file. If that’s the case you need to contact your host.

Make sure the MaxMind database file does exist in the location the documentation instructions tell you it should be for manual updates and that it’s readable. Some hosts do stupid things, like renaming or deleting legitimate files under a false pretext of security, telling you the affected file was suspicious or malicious. Unfortunately we can’t do anything about hosts being misleading except call them out on their lies by providing facts.

Also note that MaxMind’s code that we cannot touch, the code that actually converts IPs to geolocation information, requires certain PHP modules to be enabled. If these modules are disabled on your host then it won’t work and return an empty geolocation result. This is normal and doesn’t mean that we have a bug in our software, it means that your host does not meet the minimum requirements of the MaxMind GeoIP database library code.

Finally, if MaxMind’s library is already loaded either by another Joomla extension or as a PHP module we cannot tell it where to look for the GeoIP database file. Therefore it is possible that there is no GeoIP database (.mmdb) file loaded OR an invalid / out of date file. This will result in MaxMind’s library code return empty GeoIP results. Again, this is not a bug in our software, it’s a third party extension or your host doing something wrong. And yes, I’ve seen that a few times about 7 years ago. Just because it hasn’t happened for a very long time doesn’t mean that someone didn’t find a fresh way to screw up, so I keep an open mind about this possibility :)

Please check these items above and you’ll see that if everything is in order our feature (in fact, MaxMind’s code) works fine. If you still can’t figure out what’s wrong ask me to make the ticket private and I’ll ask you for connection info to your site so I can debug it for you and tell you what you need to fix.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

rokkhit
Hi Nicholas,
Thanks for your detailed overview on the Geographic Blocking feature and your thoughts as a developer.
Let me tell you that being an user of AdminTools for a long time, I do not have any doubts of its ability to protect my websites.
I can now understand that I should have worded the issue summary in present continuous tense (...is not working), rather than in present tense (...does not work). (^^)
Your guidance worked well for me to get to the core of the issue. The issue occurred due to the broken GeoIP database.
I updated the database, wrote a script to update it weekly and now it works flawlessly.
I have another inquiry (rather, a feature request) for Geographic Blocking, for which I will issue another ticket.

Thank you for your support.
You may close this ticket.

Best Regards,
Rokkhit

nicholas
Akeeba Staff
Manager
No problem! I'm glad this issue is sorted out :)

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

System Task
system
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!