diff options
Diffstat (limited to 'lib/CatDap/Controller/user.pm')
-rw-r--r-- | lib/CatDap/Controller/user.pm | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm index e6cc7a1..4bfc4ed 100644 --- a/lib/CatDap/Controller/user.pm +++ b/lib/CatDap/Controller/user.pm @@ -7,6 +7,7 @@ use Net::LDAP::Extension::SetPassword; use Net::LDAP::Control::PasswordPolicy 0.02; use Crypt::CBC; use Data::UUID; +use Socket qw(inet_pton AF_INET6); #use Data::Dumper; BEGIN {extends 'Catalyst::Controller'; } @@ -116,11 +117,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 = substr(unpack('H*', inet_pton(AF_INET6, $c->req->address)), 10, 6); } else { $keyprefix = sprintf( "%02x%02x%02x", split /\./, $c->req->address ); |