fix styleci issues

This commit is contained in:
Jakob Schrettenbrunner 2017-01-07 18:39:41 +01:00
parent cc0d54e906
commit a661f71974
3 changed files with 43 additions and 39 deletions

View file

@ -279,7 +279,8 @@ class NodesController extends Controller
]); ]);
} }
public function getConfigurationToken(Request $request, $id) { public function getConfigurationToken(Request $request, $id)
{
// Check if Node exists. Will lead to 404 if not. // Check if Node exists. Will lead to 404 if not.
Models\Node::findOrFail($id); Models\Node::findOrFail($id);
@ -290,10 +291,10 @@ class NodesController extends Controller
$token->expires_at = Carbon::now()->addMinutes(5); // Expire in 5 Minutes $token->expires_at = Carbon::now()->addMinutes(5); // Expire in 5 Minutes
$token->save(); $token->save();
$token_response = array( $token_response = [
'token' => $token->token, 'token' => $token->token,
'expires_at' => $token->expires_at->toDateTimeString() 'expires_at' => $token->expires_at->toDateTimeString(),
); ];
return response(json_encode($token_response), 200) return response(json_encode($token_response), 200)
->header('Content-Type', 'application/json'); ->header('Content-Type', 'application/json');

View file

@ -29,7 +29,6 @@ use Pterodactyl\Models;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\NotificationService; use Pterodactyl\Services\NotificationService;
use Pterodactyl\Models\NodeConfigurationToken;
class RemoteController extends Controller class RemoteController extends Controller
{ {
@ -110,20 +109,21 @@ class RemoteController extends Controller
return response('', 201); return response('', 201);
} }
public function getConfiguration(Request $request, $tokenString) { public function getConfiguration(Request $request, $tokenString)
{
// Try to query the token and the node from the database // Try to query the token and the node from the database
try { try {
$token = Models\NodeConfigurationToken::where('token', $tokenString)->firstOrFail(); $token = Models\NodeConfigurationToken::where('token', $tokenString)->firstOrFail();
$node = Models\Node::findOrFail($token->node); $node = Models\Node::findOrFail($token->node);
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return response(json_encode(array('error' => 'token_invalid')), 403) return response(json_encode(['error' => 'token_invalid']), 403)
->header('Content-Type', 'application/json'); ->header('Content-Type', 'application/json');
} }
// Check if token is expired // Check if token is expired
if ($token->expires_at->lt(Carbon::now())) { if ($token->expires_at->lt(Carbon::now())) {
$token->delete(); $token->delete();
return response(json_encode(array('error' => 'token_expired')), 403) return response(json_encode(['error' => 'token_expired']), 403)
->header('Content-Type', 'application/json'); ->header('Content-Type', 'application/json');
} }

View file

@ -119,55 +119,58 @@ class Node extends Model
} }
/** /**
* Returns the configuration in JSON format * Returns the configuration in JSON format.
* *
* @param boolean $pretty Wether to pretty print the JSON or not * @param bool $pretty Wether to pretty print the JSON or not
* @return string The configration in JSON format * @return string The configration in JSON format
*/ */
public function getConfigurationAsJson($pretty = false) { public function getConfigurationAsJson($pretty = false)
$config = array( {
'web' => array( $config = [
'web' => [
'host' => '0.0.0.0', 'host' => '0.0.0.0',
'listen' => $this->daemonListen, 'listen' => $this->daemonListen,
'ssl' => array( 'ssl' => [
'enabled' => $this->scheme === 'https', 'enabled' => $this->scheme === 'https',
'certificate' => '/etc/letsencrypt/live/localhost/fullchain.pem', 'certificate' => '/etc/letsencrypt/live/localhost/fullchain.pem',
'key' => '/etc/letsencrypt/live/localhost/privkey.pem' 'key' => '/etc/letsencrypt/live/localhost/privkey.pem',
) ],
), ],
'docker' => array( 'docker' => [
'socket' => '/var/run/docker.sock', 'socket' => '/var/run/docker.sock',
'autoupdate_images' => true 'autoupdate_images' => true,
), ],
'sftp' => array( 'sftp' => [
'path' => $this->daemonBase, 'path' => $this->daemonBase,
'port' => $this->daemonSFTP, 'port' => $this->daemonSFTP,
'container' => 'ptdl-sftp' 'container' => 'ptdl-sftp',
), ],
'query' => array( 'query' => [
'kill_on_fail' => true, 'kill_on_fail' => true,
'fail_limit' => 5 'fail_limit' => 5,
), ],
'logger' => array( 'logger' => [
'path' => 'logs/', 'path' => 'logs/',
'src' => false, 'src' => false,
'level' => 'info', 'level' => 'info',
'period' => '1d', 'period' => '1d',
'count' => 3 'count' => 3,
), ],
'remote' => array( 'remote' => [
'base' => config('app.url'), 'base' => config('app.url'),
'download' => route('remote.download'), 'download' => route('remote.download'),
'installed' => route('remote.install') 'installed' => route('remote.install'),
), ],
'uploads' => array( 'uploads' => [
'size_limit' => $this->upload_size 'size_limit' => $this->upload_size,
), ],
'keys' => array($this->daemonSecret) 'keys' => [$this->daemonSecret],
); ];
$json_options = JSON_UNESCAPED_SLASHES; $json_options = JSON_UNESCAPED_SLASHES;
if ($pretty) $json_options |= JSON_PRETTY_PRINT; if ($pretty) {
$json_options |= JSON_PRETTY_PRINT;
}
return json_encode($config, $json_options); return json_encode($config, $json_options);
} }