X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FJSONSchema.pm;h=028766c13e07459122d03331400f6428bdebd53b;hp=bed19f476db744e31b5bf161b4b93b51294e5927;hb=ed5880acdc77673c98ac25fcc4c58201832b9de7;hpb=b0edd8e6d202a7502409c56c9d569745a9d6f943 diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index bed19f4..028766c 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -147,13 +147,35 @@ register_format('ipv4', \&pve_verify_ipv4); sub pve_verify_ipv4 { my ($ipv4, $noerr) = @_; - if (!Net::IP::ip_is_ipv4($ipv4)) { - return undef if $noerr; - die "value does not look like a valid IP address\n"; + if ($ipv4 !~ m/^(?:$IPV4RE)$/) { + return undef if $noerr; + die "value does not look like a valid IPv4 address\n"; } return $ipv4; } +register_format('ipv6', \&pve_verify_ipv6); +sub pve_verify_ipv4 { + my ($ipv6, $noerr) = @_; + + if ($ipv6 !~ m/^(?:$IPV6RE)$/) { + return undef if $noerr; + die "value does not look like a valid IPv6 address\n"; + } + return $ipv6; +} + +register_format('ip', \&pve_verify_ip); +sub pve_verify_ip { + my ($ip, $noerr) = @_; + + if ($ip !~ m/^(?:(?:$IPV4RE)|(?:$IPV6RE))$/) { + return undef if $noerr; + die "value does not look like a valid IP address\n"; + } + return $ip; +} + my $ipv4_mask_hash = { '128.0.0.0' => 1, '192.0.0.0' => 2, @@ -266,7 +288,7 @@ register_standard_option('remote-viewer-config', { }, }); -PVE::JSONSchema::register_format('pve-startup-order', \&pve_verify_startup_order); +register_format('pve-startup-order', \&pve_verify_startup_order); sub pve_verify_startup_order { my ($value, $noerr) = @_;