aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>2025-04-08 11:15:30 +0200
committerGitHub <noreply@github.com>2025-04-08 11:15:30 +0200
commit59444784f2e7b121983ee3ed6b33428b62eb0b27 (patch)
treeb1c377dbe14329bb618242d64efb66709b2d4ab3
parent95eeb9f2988d85627252e904ec451f5180886968 (diff)
parentc4021c8d3863624c25782956db21272862ed7d19 (diff)
downloadnextcloud-server-59444784f2e7b121983ee3ed6b33428b62eb0b27.tar.gz
nextcloud-server-59444784f2e7b121983ee3ed6b33428b62eb0b27.zip
Merge pull request #52015 from nextcloud/feat/larger_ipv6_range
feat(ip): use larger IPv6 range by default
-rw-r--r--lib/private/Security/Normalizer/IpAddress.php8
-rw-r--r--tests/lib/Security/Normalizer/IpAddressTest.php10
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php
index e9232c5fe9f..6ef8763f6d9 100644
--- a/lib/private/Security/Normalizer/IpAddress.php
+++ b/lib/private/Security/Normalizer/IpAddress.php
@@ -24,7 +24,7 @@ class IpAddress {
}
/**
- * Return the given subnet for an IPv6 address (64 first bits)
+ * Return the given subnet for an IPv6 address (48 first bits)
*/
private function getIPv6Subnet(string $ip): string {
if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1]
@@ -36,9 +36,9 @@ class IpAddress {
}
$binary = \inet_pton($ip);
- $mask = inet_pton('FFFF:FFFF:FFFF:FFFF::');
+ $mask = inet_pton('FFFF:FFFF:FFFF::');
- return inet_ntop($binary & $mask) . '/64';
+ return inet_ntop($binary & $mask) . '/48';
}
/**
@@ -63,7 +63,7 @@ class IpAddress {
/**
- * Gets either the /32 (IPv4) or the /64 (IPv6) subnet of an IP address
+ * Gets either the /32 (IPv4) or the /48 (IPv6) subnet of an IP address
*/
public function getSubnet(): string {
if (filter_var($this->ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
diff --git a/tests/lib/Security/Normalizer/IpAddressTest.php b/tests/lib/Security/Normalizer/IpAddressTest.php
index 55cb149309a..c2989c44ef2 100644
--- a/tests/lib/Security/Normalizer/IpAddressTest.php
+++ b/tests/lib/Security/Normalizer/IpAddressTest.php
@@ -36,20 +36,20 @@ class IpAddressTest extends TestCase {
'192.168.0.123/32',
],
[
- '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
- '2001:db8:85a3::/64',
+ '2001:0db8:0000:0000:0000:8a2e:0370:7334',
+ '2001:db8::/48',
],
[
'2001:db8:3333:4444:5555:6666:7777:8888',
- '2001:db8:3333:4444::/64',
+ '2001:db8:3333::/48',
],
[
'::1234:5678',
- '::/64',
+ '::/48',
],
[
'[::1]',
- '::/64',
+ '::/48',
],
];
}