2020-04-04 06:50:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Wings;
|
|
|
|
|
2022-11-15 01:25:07 +00:00
|
|
|
use Pterodactyl\Models\Node;
|
2021-08-29 21:09:43 +00:00
|
|
|
use Lcobucci\JWT\Token\Plain;
|
|
|
|
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
|
|
|
*/
|
2022-11-15 01:25:07 +00:00
|
|
|
public function notify(Node $targetNode, Plain $token): void
|
2020-04-04 22:24:58 +00:00
|
|
|
{
|
2020-04-04 06:50:06 +00:00
|
|
|
try {
|
2022-11-15 01:25:07 +00:00
|
|
|
$this->getHttpClient()->post(sprintf('/api/servers/%s/transfer', $this->server->uuid), [
|
2020-04-04 06:50:06 +00:00
|
|
|
'json' => [
|
2022-11-15 01:25:07 +00:00
|
|
|
'server_id' => $this->server->uuid,
|
|
|
|
'url' => $targetNode->getConnectionAddress() . '/api/transfers',
|
2021-08-29 21:09:43 +00:00
|
|
|
'token' => 'Bearer ' . $token->toString(),
|
|
|
|
'server' => [
|
2022-11-15 01:25:07 +00:00
|
|
|
'uuid' => $this->server->uuid,
|
2021-08-29 21:09:43 +00:00
|
|
|
'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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|