Skip to content
Merged
Changes from all commits
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
handle IPv6 addresses with an explict incoming interface at the end (…
…e.g fe80::ae2d:d1e7:fe1e:9a8d%enp2s0)

Signed-off-by: Konrad Bucheli <[email protected]>
Signed-off-by: Konrad Bucheli <[email protected]>
  • Loading branch information
Konrad Bucheli committed Dec 10, 2019
commit f2d3e34c96ded153a095508f4dcd4fc76d9a9a8c
4 changes: 4 additions & 0 deletions lib/private/Security/Normalizer/IpAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ private function getIPv6Subnet(string $ip, int $maskBits = 48): string {
if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1]
$ip = substr($ip, 1, strlen($ip) - 2);
}
$pos = strpos($ip, '%'); // if there is an explicit interface added to the IP, e.g. fe80::ae2d:d1e7:fe1e:9a8d%enp2s0
if ($pos !== false) {
$ip = substr($ip, 0, $pos-1);
}
$binary = \inet_pton($ip);
for ($i = 128; $i > $maskBits; $i -= 8) {
$j = \intdiv($i, 8) - 1;
Expand Down