Skip to content

Commit 6bd9663

Browse files
committed
Merge branch 'develop' into feature/service-changes
2 parents a49dee2 + c09170a commit 6bd9663

File tree

136 files changed

+2440
-1707
lines changed

Some content is hidden

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

136 files changed

+2440
-1707
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["es2015"],
3+
"compact": true,
4+
"minified": true,
5+
"only": "public/js/files/*.js",
6+
"sourceMaps": "inline",
7+
"comments": false
8+
}

.editorconfig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ root = true
33
[*]
44
end_of_line = lf
55
insert_final_newline = true
6-
7-
[*.{php,js,html,css}]
8-
charset = utf-8
96
indent_style = space
107
indent_size = 4
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ Homestead.yaml
99
Vagrantfile
1010
Vagrantfile
1111

12-
node_modules
13-
.babelrc
12+
node_modules

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ 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.5.6 (Bodacious Boreopterus)
7+
### Added
8+
* 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.
9+
* Added missing `strings.password` to language file for English.
10+
* Allow listing of users from the API by passing either the user ID or their email.
11+
12+
### Fixed
13+
* Fixes bug where assigning a variable a default value (or valid value) of `0` would cause the panel to reject the value thinking it did not exist.
14+
* Addresses potential for crash by limiting total ports that can be assigned per-range to 2000.
15+
* Fixes server names requiring at minimum 4 characters. Name can now be 1 to 200 characters long. :pencil2:
16+
* Fixes bug that would allow adding the owner of a server as a subuser for that same server.
17+
* Fixes bug that would allow creating multiple subusers with the same email address.
18+
* Fixes bug where Sponge servers were improperly tagged as a spigot server in the daemon causing issues when booting or modifying configuration files.
19+
* Use transpiled ES6 -> ES5 filemanager code in browsers.
20+
* Fixes service option name displaying the name of a nwly added variable after the variable is added and until the page is refreshed. (see #208)
21+
22+
### Changed
23+
* Filemanager and EULA checking javascript is now written in pure ES6 code rather than as a blade-syntax template. This allows the use of babel to transpile into ES5 as a minified version.
24+
625
## v0.5.5 (Bodacious Boreopterus)
726
### Added
827
* New API route to return allocations given a server ID. This adds support for a community-driven WHMCS module :rocket: available [here](https://github.com/hammerdawn/Pterodactyl-WHMCS).

app/Http/Controllers/API/UserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function lists(Request $request)
7575
*/
7676
public function view(Request $request, $id)
7777
{
78-
$query = Models\User::where('id', $id);
78+
$query = Models\User::where((is_numeric($id) ? 'id' : 'email'), $id);
7979

8080
if (! is_null($request->input('fields'))) {
8181
foreach (explode(',', $request->input('fields')) as $field) {

app/Http/Controllers/Admin/NodesController.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use DB;
2828
use Log;
2929
use Alert;
30+
use Carbon;
3031
use Validator;
3132
use Pterodactyl\Models;
3233
use Illuminate\Http\Request;
@@ -82,6 +83,7 @@ public function postNew(Request $request)
8283
'_token',
8384
]));
8485
Alert::success('Successfully created new node. <strong>Before you can add any servers you need to first assign some IP addresses and ports.</strong>')->flash();
86+
Alert::info('<strong>To simplify the node setup you can generate a token on the configuration tab.</strong>')->flash();
8587

8688
return redirect()->route('admin.nodes.view', [
8789
'id' => $new,
@@ -276,4 +278,24 @@ public function deleteNode(Request $request, $id)
276278
'tab' => 'tab_delete',
277279
]);
278280
}
281+
282+
public function getConfigurationToken(Request $request, $id)
283+
{
284+
// Check if Node exists. Will lead to 404 if not.
285+
Models\Node::findOrFail($id);
286+
287+
// Create a token
288+
$token = new Models\NodeConfigurationToken();
289+
$token->node = $id;
290+
$token->token = str_random(32);
291+
$token->expires_at = Carbon::now()->addMinutes(5); // Expire in 5 Minutes
292+
$token->save();
293+
294+
$token_response = [
295+
'token' => $token->token,
296+
'expires_at' => $token->expires_at->toDateTimeString(),
297+
];
298+
299+
return response()->json($token_response, 200);
300+
}
279301
}

app/Http/Controllers/Admin/ServiceController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function postNewVariable(Request $request, $service, $option)
232232
]));
233233
Alert::success('Successfully added new variable to this option.')->flash();
234234

