diff --git a/app/Repositories/NodeRepository.php b/app/Repositories/NodeRepository.php index 873bf2e90..104ba51f6 100644 --- a/app/Repositories/NodeRepository.php +++ b/app/Repositories/NodeRepository.php @@ -64,12 +64,14 @@ class NodeRepository { throw new DisplayValidationException($validator->errors()); } - // Verify the FQDN - if (filter_var($data['fqdn'], FILTER_VALIDATE_IP)) { - throw new DisplayException('The FQDN provided was an IP address. You must use a FQDN.'); + // Verify the FQDN if using SSL + if (filter_var($data['fqdn'], FILTER_VALIDATE_IP) && $data['scheme'] === 'https') { + throw new DisplayException('A fully qualified domain name is required to use secure comunication on this node.'); } + + // Verify FQDN is resolvable, or if not using SSL that the IP is valid. if (!filter_var(gethostbyname($data['fqdn']), FILTER_VALIDATE_IP)) { - throw new DisplayException('The FQDN provided does not resolve to a valid IP address.'); + throw new DisplayException('The FQDN (or IP Address) provided does not resolve to a valid IP address.'); } // Should we be nulling the overallocations? @@ -91,6 +93,8 @@ class NodeRepository { public function update($id, array $data) { + $node = Models\Node::findOrFail($id); + // Validate Fields $validator = $validator = Validator::make($data, [ 'name' => 'regex:/^([\w .-]{1,100})$/', @@ -116,12 +120,19 @@ class NodeRepository { // Verify the FQDN if (isset($data['fqdn'])) { - if (filter_var($data['fqdn'], FILTER_VALIDATE_IP)) { - throw new DisplayException('The FQDN provided was an IP address. You must use a FQDN.'); + + // Verify the FQDN if using SSL + if ((isset($data['scheme']) && $data['scheme'] === 'https') || (!isset($data['scheme']) && $node->scheme === 'https')) { + if (filter_var($data['fqdn'], FILTER_VALIDATE_IP)) { + throw new DisplayException('A fully qualified domain name is required to use secure comunication on this node.'); + } } + + // Verify FQDN is resolvable, or if not using SSL that the IP is valid. if (!filter_var(gethostbyname($data['fqdn']), FILTER_VALIDATE_IP)) { - throw new DisplayException('The FQDN provided does not resolve to a valid IP address.'); + throw new DisplayException('The FQDN (or IP Address) provided does not resolve to a valid IP address.'); } + } // Should we be nulling the overallocations? @@ -141,7 +152,6 @@ class NodeRepository { } // Store the Data - $node = Models\Node::findOrFail($id); return $node->update($data); } diff --git a/resources/views/admin/nodes/new.blade.php b/resources/views/admin/nodes/new.blade.php index 154fc31f5..0856c7c41 100644 --- a/resources/views/admin/nodes/new.blade.php +++ b/resources/views/admin/nodes/new.blade.php @@ -67,7 +67,7 @@
This must be a fully qualified domain name, you may not enter an IP address or a domain that does not exist. +
Please enter domain name (e.g node.example.com
) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.
Why?
This must be a fully qualified domain name, you may not enter an IP address or a domain that does not exist. +
Please enter domain name (e.g node.example.com
) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.
Why?