Path: blob/1.0-develop/app/Repositories/Wings/DaemonRepository.php
7460 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;910/**11* @method \Pterodactyl\Repositories\Wings\DaemonRepository setNode(\Pterodactyl\Models\Node $node)12* @method \Pterodactyl\Repositories\Wings\DaemonRepository setServer(\Pterodactyl\Models\Server $server)13*/14abstract class DaemonRepository15{16protected ?Server $server;1718protected ?Node $node;1920/**21* DaemonRepository constructor.22*/23public function __construct(protected Application $app)24{25}2627/**28* Set the server model this request is stemming from.29*/30public function setServer(Server $server): self31{32$this->server = $server;3334$this->setNode($this->server->node);3536return $this;37}3839/**40* Set the node model this request is stemming from.41*/42public function setNode(Node $node): self43{44$this->node = $node;4546return $this;47}4849/**50* Return an instance of the Guzzle HTTP Client to be used for requests.51*/52public function getHttpClient(array $headers = []): Client53{54Assert::isInstanceOf($this->node, Node::class);5556return new Client([57'verify' => $this->app->environment('production'),58'base_uri' => $this->node->getConnectionAddress(),59'timeout' => config('pterodactyl.guzzle.timeout'),60'connect_timeout' => config('pterodactyl.guzzle.connect_timeout'),61'headers' => array_merge($headers, [62'Authorization' => 'Bearer ' . $this->node->getDecryptedKey(),63'Accept' => 'application/json',64'Content-Type' => 'application/json',65]),66]);67}68}697071