Skip to content

Commit b183430

Browse files
committed
Update demon routes to use /v1/
1 parent 15d38ce commit b183430

File tree

25 files changed

+55
-67
lines changed

25 files changed

+55
-67
lines changed

app/Http/Controllers/API/Remote/ValidateKeyController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
use Illuminate\Foundation\Testing\HttpException;
3131
use League\Fractal\Serializer\JsonApiSerializer;
3232
use Pterodactyl\Transformers\Daemon\ApiKeyTransformer;
33+
use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
34+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
3335
use Pterodactyl\Contracts\Repository\DaemonKeyRepositoryInterface;
3436

3537
class ValidateKeyController extends Controller
@@ -81,7 +83,11 @@ public function index($token)
8183
throw new HttpException(501);
8284
}
8385

84-
$key = $this->daemonKeyRepository->getKeyWithServer($token);
86+
try {
87+
$key = $this->daemonKeyRepository->getKeyWithServer($token);
88+
} catch (RecordNotFoundException $exception) {
89+
throw new NotFoundHttpException;
90+
}
8591

8692
return $this->fractal->item($key, $this->app->make(ApiKeyTransformer::class), 'server')
8793
->serializeWith(JsonApiSerializer::class)

app/Http/Controllers/Admin/OptionController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ public function editConfiguration(Request $request, ServiceOption $option)
194194
$this->optionUpdateService->handle($option, $request->all());
195195
$this->alert->success(trans('admin/services.options.notices.option_updated'))->flash();
196196
} catch (NoParentConfigurationFoundException $exception) {
197-
dd('hodor');
198197
$this->alert->danger($exception->getMessage())->flash();
199198
}
200199

app/Http/Controllers/Server/Files/DownloadController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function index($uuid, $file)
5555
$this->cache->tags(['Server:Downloads'])->put($token, ['server' => $server->uuid, 'path' => $file], 5);
5656

5757
return redirect(sprintf(
58-
'%s://%s:%s/server/file/download/%s', $server->node->scheme, $server->node->fqdn, $server->node->daemonListen, $token
58+
'%s://%s:%s/v1/server/file/download/%s', $server->node->scheme, $server->node->fqdn, $server->node->daemonListen, $token
5959
));
6060
}
6161
}

app/Models/Node.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Pterodactyl\Models;
1111

12-
use GuzzleHttp\Client;
1312
use Sofa\Eloquence\Eloquence;
1413
use Sofa\Eloquence\Validable;
1514
use Illuminate\Database\Eloquent\Model;
@@ -126,22 +125,6 @@ class Node extends Model implements CleansAttributes, ValidableContract
126125
'daemonListen' => 8080,
127126
];
128127

