]> source.dussan.org Git - nextcloud-server.git/commitdiff
Improve local IP detection
authorCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 27 Jun 2022 14:48:58 +0000 (16:48 +0200)
committerCôme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com>
Tue, 12 Jul 2022 09:49:27 +0000 (09:49 +0000)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
lib/private/Http/Client/LocalAddressChecker.php

index c69d1007a160e6fa48bfb9f9889f09fb04c7c1ce..b233f34b19c63c6aa3f5f81062295449ee96b824 100644 (file)
@@ -41,6 +41,12 @@ class LocalAddressChecker {
                        throw new LocalServerException('Host violates local access rules');
                }
 
+               $localIps = ['100.100.100.200'];
+               if ((bool)filter_var($ip, FILTER_VALIDATE_IP) && in_array($ip, $localIps)) {
+                       $this->logger->warning("Host $ip was not connected to because it violates local access rules");
+                       throw new LocalServerException('Host violates local access rules');
+               }
+
                // Also check for IPv6 IPv4 nesting, because that's not covered by filter_var
                if ((bool)filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) && substr_count($ip, '.') > 0) {
                        $delimiter = strrpos($ip, ':'); // Get last colon