diff options
Diffstat (limited to 'plugins-scripts/utils.pm.in')
-rw-r--r-- | plugins-scripts/utils.pm.in | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in index e2458359..8449b544 100644 --- a/plugins-scripts/utils.pm.in +++ b/plugins-scripts/utils.pm.in @@ -53,9 +53,16 @@ sub usage { sub is_hostname { my $host1 = shift; - if ($host1 && $host1 =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z0-9][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*)$/) { + return 0 unless defined $host1; + if ($host1 =~ m/^[\d\.]+$/ && $host1 !~ /\.$/) { + if ($host1 =~ m/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) { + return 1; + } else { + return 0; + } + } elsif ($host1 =~ m/^[a-zA-Z0-9][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*\.?$/) { return 1; - }else{ + } else { return 0; } } |