X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXUtil.pm;fp=perl%2FDXUtil.pm;h=b01c234b80bfeea0bf1f60b25cf1679f546b8af0;hb=d0b21f21559a63d84086b549bb7570e2e16b75cd;hp=b89d88ea9a89def800ffdfcba3ba39d1cc4e26aa;hpb=49d7cd28623df3c4accf72d48f74b4b00238a81a;p=spider.git diff --git a/perl/DXUtil.pm b/perl/DXUtil.pm index b89d88ea..b01c234b 100644 --- a/perl/DXUtil.pm +++ b/perl/DXUtil.pm @@ -15,6 +15,7 @@ use File::Copy; use Data::Dumper; use Time::HiRes qw(gettimeofday tv_interval); use Text::Wrap; +use Socket qw(AF_INET6 AF_INET inet_pton); use strict; @@ -448,7 +449,18 @@ sub is_latlong # is it an ip address? sub is_ipaddr { - return $_[0] =~ /^(?:(?:\:\:)?\d+\.\d+\.\d+\.\d+)|(?:[0-9a-f]{1,4}\:)?(?:\:[0-9a-f]{1,4}(?:\:\:)?){1,6}$/i; + + if ($_[0] =~ /:/) { + if (inet_pton(AF_INET6, $_[0])) { + return ($_[0] =~ /([:0-9a-f]+)/); + } +# use re 'debug'; +# return ($1) if $_[0] =~ /^(\:?(?:\:?[0-9a-f]{1,4}){1,8}?)$/i; +# no re 'debug'; + } else { + return ($_[0] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/); + } + return undef; } # is it a zulu time hhmmZ