2020-04-04 06:50:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Wings;
|
|
|
|
|
2021-08-29 21:09:43 +00:00
|
|
|
use Lcobucci\JWT\Token\Plain;
|
2020-04-04 06:50:06 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
2021-08-29 21:09:43 +00:00
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
2020-04-04 06:50:06 +00:00
|
|
|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
|
|
|
|
|
|
|
class DaemonTransferRepository extends DaemonRepository
|
|
|
|
{
|
|
|
|
/**
|
2021-08-29 21:09:43 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
2020-04-04 06:50:06 +00:00
|
|
|
*/
|
2021-08-29 21:09:43 +00:00
|
|
|
public function notify(Server $server, Plain $token): void
|
2020-04-04 22:24:58 +00:00
|
|
|
{
|
2020-04-04 06:50:06 +00:00
|
|
|
try {
|
|
|
|
$this->getHttpClient()->post('/api/transfer', [
|
|
|
|
'json' => [
|
2020-04-04 20:10:18 +00:00
|
|
|
'server_id' => $server->uuid,
|
2021-08-29 21:09:43 +00:00
|
|
|
'url' => $server->node->getConnectionAddress() . sprintf('/api/servers/%s/archive', $server->uuid),
|
|
|
|
'token' => 'Bearer ' . $token->toString(),
|
|
|
|
'server' => [
|
|
|
|
'uuid' => $server->uuid,
|
|
|
|
'start_on_completion' => false,
|
|
|
|
],
|
2020-04-04 06:50:06 +00:00
|
|
|
],
|
|
|
|
]);
|
2021-08-29 21:09:43 +00:00
|
|
|
} catch (GuzzleException $exception) {
|
2020-04-04 06:50:06 +00:00
|
|
|
throw new DaemonConnectionException($exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|