On examining the code I noticed this module is IPv4 only by the way the IP addresses are checked.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

panthar’s picture

Whenever I become a maintainer, I would be happy to fix this.

panthar’s picture

Category: bug » task
panthar’s picture

Priority: Normal » Major
james.wilson’s picture

Assigned: Unassigned » james.wilson

IPv6 support will be added with a D7 version and backported to the 6.x-3.x branch.

lochii’s picture

Here is a patch to 6.x-2.x-dev to enable IPv6 support:

http://www.convergence.cx/scripts/restrict_by_ip.module.ipv6.patch

I'm using this happily on a large, production site (which happens to be PHP 5.3.2 )

panthar’s picture

Has anyone else tested this patch?

bart.hanssens’s picture

Didn't test it, just wondering if the IPv4/ IPv6 validation could be replaced by just

function _validate_address($ip) {
return is_string(inet_pton($ip));
}

geodaniel’s picture

Status: Active » Needs review
panthar’s picture

ya problem for me is, I don't really understand ipv6 to know what will work/does not work.

rocketeerbkw’s picture

Issue summary: View changes
StatusFileSize
new6.65 KB

Just uploading the patch from #5.

rocketeerbkw’s picture

Version: 6.x-1.x-dev » 8.x-4.x-dev
Assigned: james.wilson » Unassigned
Category: Task » Feature request
Status: Needs review » Active
tcorneli’s picture

StatusFileSize
new4.15 KB

New patch for latest dev. Thanks to @lochii for previous patch.

tcorneli’s picture

StatusFileSize
new4.15 KB

Sorry, previous patch contained error.

tcorneli’s picture

StatusFileSize
new4.02 KB
new4.02 KB

This patch fixes the issue where IPv6 wasn't validated correctly.

tcorneli’s picture

Status: Active » Needs review
darvanen’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Agree this is vaulable, just needs tests to make it part of the module.

darvanen’s picture

This change is badly needed for the test suite to run green because gitlab CI uses IPv6 in Functional tests, however, it is currently failing at the Unit test:

There were 3 failures:
1) Drupal\Tests\restrict_by_ip\Unit\UnitTest::testIpFailValidation with data set #3 ('127.0.0.1/8', 'Invalid /8')
Failed asserting that exception of type "Drupal\restrict_by_ip\Exception\InvalidIPException" is thrown.
/builds/project/restrict_by_ip/vendor/bin/phpunit:122
2) Drupal\Tests\restrict_by_ip\Unit\UnitTest::testIpFailValidation with data set #4 ('127.0.0.1/16', 'Invalid /16')
Failed asserting that exception of type "Drupal\restrict_by_ip\Exception\InvalidIPException" is thrown.
/builds/project/restrict_by_ip/vendor/bin/phpunit:122
3) Drupal\Tests\restrict_by_ip\Unit\UnitTest::testIpFailValidation with data set #5 ('127.0.0.1/24', 'Invalid /24')
Failed asserting that exception of type "Drupal\restrict_by_ip\Exception\InvalidIPException" is thrown.
/builds/project/restrict_by_ip/vendor/bin/phpunit:122
darvanen’s picture

Status: Needs work » Needs review

Seems Symfony's IPUtils doesn't check for valid CIDR ranges so that had to be put back in for IPv4 addresses.

I will admit I asked Junie (AI) to add some IPv6 testing data to the Unit test but I have looked them over and they seem right to me.

All tests are passing both locally and in the CI.

I'll leave this a short while for review and if there are no comments I'll commit it.

  • darvanen committed b81157ca on 8.x-4.x
    Issue #721684 by tcorneli, darvanen, rocketeerbkw: Not IPv6 compatible
    
darvanen’s picture

Status: Needs review » Fixed

I think that's long enough :)

Status: Fixed » Closed (fixed)

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