Skip to content

Commit 0b044b3

Browse files
committed
fixes bug that would allow deleting the default allocation for a server.
1 parent 0a481b3 commit 0b044b3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/Repositories/ServerRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,12 @@ public function changeBuild($id, array $data)
537537
list($ip, $port) = explode(':', $combo);
538538
// Invalid, not worth killing the whole thing, we'll just skip over it.
539539
if (!filter_var($ip, FILTER_VALIDATE_IP) || !preg_match('/^(\d{1,5})$/', $port)) {
540-
continue;
540+
break;
541541
}
542542

543543
// Can't remove the assigned IP/Port combo
544544
if ($ip === $allocation->ip && $port === $allocation->port) {
545-
continue;
545+
break;
546546
}
547547

548548
Models\Allocation::where('ip', $ip)->where('port', $port)->where('assigned_to', $server->id)->update([
@@ -558,12 +558,12 @@ public function changeBuild($id, array $data)
558558
list($ip, $port) = explode(':', $combo);
559559
// Invalid, not worth killing the whole thing, we'll just skip over it.
560560
if (!filter_var($ip, FILTER_VALIDATE_IP) || !preg_match('/^(\d{1,5})$/', $port)) {
561-
continue;
561+
break;
562562
}
563563

564564
// Don't allow double port assignments
565565
if (Models\Allocation::where('port', $port)->where('assigned_to', $server->id)->count() !== 0) {
566-
continue;
566+
break;
567567
}
568568

569569
Models\Allocation::where('ip', $ip)->where('port', $port)->whereNull('assigned_to')->update([

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
<div>
286286
<select name="remove_additional[]" class="form-control" multiple>
287287
@foreach ($assigned as $assignment)
288-
<option value="{{ $assignment->ip }}:{{ $assignment->port }}">@if(!is_null($assignment->ip_alias)){{ $assignment->ip_alias }}@else{{ $assignment->ip }}@endif:{{ $assignment->port }} @if(!is_null($assignment->ip_alias))(alias of {{ $assignment->ip }})@endif</option>
288+
<option value="{{ $assignment->ip }}:{{ $assignment->port }}" @if($server->allocation === $assignment->id)disabled @endif>@if(!is_null($assignment->ip_alias)){{ $assignment->ip_alias }}@else{{ $assignment->ip }}@endif:{{ $assignment->port }} @if(!is_null($assignment->ip_alias))(alias of {{ $assignment->ip }})@endif</option>
289289
@endforeach
290290
</select>
291291
</div>

0 commit comments

Comments
 (0)