]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Correct ipv6 host name for EL8 and EL9 270/head
authorCarl Vuosalo <cvuosalo@cern.ch>
Fri, 7 Mar 2025 22:28:30 +0000 (23:28 +0100)
committerCarl Vuosalo <cvuosalo@cern.ch>
Fri, 7 Mar 2025 22:28:30 +0000 (23:28 +0100)
wwwroot/cgi-bin/plugins/ipv6.pm

index 14857ee5f2ff873c8fad9172bbfce70a44dc365f..fe4cb8e59d926ee6205f0c4ebb8b49d229fc32ea 100644 (file)
@@ -63,8 +63,12 @@ sub GetResolvedIP_ipv6 {
        my $query = $resolver->query($reverseip, "PTR");
        if (! defined($query)) { return; }
        my @result=split(/\s/, ($query->answer)[0]->string);
-       chop($result[4]); # Remove the trailing dot of the answer.
-       return $result[4];
+       my $hostindex = 6;
+       # Host name appears at index 6 on EL8 and EL9.
+       # On older operating systems, it appears at index 4 at the array's end.
+       if ($hostindex > $#result) { $hostindex = $#result; }
+       chop($result[$hostindex]); # Remove the trailing dot of the answer.
+       return $result[$hostindex];
        # ----->
 }