Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve local IP detection
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc authored and backportbot-nextcloud[bot] committed Jul 26, 2022
commit c0be5cc91da925fc5f6f03f8d08c87300c649be5
6 changes: 6 additions & 0 deletions lib/private/Http/Client/LocalAddressChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public function ThrowIfLocalIp(string $ip) : void {
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
Expand Down