]> git.proxmox.com Git - pve-common.git/commitdiff
spice-proxy format now uses new address format
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 27 May 2015 11:16:35 +0000 (13:16 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 27 May 2015 13:32:11 +0000 (15:32 +0200)
spice-proxy used dns-name before which matches a combination of letters,
digits and dots, which happens to include ipv4 addresses but not ipv6
ones.
Since 'dns-name' sounds like it's only for names, I'm adding an address
format which is either a dns-name or an ip (including ipv6).

src/PVE/JSONSchema.pm

index e1485ff161f13343c5ca0768e4a575374c6a1da0..36a2de994e35cf1c7f8f4655a4f13c0334e6f5fc 100644 (file)
@@ -271,9 +271,23 @@ sub pve_verify_iface {
     return $id;
 }
 
+# general addresses by name or IP
+register_format('address', \&pve_verify_address);
+sub pve_verify_address {
+    my ($addr, $noerr) = @_;
+
+    if (!(pve_verify_ip($addr, 1) ||
+         pve_verify_dns_name($addr, 1)))
+    {
+          return undef if $noerr;
+          die "value does not look like a valid address: $addr\n";
+    }
+    return $addr;
+}
+
 register_standard_option('spice-proxy', {
     description => "SPICE proxy server. This can be used by the client to specify the proxy server. All nodes in a cluster runs 'spiceproxy', so it is up to the client to choose one. By default, we return the node where the VM is currently running. As resonable setting is to use same node you use to connect to the API (This is window.location.hostname for the JS GUI).",
-    type => 'string', format => 'dns-name',
+    type => 'string', format => 'address',
 }); 
 
 register_standard_option('remote-viewer-config', {