diff options
author | Pascal Terjan <pterjan@gmail.com> | 2016-12-06 14:44:57 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@gmail.com> | 2016-12-06 14:44:57 +0000 |
commit | 0b509d832bfd5ecb416d8992b04055b866d534b7 (patch) | |
tree | 63f879a23a67247408ede43a789788b1c9c92223 | |
parent | 4bbd1931281df6c15b67bbe37883a482fc632fa3 (diff) | |
download | identity-0b509d832bfd5ecb416d8992b04055b866d534b7.tar identity-0b509d832bfd5ecb416d8992b04055b866d534b7.tar.gz identity-0b509d832bfd5ecb416d8992b04055b866d534b7.tar.bz2 identity-0b509d832bfd5ecb416d8992b04055b866d534b7.tar.xz identity-0b509d832bfd5ecb416d8992b04055b866d534b7.zip |
Better fix for handling IPv6 addresses
-rw-r--r-- | lib/CatDap/Controller/user.pm | 4 |
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 ); |