Skip to content

Commit 7c80588

Browse files
committed
Allow IP if not using SSL
1 parent 81da576 commit 7c80588

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

app/Repositories/NodeRepository.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ public function create(array $data)
6464
throw new DisplayValidationException($validator->errors());
6565
}
6666

67-
// Verify the FQDN
68-
if (filter_var($data['fqdn'], FILTER_VALIDATE_IP)) {
69-
throw new DisplayException('The FQDN provided was an IP address. You must use a FQDN.');
67+
// Verify the FQDN if using SSL
68+
if (filter_var($data['fqdn'], FILTER_VALIDATE_IP) && $data['scheme'] === 'https') {
69+
throw new DisplayException('A fully qualified domain name is required to use secure comunication on this node.');
7070
}
71+
72+
// Verify FQDN is resolvable, or if not using SSL that the IP is valid.
7173
if (!filter_var(gethostbyname($data['fqdn']), FILTER_VALIDATE_IP)) {
72-
throw new DisplayException('The FQDN provided does not resolve to a valid IP address.');
74+
throw new DisplayException('The FQDN (or IP Address) provided does not resolve to a valid IP address.');
7375
}
7476

7577
// Should we be nulling the overallocations?
@@ -91,6 +93,8 @@ public function create(array $data)
9193

9294
public function update($id, array $data)
9395
{
96+
$node = Models\Node::findOrFail($id);
97+
9498
// Validate Fields
9599
$validator = $validator = Validator::make($data, [
96100
'name' => 'regex:/^([\w .-]{1,100})$/',
@@ -116,12 +120,19 @@ public function update($id, array $data)
116120

117121
// Verify the FQDN
118122
if (isset($data['fqdn'])) {
119-
if (filter_var($data['fqdn'], FILTER_VALIDATE_IP)) {
120-
throw new DisplayException('The FQDN provided was an IP address. You must use a FQDN.');
123+
124+
// Verify the FQDN if using SSL
125+
if ((isset($data['scheme']) && $data['scheme'] === 'https') || (!isset($data['scheme']) && $node->scheme === 'https')) {
126+
if (filter_var($data['fqdn'], FILTER_VALIDATE_IP)) {
127+
throw new DisplayException('A fully qualified domain name is required to use secure comunication on this node.');
128+
}
121129
}
130+
131+
// Verify FQDN is resolvable, or if not using SSL that the IP is valid.
122132
if (!filter_var(gethostbyname($data['fqdn']), FILTER_VALIDATE_IP)) {
123-
throw new DisplayException('The FQDN provided does not resolve to a valid IP address.');
133+
throw new DisplayException('The FQDN (or IP Address) provided does not resolve to a valid IP address.');
124134
}
135+
125136
}
126137

127138
// Should we be nulling the overallocations?
@@ -141,7 +152,6 @@ public function update($id, array $data)
141152
}
142153

143154
// Store the Data
144-
$node = Models\Node::findOrFail($id);
145155
return $node->update($data);
146156

147157
}

resources/views/admin/nodes/new.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<div>
6868
<input type="text" autocomplete="off" name="fqdn" class="form-control" value="{{ old('fqdn') }}" />
6969
</div>
70-
<p class="text-muted"><small>This <strong>must</strong> be a fully qualified domain name, you may not enter an IP address or a domain that does not exist.
70+
<p class="text-muted"><small>Please enter domain name (e.g <code>node.example.com</code>) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.
7171
<a tabindex="0" data-toggle="popover" data-trigger="focus" title="Why do I need a FQDN?" data-content="In order to secure communications between your server and this node we use SSL. We cannot generate a SSL certificate for IP Addresses, and as such you will need to provide a FQDN.">Why?</a>
7272
</small></p>
7373
</div>

resources/views/admin/nodes/view.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
<div>
150150
<input type="text" autocomplete="off" name="fqdn" class="form-control" value="{{ old('fqdn', $node->fqdn) }}" />
151151
</div>
152-
<p class="text-muted"><small>This <strong>must</strong> be a fully qualified domain name, you may not enter an IP address or a domain that does not exist.
152+
<p class="text-muted"><small>Please enter domain name (e.g <code>node.example.com</code>) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.
153153
<a tabindex="0" data-toggle="popover" data-trigger="focus" title="Why do I need a FQDN?" data-content="In order to secure communications between your server and this node we use SSL. We cannot generate a SSL certificate for IP Addresses, and as such you will need to provide a FQDN.">Why?</a>
154154
</small></p>
155155
</div>

0 commit comments

Comments
 (0)