Problem/Motivation

Sometimes we want to have a more persistent ban alongside the less permanent ones.

Steps to reproduce

Proposed resolution

Add a new button with callback to "Ban indefinitely". The actual ban period is limited to the year 2038 because of the storage limitations, but it should suffice.

Remaining tasks

Discuss proposed solution.

User interface changes

API changes

Data model changes

Comments

Primsi created an issue. See original summary.

primsi’s picture

Status: Active » Needs review
StatusFileSize
new3.31 KB

Initial patch.

berdir’s picture

Status: Needs review » Needs work
+++ b/auto_unban.module
@@ -82,3 +90,24 @@ function auto_unban_form_ban_ip_form_alter(array &$form, FormStateInterface $for
+    $time = \Drupal::time();
+    // Ban for as much as the db field allows us.
+    $ip_manager->setBanDurationOverride(2147483647 - $time->getCurrentTime());
+    $ip_manager->banIp($ip);

I think if we go with a separate submit button then a new method that's banIpIndefinitely() or banIpWithExpire() makes more sense, we don't need to introduce state in the storage then.

primsi’s picture

Status: Needs work » Needs review
StatusFileSize
new2.96 KB
new2.77 KB

Thanks. Seems it's fine even with just a new argument (that's what the module is doing anyway with $attempts).

primsi’s picture

Few notes for the maintainer:

  1. +++ b/auto_unban.module
    @@ -1,5 +1,6 @@
    +use Drupal\auto_unban\BanIpManager as AutoUnbanBanIpManager;
    

    I aliased this for a bit better code clarity, because the replacement class auto_unban provides has the same name as the one that it substitutes.

  2. +++ b/auto_unban.module
    @@ -15,7 +24,7 @@ function auto_unban_form_ban_ip_form_alter(array &$form, FormStateInterface $for
    +      'data' => t('Ban count'),
    

    We discussed with @Berdir, that just Count is a bit confusing. So we are proposing here a small renaming. Sorry for the scope creep.

berdir’s picture

Title: Add option to ban indifenitely (sort of) » Add option to ban indefinitely (sort of)
andybroomfield’s picture

Status: Needs review » Reviewed & tested by the community

Have tested this and selecting add indefinatly does ban the IP address with a date set to 2038 (max unix time stamp).

  • douggreen committed 748cde0c on 1.0.x
    Issue #3395292: Add option to ban indefinitely (sort of)
    
douggreen’s picture

Committed, I wasn't initially a fan of this, but as an option it's certainly valuable.

douggreen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.