diff options
author | Pascal Terjan <pterjan@mageia.org> | 2018-02-18 13:16:49 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@mageia.org> | 2018-02-18 13:16:49 +0000 |
commit | 87776c2ce990581276d971ec5ed683d8534181a9 (patch) | |
tree | 78f01c810adfc6fd46bc0f8f731ff6f7263eccf5 /lib/CatDap/Controller | |
parent | 03ad6872d6b375bd46ad7380b6274365a0f9d019 (diff) | |
parent | 48d92c25023fa8fae2cbd4de4b06b7f1b604f0a9 (diff) | |
download | identity-topic/production.tar identity-topic/production.tar.gz identity-topic/production.tar.bz2 identity-topic/production.tar.xz identity-topic/production.zip |
Merge branch 'master' into topic/productiontopic/production
Diffstat (limited to 'lib/CatDap/Controller')
-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 ); |