Skip to content

Commit 81143e2

Browse files
committed
Merge branch 'master' into develop
2 parents 2716ff8 + bd58750 commit 81143e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+304
-191
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@ This file is a running track of new features and fixes to each version of the pa
33

44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

6+
## v0.7.15 (Derelict Dermodactylus)
7+
### Fixed
8+
* Fixes support for PHP 7.3 when running `composer install` commands due to a dependency that needed updating.
9+
* Automatic allocation field when creating a new node (or updating one) should now properly remeber its old
10+
value when showing an error state.
11+
* Mass deleting files now executes properly and doesn't result in a JS console error.
12+
* Scrolling on email settings page now works.
13+
* Database host management will now properly display an error message to the user when there is any type of MySQL related
14+
error encountered during creation or update.
15+
* Two-factor tokens generated when a company name has a space in it will now properly be parsed on iOS authenticator devices.
16+
* Fixed 500 error when trying to request subuser's from a server in the application API.
17+
* Creating a node allocation via the API no longer requires an alias field be passed through in the request.
18+
* Bulk power management for servers via the CLI no longer fails when servers span multiple nodes.
19+
20+
### Added
21+
* Server listing view now displays the total used disk space for each server.
22+
* Client API endpoint to list all servers now supports an additional `?filter=subuser-of|all|admin|owner` parameter to
23+
return different groupings of servers. The default value is `subuser-of` which will include all of the user's servers
24+
that they are the owner of, as well as all servers they're a subuser of.
25+
* Added back ability to toggle OOM killer status on a per-server basis.
26+
* Added `LOCK TABLES` permission for generated database users.
27+
28+
### Changed
29+
* Updated Paper egg to not download `server.properties` each time. [parkervcp/eggs#260](https://github.com/parkervcp/eggs/issues/260)
30+
* Insurgency egg now uses the proper dedicated server ID.
31+
* Teamspeak egg updated with improved installation process and grabbing latest versions.
32+
* OOM killer disabled by default on all new servers.
33+
* Passwords generated for MySQL now include special characters and are 24 characters in length.
34+
635
## v0.7.14 (Derelict Dermodactylus)
736
### Fixed
837
* **[SECURITY]** Fixes an XSS vulnerability when performing certain actions in the file manager.

app/Console/Commands/Server/BulkPowerActionCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ public function handle()
102102
$bar->clear();
103103

104104
try {
105-
$this->powerRepository->setServer($server)->sendSignal($action);
105+
$this->powerRepository
106+
->setNode($server->node)
107+
->setServer($server)
108+
->sendSignal($action);
106109
} catch (RequestException $exception) {
107110
$this->output->error(trans('command/messages.server.power.action_failed', [
108111
'name' => $server->name,

app/Http/Controllers/Admin/DatabaseController.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Pterodactyl\Http\Controllers\Admin;
44

5+
use Exception;
56
use PDOException;
67
use Illuminate\View\View;
78
use Pterodactyl\Models\DatabaseHost;
@@ -118,17 +119,22 @@ public function view(int $host): View
118119
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
119120
* @return \Illuminate\Http\RedirectResponse
120121
*
121-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
122-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
122+
* @throws \Throwable
123123
*/
124124
public function create(DatabaseHostFormRequest $request): RedirectResponse
125125
{
126126
try {
127127
$host = $this->creationService->handle($request->normalize());
128-
} catch (PDOException $ex) {
129-
$this->alert->danger($ex->getMessage())->flash();
130-
131-
return redirect()->route('admin.databases');
128+
} catch (Exception $exception) {
129+
if ($exception instanceof PDOException || $exception->getPrevious() instanceof PDOException) {
130+
$this->alert->danger(
131+
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
132+
)->flash();
133+
134+
redirect()->route('admin.databases')->withInput($request->validated());
135+
} else {
136+
throw $exception;
137+
}
132138
}
133139

134140
$this->alert->success('Successfully created a new database host on the system.')->flash();
@@ -143,8 +149,7 @@ public function create(DatabaseHostFormRequest $request): RedirectResponse
143149
* @param \Pterodactyl\Models\DatabaseHost $host
144150
* @return \Illuminate\Http\RedirectResponse
145151
*
146-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
147-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
152+
* @throws \Throwable
148153
*/
149154
public function update(DatabaseHostFormRequest $request, DatabaseHost $host): RedirectResponse
150155
{
@@ -153,9 +158,17 @@ public function update(DatabaseHostFormRequest $request, DatabaseHost $host): Re
153158
try {
154159
$this->updateService->handle($host->id, $request->normalize());
155160
$this->alert->success('Database host was updated successfully.')->flash();
156-
} catch (PDOException $ex) {
157-
$this->alert->danger($ex->getMessage())->flash();
158-
$redirect->withInput($request->normalize());
161+
} catch (Exception $exception) {
162+
// Catch any SQL related exceptions and display them back to the user, otherwise just
163+
// throw the exception like normal and move on with it.
164+
if ($exception instanceof PDOException || $exception->getPrevious() instanceof PDOException) {
165+
$this->alert->danger(
166+
sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage())
167+
)->flash();
168+
$redirect->withInput($request->normalize());
169+
} else {
170+
throw $exception;
171+
}
159172
}
160173

161174
return $redirect;

app/Http/Controllers/Admin/ServersController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public function updateBuild(Request $request, Server $server)
516516
$this->buildModificationService->handle($server, $request->only([
517517
'allocation_id', 'add_allocations', 'remove_allocations',
518518
'memory', 'swap', 'io', 'cpu', 'disk',
519-
'database_limit', 'allocation_limit',
519+
'database_limit', 'allocation_limit', 'oom_disabled',
520520
]));
521521
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
522522

@@ -589,8 +589,7 @@ public function newDatabase(StoreServerDatabaseRequest $request, $server)
589589
* @param int $server
590590
* @return \Illuminate\Http\RedirectResponse
591591
*
592-
* @throws \Exception
593-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
592+
* @throws \Throwable
594593
*/
595594
public function resetDatabasePassword(Request $request, $server)
596595
{
@@ -599,7 +598,7 @@ public function resetDatabasePassword(Request $request, $server)
599598
['id', '=', $request->input('database')],
600599
]);
601600

602-
$this->databasePasswordService->handle($database, str_random(24));
601+
$this->databasePasswordService->handle($database);
603602

604603
return response('', 204);
605604
}

app/Http/Controllers/Api/Application/Servers/DatabaseController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ public function view(GetServerDatabaseRequest $request): array
8787
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
8888
* @return \Illuminate\Http\Response
8989
*
90-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
91-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
90+
* @throws \Throwable
9291
*/
9392
public function resetPassword(ServerDatabaseWriteRequest $request): Response
9493
{
95-
$this->databasePasswordService->handle($request->getModel(Database::class), str_random(24));
94+
$this->databasePasswordService->handle($request->getModel(Database::class));
9695

9796
return response('', 204);
9897
}

app/Http/Controllers/Api/Client/ClientController.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,28 @@ public function __construct(ServerRepositoryInterface $repository)
3535
*/
3636
public function index(GetServersRequest $request): array
3737
{
38-
$servers = $this->repository
38+
// Check for the filter parameter on the request.
39+
switch ($request->input('filter')) {
40+
case 'all':
41+
$filter = User::FILTER_LEVEL_ALL;
42+
break;
43+
case 'admin':
44+
$filter = User::FILTER_LEVEL_ADMIN;
45+
break;
46+
case 'owner':
47+
$filter = User::FILTER_LEVEL_OWNER;
48+
break;
49+
case 'subuser-of':
50+
default:
51+
$filter = User::FILTER_LEVEL_SUBUSER;
52+
break;
53+
}
54+
55+
$servers = $this->repository->
3956
->setSearchTerm($request->input('query'))
40-
->filterUserAccessServers($request->user(), User::FILTER_LEVEL_ALL);
57+
->filterUserAccessServers(
58+
$request->user(), $filter, config('pterodactyl.paginate.frontend.servers')
59+
);
4160

4261
return $this->fractal->collection($servers)
4362
->transformWith($this->getTransformer(ServerTransformer::class))

app/Http/Requests/Api/Application/Allocations/StoreAllocationRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function validated()
4040
return [
4141
'allocation_ip' => $data['ip'],
4242
'allocation_ports' => $data['ports'],
43-
'allocation_alias' => $data['alias'],
43+
'allocation_alias' => $data['alias'] ?? null,
4444
];
4545
}
4646
}

app/Http/Requests/Api/Application/Servers/StoreServerRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function rules(): array
4141
'startup' => $rules['startup'],
4242
'environment' => 'present|array',
4343
'skip_scripts' => 'sometimes|boolean',
44+
'oom_disabled' => 'sometimes|boolean',
4445

4546
// Resource limitations
4647
'limits' => 'required|array',

app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function rules(): array
1818

1919
return [
2020
'allocation' => $rules['allocation_id'],
21+
'oom_disabled' => $rules['oom_disabled'],
2122

2223
'limits' => 'sometimes|array',
2324
'limits.memory' => $this->requiredToOptional('memory', $rules['memory'], true),

app/Models/Server.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ class Server extends Model implements CleansAttributes, ValidableContract
2828
*/
2929
protected $table = 'servers';
3030

31+
/**
32+
* Default values when creating the model. We want to switch to disabling OOM killer
33+
* on server instances unless the user specifies otherwise in the request.
34+
*
35+
* @var array
36+
*/
37+
protected $attributes = [
38+
'oom_disabled' => true,
39+
];
40+
3141
/**
3242
* The attributes that should be mutated to dates.
3343
*
@@ -53,6 +63,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
5363
'swap' => 'required',
5464
'io' => 'required',
5565
'cpu' => 'required',
66+
'oom_disabled' => 'sometimes',
5667
'disk' => 'required',
5768
'nest_id' => 'required',
5869
'egg_id' => 'required',
@@ -79,6 +90,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
7990
'swap' => 'numeric|min:-1',
8091
'io' => 'numeric|between:10,1000',
8192
'cpu' => 'numeric|min:0',
93+
'oom_disabled' => 'boolean',
8294
'disk' => 'numeric|min:0',
8395
'allocation_id' => 'bail|unique:servers|exists:allocations,id',
8496
'nest_id' => 'exists:nests,id',
@@ -107,7 +119,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
107119
'disk' => 'integer',
108120
'io' => 'integer',
109121
'cpu' => 'integer',
110-
'oom_disabled' => 'integer',
122+
'oom_disabled' => 'boolean',
111123
'allocation_id' => 'integer',
112124
'nest_id' => 'integer',
113125
'egg_id' => 'integer',
@@ -164,11 +176,11 @@ public function user()
164176
/**
165177
* Gets the subusers associated with a server.
166178
*
167-
* @return \Illuminate\Database\Eloquent\Relations\HasMany
179+
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
168180
*/
169181
public function subusers()
170182
{
171-
return $this->hasMany(Subuser::class);
183+
return $this->hasManyThrough(User::class, Subuser::class, 'server_id', 'id', 'id', 'user_id');
172184
}
173185

174186
/**

0 commit comments

Comments
 (0)