- Issue created by @ndf
- πΊπ¦Ukraine goodboy Kharkiv, Ukraine
Hi, Niels
Thanks for your proposition
I think we could use ip2country β
I'm not sure if the data on https://www.nirsoft.net/countryip/ is up to date, and the Drupal module seems pretty easy to use. - π³π±Netherlands ndf Amsterdam
Hi Serhii, yes ip2country module sounds like a better option! So that module already has the IP country data in it and fetches it regularly from ARIN.
Then we need a module that combines both; i.e. 'advban_ip2country' with a UI for administrators to select banned countries, and code that fetches the country ip-ranges from the ip2country module.
- πΊπ¦Ukraine goodboy Kharkiv, Ukraine
Niels,
I've installed the ip2country module and applied a patch from https://www.drupal.org/project/ip2country/issues/2571835 β¨ Use HTTP instead of FTP Needs review ( https://www.drupal.org/files/issues/2025-03-24/ip2country-2571835-21.patch β ).I think we need to create advban_bycountry submodule of the advban module.
We can get coutry code for user and check the selected forbidden countries from the module's setings.$ip = \Drupal::request()->getClientIp(); $country_code = \Drupal::service('ip2country.lookup')->getCountry($ip); if (in_array($country_code,$forbidded_countries)) { // Ban the ip in the middleware class }
We need also to get countries list for settings by combine 2 lists:
$countries = \Drupal\Core\Locale\CountryManager::getStandardList(); "SELECT country FROM {ip2country} GROUP BY country"
I think we need to create a plugins system, then use
getDefinitions()
andcreateInstance()
for checking all advban extentions.
After the submodule was completed we will have 2 ways for IP banning: by IP list and by country. What should be the priority? - πΊπ¦Ukraine goodboy Kharkiv, Ukraine
Niels, it's extremely hard for me - creating forks, merge requests. It's done in an inconvenient and unclear way.
I've created https://git.drupalcode.org/project/advban/-/merge_requests/8 - please review - πΊπ¦Ukraine goodboy Kharkiv, Ukraine
goodboy β changed the visibility of the branch 3524654-country_ban_request to hidden.
- πΊπ¦Ukraine goodboy Kharkiv, Ukraine
goodboy β changed the visibility of the branch 3524654-country-ban-request to hidden.