aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/CatDap/Controller/user.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm
index 6f8ac9f..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'; }
@@ -118,8 +119,7 @@ sub get_keyprefix : Private {
if ($c->req->address =~ m/:/) {
# For IPv6 the first 3 can be special and shared by many people,
# bytes 6-8 are more interesting
- my @address_chunks = split /:/, $c->req->address;
- $keyprefix = sprintf( "%02x%02x%02x", splice(@address_chunks, 5, 3));
+ $keyprefix = substr(unpack('H*', inet_pton(AF_INET6, $c->req->address)), 10, 6);
}
else {
$keyprefix = sprintf( "%02x%02x%02x", split /\./, $c->req->address );