From: Carl Vuosalo Date: Fri, 7 Mar 2025 22:28:30 +0000 (+0100) Subject: Correct ipv6 host name for EL8 and EL9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F270%2Fhead;p=thirdparty%2FAWStats.git Correct ipv6 host name for EL8 and EL9 --- diff --git a/wwwroot/cgi-bin/plugins/ipv6.pm b/wwwroot/cgi-bin/plugins/ipv6.pm index 14857ee5..fe4cb8e5 100644 --- a/wwwroot/cgi-bin/plugins/ipv6.pm +++ b/wwwroot/cgi-bin/plugins/ipv6.pm @@ -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]; # -----> }