[Mageia-sysadm] [170] - fix the keyprefix for ipv6 here too ( patch by Maarten Vanraes )

root at mageia.org root at mageia.org
Thu Dec 16 01:34:17 CET 2010


Revision: 170
Author:   misc
Date:     2010-12-16 01:34:17 +0100 (Thu, 16 Dec 2010)
Log Message:
-----------
- fix the keyprefix for ipv6 here too ( patch by Maarten Vanraes )

Modified Paths:
--------------
    identity/CatDap/trunk/lib/CatDap/Controller/admin.pm

Modified: identity/CatDap/trunk/lib/CatDap/Controller/admin.pm
===================================================================
--- identity/CatDap/trunk/lib/CatDap/Controller/admin.pm	2010-12-16 00:33:50 UTC (rev 169)
+++ identity/CatDap/trunk/lib/CatDap/Controller/admin.pm	2010-12-16 00:34:17 UTC (rev 170)
@@ -47,7 +47,15 @@
     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')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20101216/1af6ab62/attachment.html>


More information about the Mageia-sysadm mailing list