235-
return redirect()->route('admin.services.option', [$service, $option])->withInput();
235+
return redirect()->route('admin.services.option', [$service, $option]);
236236
} catch (DisplayValidationException $ex) {
237237
return redirect()->route('admin.services.option.variable.new', [$service, $option])->withErrors(json_decode($ex->getMessage()))->withInput();
238238
} catch (DisplayException $ex) {

app/Http/Controllers/Base/LanguageController.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@
3333
class LanguageController extends Controller
3434
{
3535
protected $languages = [
36-
'de' => 'Danish',
36+
'de' => 'German',
3737
'en' => 'English',
38-
'es' => 'Spanish',
39-
'fr' => 'French',
40-
'it' => 'Italian',
41-
'pl' => 'Polish',
38+
'et' => 'Estonian',
39+
'nb' => 'Norwegian',
40+
'nl' => 'Dutch',
4241
'pt' => 'Portuguese',
42+
'ro' => 'Romanian',
4343
'ru' => 'Russian',
44-
'se' => 'Swedish',
45-
'zh' => 'Chinese',
4644
];
4745

4846
/**

app/Http/Controllers/Remote/RemoteController.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
namespace Pterodactyl\Http\Controllers\Remote;
2626

27+
use Carbon\Carbon;
2728
use Pterodactyl\Models;
2829
use Illuminate\Http\Request;
2930
use Pterodactyl\Http\Controllers\Controller;
@@ -107,4 +108,29 @@ public function event(Request $request)
107108

108109
return response('', 201);
109110
}
111+
112+
public function getConfiguration(Request $request, $tokenString)
113+
{
114+
// Try to query the token and the node from the database
115+
try {
116+
$token = Models\NodeConfigurationToken::where('token', $tokenString)->firstOrFail();
117+
$node = Models\Node::findOrFail($token->node);
118+
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
119+
return response()->json(['error' => 'token_invalid'], 403);
120+
}
121+
122+
// Check if token is expired
123+
if ($token->expires_at->lt(Carbon::now())) {
124+
$token->delete();
125+
126+
return response()->json(['error' => 'token_expired'], 403);
127+
}
128+
129+
// Delete the token, it's one-time use
130+
$token->delete();
131+
132+
// Manually as getConfigurationAsJson() returns it in correct format already
133+
return response($node->getConfigurationAsJson(), 200)
134+
->header('Content-Type', 'application/json');
135+
}
110136
}

app/Http/Controllers/Server/ServerController.php

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
use Log;
2929
use Uuid;
3030
use Alert;
31+
use Javascript;
3132
use Pterodactyl\Models;
3233
use Illuminate\Http\Request;
33-
use InvalidArgumentException;
3434
use Pterodactyl\Exceptions\DisplayException;
3535
use Pterodactyl\Http\Controllers\Controller;
3636
use Pterodactyl\Repositories\ServerRepository;
@@ -49,24 +49,6 @@ public function __construct()
4949
//
5050
}
5151

52-
public function getJavascript(Request $request, $uuid, $folder, $file)
53-
{
54-
$server = Models\Server::getByUUID($uuid);
55-
56-
$info = pathinfo($file);
57-
$routeFile = str_replace('/', '.', $info['dirname']) . '.' . $info['filename'];
58-
try {
59-
return response()->view('server.js.' . $folder . '.' . $routeFile, [
60-
'server' => $server,
61-
'node' => Models\Node::find($server->node),
62-
])->header('Content-Type', 'application/javascript');
63-
} catch (InvalidArgumentException $ex) {
64-
return abort(404);
65-
} catch (\Exception $ex) {
66-
throw $ex;
67-
}
68-
}
69-
7052
/**
7153
* Renders server index page for specified server.
7254
*
@@ -77,6 +59,13 @@ public function getIndex(Request $request)
7759
{
7860
$server = Models\Server::getByUUID($request->route()->server);
7961

62+
Javascript::put([
63+
'meta' => [
64+
'saveFile' => route('server.files.save', $server->uuidShort),
65+
'csrfToken' => csrf_token(),
66+
],
67+
]);
68+
8069
return view('server.index', [
8170
'server' => $server,
8271
'allocations' => Models\Allocation::where('assigned_to', $server->id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(),
@@ -90,14 +79,34 @@ public function getIndex(Request $request)
9079
* @param Request $request
9180
* @return \Illuminate\Contracts\View\View
9281
*/
93-
public function getFiles(Request $request)
82+
public function getFiles(Request $request, $uuid)
9483
{
95-
$server = Models\Server::getByUUID($request->route()->server);
84+
$server = Models\Server::getByUUID($uuid);
9685
$this->authorize('list-files', $server);
9786

87+
$node = Models\Node::find($server->node);
88+
89+
Javascript::put([
90+
'server' => collect($server->makeVisible('daemonSecret'))->only('uuid', 'uuidShort', 'daemonSecret'),
91+
'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'),
92+
'meta' => [
93+
'directoryList' => route('server.files.directory-list', $server->uuidShort),
94+
'csrftoken' => csrf_token(),
95+
],
96+
'permissions' => [
97+
'moveFiles' => $request->user()->can('move-files', $server),
98+
'copyFiles' => $request->user()->can('copy-files', $server),
99+
'compressFiles' => $request->user()->can('compress-files', $server),
100+
'decompressFiles' => $request->user()->can('decompress-files', $server),
101+
'createFiles' => $request->user()->can('create-files', $server),
102+
'downloadFiles' => $request->user()->can('download-files', $server),
103+
'deleteFiles' => $request->user()->can('delete-files', $server),
104+
],
105+
]);
106+
98107
return view('server.files.index', [
99108
'server' => $server,
100-
'node' => Models\Node::find($server->node),
109+
'node' => $node,
101110
]);
102111
}
103112

@@ -107,9 +116,9 @@ public function getFiles(Request $request)
107116
* @param Request $request
108117
* @return \Illuminate\Contracts\View\View
109118
*/
110-
public function getAddFile(Request $request)
119+
public function getAddFile(Request $request, $uuid)
111120
{
112-
$server = Models\Server::getByUUID($request->route()->server);
121+
$server = Models\Server::getByUUID($uuid);
113122
$this->authorize('add-files', $server);
114123

115124
return view('server.files.add', [

0 commit comments

Comments
 (0)