129-
/**
130-
* Return an instance of the Guzzle client for this specific node.
131-
*
132-
* @param array $headers
133-
* @return \GuzzleHttp\Client
134-
*/
135-
public function guzzleClient($headers = [])
136-
{
137-
return new Client([
138-
'base_uri' => sprintf('%s://%s:%s/', $this->scheme, $this->fqdn, $this->daemonListen),
139-
'timeout' => config('pterodactyl.guzzle.timeout'),
140-
'connect_timeout' => config('pterodactyl.guzzle.connect_timeout'),
141-
'headers' => $headers,
142-
]);
143-
}
144-
145128
/**
146129
* Returns the configuration in JSON format.
147130
*

app/Repositories/Daemon/BaseRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function getHttpClient(array $headers = [])
141141
}
142142

143143
return new Client([
144-
'base_uri' => sprintf('%s://%s:%s/', $this->getNode()->scheme, $this->getNode()->fqdn, $this->getNode()->daemonListen),
144+
'base_uri' => sprintf('%s://%s:%s/v1/', $this->getNode()->scheme, $this->getNode()->fqdn, $this->getNode()->daemonListen),
145145
'timeout' => $this->config->get('pterodactyl.guzzle.timeout'),
146146
'connect_timeout' => $this->config->get('pterodactyl.guzzle.connect_timeout'),
147147
'headers' => $headers,

app/Repositories/Daemon/CommandRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function send($command)
2121
{
2222
Assert::stringNotEmpty($command, 'First argument passed to send must be a non-empty string, received %s.');
2323

24-
return $this->getHttpClient()->request('POST', '/server/command', [
24+
return $this->getHttpClient()->request('POST', 'server/command', [
2525
'json' => [
2626
'command' => $command,
2727
],

app/Repositories/Daemon/ConfigurationRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function update(array $overrides = [])
4141
],
4242
];
4343

44-
return $this->getHttpClient()->request('PATCH', '/config', [
44+
return $this->getHttpClient()->request('PATCH', 'config', [
4545
'json' => array_merge($structure, $overrides),
4646
]);
4747
}

app/Repositories/Daemon/FileRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function getFileStat($path)
2222
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
2323

2424
$response = $this->getHttpClient()->request('GET', sprintf(
25-
'/server/file/stat/%s',
25+
'server/file/stat/%s',
2626
rawurlencode($file['dirname'] . $file['basename'])
2727
));
2828

@@ -40,7 +40,7 @@ public function getContent($path)
4040
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
4141

4242
$response = $this->getHttpClient()->request('GET', sprintf(
43-
'/server/file/f/%s',
43+
'server/file/f/%s',
4444
rawurlencode($file['dirname'] . $file['basename'])
4545
));
4646

@@ -58,7 +58,7 @@ public function putContent($path, $content)
5858
$file = pathinfo($path);
5959
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
6060

61-
return $this->getHttpClient()->request('POST', '/server/file/save', [
61+
return $this->getHttpClient()->request('POST', 'server/file/save', [
6262
'json' => [
6363
'path' => rawurlencode($file['dirname'] . $file['basename']),
6464
'content' => $content,
@@ -74,7 +74,7 @@ public function getDirectory($path)
7474
Assert::string($path, 'First argument passed to getDirectory must be a string, received %s.');
7575

7676
$response = $this->getHttpClient()->request('GET', sprintf(
77-
'/server/directory/%s',
77+
'server/directory/%s',
7878
rawurlencode($path)
7979
));
8080

app/Repositories/Daemon/PowerRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function sendSignal($signal)
2727
case self::SIGNAL_STOP:
2828
case self::SIGNAL_RESTART:
2929
case self::SIGNAL_KILL:
30-
return $this->getHttpClient()->request('PUT', '/server/power', [
30+
return $this->getHttpClient()->request('PUT', 'server/power', [
3131
'json' => [
3232
'action' => $signal,
3333
],

app/Repositories/Daemon/ServerRepository.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function create($id, array $overrides = [], $start = false)
6363
array_set($data, $key, $value);
6464
}
6565

66-
return $this->getHttpClient()->request('POST', '/servers', [
66+
return $this->getHttpClient()->request('POST', 'servers', [
6767
'json' => $data,
6868
]);
6969
}
@@ -73,7 +73,7 @@ public function create($id, array $overrides = [], $start = false)
7373
*/
7474
public function update(array $data)
7575
{
76-
return $this->getHttpClient()->request('PATCH', '/server', [
76+
return $this->getHttpClient()->request('PATCH', 'server', [
7777
'json' => $data,
7878
]);
7979
}
@@ -86,10 +86,10 @@ public function reinstall($data = null)
8686
Assert::nullOrIsArray($data, 'First argument passed to reinstall must be null or an array, received %s.');
8787

8888
if (is_null($data)) {
89-
return $this->getHttpClient()->request('POST', '/server/reinstall');
89+
return $this->getHttpClient()->request('POST', 'server/reinstall');
9090
}
9191

92-
return $this->getHttpClient()->request('POST', '/server/reinstall', [
92+
return $this->getHttpClient()->request('POST', 'server/reinstall', [
9393
'json' => $data,
9494
]);
9595
}
@@ -99,39 +99,39 @@ public function reinstall($data = null)
9999
*/
100100
public function rebuild()
101101
{
102-
return $this->getHttpClient()->request('POST', '/server/rebuild');
102+
return $this->getHttpClient()->request('POST', 'server/rebuild');
103103
}
104104

105105
/**
106106
* {@inheritdoc}
107107
*/
108108
public function suspend()
109109
{
110-
return $this->getHttpClient()->request('POST', '/server/suspend');
110+
return $this->getHttpClient()->request('POST', 'server/suspend');
111111
}
112112

113113
/**
114114
* {@inheritdoc}
115115
*/
116116
public function unsuspend()
117117
{
118-
return $this->getHttpClient()->request('POST', '/server/unsuspend');
118+
return $this->getHttpClient()->request('POST', 'server/unsuspend');
119119
}
120120

121121
/**
122122
* {@inheritdoc}
123123
*/
124124
public function delete()
125125
{
126-
return $this->getHttpClient()->request('DELETE', '/servers');
126+
return $this->getHttpClient()->request('DELETE', 'servers');
127127
}
128128

129129
/**
130130
* {@inheritdoc}
131131
*/
132132
public function details()
133133
{
134-
return $this->getHttpClient()->request('GET', '/server');
134+
return $this->getHttpClient()->request('GET', 'server');
135135
}
136136

137137
/**
@@ -141,6 +141,6 @@ public function revokeAccessKey($key)
141141
{
142142
Assert::stringNotEmpty($key, 'First argument passed to revokeAccessKey must be a non-empty string, received %s.');
143143

144-
return $this->getHttpClient()->request('DELETE', '/keys/' . $key);
144+
return $this->getHttpClient()->request('DELETE', 'keys/' . $key);
145145
}
146146
}

0 commit comments

Comments
 (0)