From 9aa0a5137730d580da32a7ad53f5f12a0057b6dc Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 6 Dec 2016 13:54:37 +0000 Subject: Fix prefix for IPv6 users Argument "2a00:79e0:d:302:7ce7:3d64:23ac:b212" isn't numeric in right bitshift (>>) at /var/www/identity/script/../lib/CatDap/Controller/user.pm line 123 --- lib/CatDap/Controller/user.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm index e6cc7a1..8c14cfd 100644 --- a/lib/CatDap/Controller/user.pm +++ b/lib/CatDap/Controller/user.pm @@ -116,11 +116,9 @@ sub get_keyprefix : Private { my ( $self, $c ) = @_; my $keyprefix; if ($c->req->address =~ m/:/) { - my $address = $c->req->address; - $address =~ s/\[\]://; - - # if we shift right 104 bits from 128 we have 24 bits left or 3 bytes. - $keyprefix = sprintf( "%06x", $address >> 104 ); + # For IPv6 the first 3 can be special and shared by many people, + # bytes 6-8 are more interesting + $keyprefix = sprintf( "%02x%02x%02x", splice(5, 3, split /:/, $c->req->address)); } else { $keyprefix = sprintf( "%02x%02x%02x", split /\./, $c->req->address ); -- cgit v1.2.1