use Storable; # for dclone
use Getopt::Long;
use Devel::Cycle -quiet; # todo: remove?
-use PVE::Tools qw(split_list);
+use PVE::Tools qw(split_list $IPV6RE $IPV4RE);
use PVE::Exception qw(raise);
use HTTP::Status qw(:constants);
use Net::IP qw(:PROC);
type => 'string', format => 'pve-storage-id',
});
+PVE::JSONSchema::register_standard_option('pve-config-digest', {
+ description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
+ type => 'string',
+ optional => 1,
+ maxLength => 40, # sha1 hex digest lenght is 40
+});
+
my $format_list = {};
sub register_format {
return $mask;
}
+register_format('CIDR', \&pve_verify_cidr);
+sub pve_verify_cidr {
+ my ($cidr, $noerr) = @_;
+
+ if ($cidr =~ m!^(?:$IPV4RE)(?:/(\d+))$! && ($1 > 7) && ($1 < 32)) {
+ return $cidr;
+ } elsif ($cidr =~ m!^(?:$IPV6RE)(?:/(\d+))$! && ($1 > 7) && ($1 <= 120)) {
+ return $cidr;
+ }
+
+ return undef if $noerr;
+ die "value does not look like a valid CIDR network\n";
+}
+
register_format('email', \&pve_verify_email);
sub pve_verify_email {
my ($email, $noerr) = @_;