Skip to content

Commit 31864de

Browse files
authored
Merge pull request pterodactyl#248 from Pterodactyl/feature/service-changes
Feature/service changes
2 parents c09170a + 3a4d3fb commit 31864de

Some content is hidden

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

51 files changed

+2520
-98
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
root = true
22

33
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
46
indent_style = space
57
indent_size = 4
68
charset = utf-8
79
trim_trailing_whitespace = true
8-
insert_final_newline = true
910

1011
[*.md]
1112
trim_trailing_whitespace = false

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ 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.6.0-pre.1
7+
### Added
8+
* Remote routes for daemon to contact in order to allow Daemon to retrieve updated service configuration files on boot. Centralizes services to the panel rather than to each daemon.
9+
* Basic service pack implementation to allow assignment of modpacks or software to a server to pre-install applications and allow users to update.
10+
* Users can now have a username as well as client name assigned to thier account.
11+
12+
### Fixed
13+
* Bug causing error logs to be spammed if someone timed out on an ajax based page.
14+
15+
### Changed
16+
* Admin API and base routes for user management now define the fields that should be passed to repositories rather than passing all fields.
17+
* User model now defines mass assignment fields using `$fillable` rather than `$guarded`.
18+
19+
### Deprecated
20+
621
## v0.5.6 (Bodacious Boreopterus)
722
### Added
823
* Added the following languages: Estonian `et`, Dutch `nl`, Norwegian `nb` (partial), Romanian `ro`, and Russian `ru`. Interested in helping us translate the panel into more languages, or improving existing translations? Contact us on Discord and let us know.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Console\Commands;
26+
27+
use Carbon;
28+
use Storage;
29+
use Illuminate\Console\Command;
30+
31+
class CleanServiceBackup extends Command
32+
{
33+
/**
34+
* The name and signature of the console command.
35+
*
36+
* @var string
37+
*/
38+
protected $signature = 'pterodactyl:cleanservices';
39+
40+
/**
41+
* The console command description.
42+
*
43+
* @var string
44+
*/
45+
protected $description = 'Cleans .bak files assocaited with service backups whene editing files through the panel.';
46+
47+
/**
48+
* Create a new command instance.
49+
*
50+
* @return void
51+
*/
52+
public function __construct()
53+
{
54+
parent::__construct();
55+
}
56+
57+
/**
58+
* Execute the console command.
59+
*
60+
* @return mixed
61+
*/
62+
public function handle()
63+
{
64+
$files = Storage::files('services/.bak');
65+
66+
foreach ($files as $file) {
67+
$lastModified = Carbon::createFromTimestamp(Storage::lastModified($file));
68+
if ($lastModified->diffInMinutes(Carbon::now()) > 5) {
69+
$this->info('Deleting ' . $file);
70+
Storage::delete($file);
71+
}
72+
}
73+
}
74+
}

app/Console/Kernel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Kernel extends ConsoleKernel
2121
\Pterodactyl\Console\Commands\ClearTasks::class,
2222
\Pterodactyl\Console\Commands\ClearServices::class,
2323
\Pterodactyl\Console\Commands\UpdateEmailSettings::class,
24+
\Pterodactyl\Console\Commands\CleanServiceBackup::class,
2425
];
2526

2627
/**
@@ -33,5 +34,6 @@ protected function schedule(Schedule $schedule)
3334
{
3435
$schedule->command('pterodactyl:tasks')->everyMinute()->withoutOverlapping();
3536
$schedule->command('pterodactyl:tasks:clearlog')->twiceDaily(3, 15);
37+
$schedule->command('pterodactyl:cleanservices')->twiceDaily(1, 13);
3638
}
3739
}

app/Exceptions/Handler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ public function report(Exception $exception)
4646
*/
4747
public function render($request, Exception $exception)
4848
{
49-
if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('remote/*')) {
49+
if ($request->expectsJson()) {
5050
$response = response()->json([
5151
'error' => ($exception instanceof DisplayException) ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.',
52-
], 500);
52+
], ($this->isHttpException($exception)) ? $e->getStatusCode() : 500);
5353

54-
// parent::render() will log it, we are bypassing it in this case.
55-
Log::error($exception);
54+
parent::report($exception);
5655
}
5756

5857
return (isset($response)) ? $response : parent::render($request, $exception);

app/Http/Controllers/API/UserController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public function create(Request $request)
122122
{
123123
try {
124124
$user = new UserRepository;
125+
$create = $user->create($request->only([
126+
'email', 'username', 'name_first', 'name_last', 'password', 'root_admin', 'custom_id',
127+
]));
125128
$create = $user->create($request->input('email'), $request->input('password'), $request->input('admin'), $request->input('custom_id'));
126129

127130
return ['id' => $create];
@@ -156,7 +159,9 @@ public function update(Request $request, $id)
156159
{
157160
try {
158161
$user = new UserRepository;
159-
$user->update($id, $request->all());
162+
$user->update($id, $request->only([
163+
'username', 'email', 'name_first', 'name_last', 'password', 'root_admin', 'language',
164+
]));
160165

161166
return Models\User::findOrFail($id);
162167
} catch (DisplayValidationException $ex) {

0 commit comments

Comments
 (0)