From 4282d933bc11034e0cc8ad680a7789482ba4b33f Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Thu, 16 Dec 2010 00:34:17 +0000 Subject: - fix the keyprefix for ipv6 here too ( patch by Maarten Vanraes ) --- lib/CatDap/Controller/admin.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/CatDap/Controller') diff --git a/lib/CatDap/Controller/admin.pm b/lib/CatDap/Controller/admin.pm index b324421..2ae362b 100644 --- a/lib/CatDap/Controller/admin.pm +++ b/lib/CatDap/Controller/admin.pm @@ -47,7 +47,15 @@ sub auto : Private { my $password; my $mesg; my $dn; - my $keyprefix = sprintf( "%02x%02x%02x", split /\./, $c->req->address ); + my $keyprefix; + if ($c->req->address =~ m/:/) { + my $address = $c->req->address; + $address =~ s/\[\]://; + $keyprefix = sprintf( "%06x", $address >> 104 ); # if we shift right 104 bits from 128 we have 24 bits left or 3 bytes. + } + else { + $keyprefix = sprintf( "%02x%02x%02x", split /\./, $c->req->address ); + } if ( !defined $c->user or not $c->req->cookie('key') ) { $c->detach('/user/login') if ( not $c->req->param('username') -- cgit v1.2.1