mirror of
git://git.proxmox.com/git/pve-common.git
synced 2025-02-09 17:57:21 +03:00
Modified IPv4 validation function, included Net::IP
Signed-off-by: Damien PIQUET <piqudam@gmail.com>
This commit is contained in:
parent
a13c6f08a3
commit
23b5624575
@ -8,6 +8,7 @@ use Devel::Cycle -quiet; # todo: remove?
|
|||||||
use PVE::Tools qw(split_list);
|
use PVE::Tools qw(split_list);
|
||||||
use PVE::Exception qw(raise);
|
use PVE::Exception qw(raise);
|
||||||
use HTTP::Status qw(:constants);
|
use HTTP::Status qw(:constants);
|
||||||
|
use Net::IP qw(:PROC);
|
||||||
|
|
||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
|
|
||||||
@ -140,10 +141,7 @@ register_format('ipv4', \&pve_verify_ipv4);
|
|||||||
sub pve_verify_ipv4 {
|
sub pve_verify_ipv4 {
|
||||||
my ($ipv4, $noerr) = @_;
|
my ($ipv4, $noerr) = @_;
|
||||||
|
|
||||||
if ($ipv4 !~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ ||
|
if (!Net::IP::ip_is_ipv4($ipv4)) {
|
||||||
!(($1 > 0) && ($1 < 255) &&
|
|
||||||
($2 <= 255) && ($3 <= 255) &&
|
|
||||||
($4 > 0) && ($4 < 255))) {
|
|
||||||
return undef if $noerr;
|
return undef if $noerr;
|
||||||
die "value does not look like a valid IP address\n";
|
die "value does not look like a valid IP address\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user