Fix allocation selection
This commit is contained in:
parent
ae843a72c6
commit
be48fbd418
2 changed files with 19 additions and 15 deletions
|
@ -211,24 +211,24 @@ class AjaxController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$repo = new Repositories\ServerRepository;
|
$repo = new Repositories\ServerRepository;
|
||||||
$repo->changeBuild($server->id, [
|
$repo->changeBuild($server->id, [
|
||||||
'default' => $request->input('connection'),
|
'default' => $request->input('connection'),
|
||||||
]);
|
]);
|
||||||
return response('The default connection for this server has been updated. Please be aware that you will need to restart your server for this change to go into effect.');
|
return response('The default connection for this server has been updated. Please be aware that you will need to restart your server for this change to go into effect.');
|
||||||
|
} catch (\Pterodactyl\Exceptions\DisplayValidationException $ex) {
|
||||||
} catch (\Exception $e) {
|
return response()->json([
|
||||||
if ($e instanceof \Pterodactyl\Exceptions\DisplayException || $e instanceof \Pterodactyl\Exceptions\DisplayValidationException) {
|
'error' => json_decode($ex->getMessage(), true),
|
||||||
return response()->json([
|
], 503);
|
||||||
'error' => $e->getMessage(),
|
} catch (\Pterodactyl\Exceptions\DisplayException $ex) {
|
||||||
], 503);
|
return response()->json([
|
||||||
} else {
|
'error' => $ex->getMessage(),
|
||||||
Log::error($e);
|
], 503);
|
||||||
return response()->json([
|
} catch (\Exception $ex) {
|
||||||
'error' => 'An unhandled exception occured while attemping to modify the default connection for this server.'
|
Log::error($ex);
|
||||||
], 503);
|
return response()->json([
|
||||||
}
|
'error' => 'An unhandled exception occured while attemping to modify the default connection for this server.'
|
||||||
|
], 503);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -416,9 +416,9 @@ class ServerRepository
|
||||||
if (isset($data['default'])) {
|
if (isset($data['default'])) {
|
||||||
list($ip, $port) = explode(':', $data['default']);
|
list($ip, $port) = explode(':', $data['default']);
|
||||||
if ($ip !== $server->ip || $port !== $server->port) {
|
if ($ip !== $server->ip || $port !== $server->port) {
|
||||||
$allocation = Models\Allocation::where('ip', $ip)->where('port', $port)->where('assigned_to', $server->id)->get();
|
$allocation = Models\Allocation::where('ip', $ip)->where('port', $port)->where('assigned_to', $server->id)->first();
|
||||||
if (!$allocation) {
|
if (!$allocation) {
|
||||||
throw new DisplayException('The assigned default connection (' . $ip . ':' . $port . ') is not allocated to this server.');
|
throw new DisplayException('The requested default connection (' . $ip . ':' . $port . ') is not allocated to this server.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$server->ip = $ip;
|
$server->ip = $ip;
|
||||||
|
@ -532,6 +532,10 @@ class ServerRepository
|
||||||
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
} catch (\GuzzleHttp\Exception\TransferException $ex) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
throw new DisplayException('An error occured while attempting to update the configuration: ' . $ex->getMessage());
|
throw new DisplayException('An error occured while attempting to update the configuration: ' . $ex->getMessage());
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
DB::rollBack();
|
||||||
|
Log::error($ex);
|
||||||
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue