Path: blob/1.0-develop/app/Repositories/Wings/DaemonRepository.php
10280 views
<?php12namespace Pterodactyl\Repositories\Wings;34use GuzzleHttp\Client;5use Pterodactyl\Models\Node;6use Webmozart\Assert\Assert;7use Pterodactyl\Models\Server;8use Illuminate\Contracts\Foundation\Application;910abstract class DaemonRepository11{12protected ?Server $server;1314protected ?Node $node;1516/**17* DaemonRepository constructor.18*/19public function __construct(protected Application $app)20{21}2223/**24* Set the server model this request is stemming from.25*/26public function setServer(Server $server): self27{28$this->server = $server;2930$this->setNode($this->server->node);3132return $this;33}3435/**36* Set the node model this request is stemming from.37*/38public function setNode(Node $node): self39{40$this->node = $node;4142return $this;43}4445/**46* Return an instance of the Guzzle HTTP Client to be used for requests.47*/48public function getHttpClient(array $headers = []): Client49{50Assert::isInstanceOf($this->node, Node::class);5152return new Client([53'verify' => $this->app->environment('production'),54'base_uri' => $this->node->getConnectionAddress(),55'timeout' => config('pterodactyl.guzzle.timeout'),56'connect_timeout' => config('pterodactyl.guzzle.connect_timeout'),57'headers' => array_merge($headers, [58'Authorization' => 'Bearer ' . $this->node->getDecryptedKey(),59'Accept' => 'application/json',60'Content-Type' => 'application/json',61]),62]);63}64}656667