This commit is contained in:
Saeed Vaziry
2024-12-14 03:13:47 +01:00
committed by GitHub
parent 0d12dd0c69
commit 572d1df010
20 changed files with 734 additions and 67 deletions

View File

@ -4,6 +4,7 @@
use App\Exceptions\SSHConnectionError;
use App\Helpers\SSH;
use App\Models\Server;
use Illuminate\Support\Traits\ReflectsClosures;
use PHPUnit\Framework\Assert;
@ -28,6 +29,21 @@ public function __construct(?string $output = null)
$this->output = $output;
}
public function init(Server $server, ?string $asUser = null): self
{
$this->connection = null;
$this->log = null;
$this->asUser = null;
$this->server = $server->refresh();
$this->user = $server->getSshUser();
if ($asUser && $asUser != $server->getSshUser()) {
$this->user = $asUser;
$this->asUser = $asUser;
}
return $this;
}
public function connectionWillFail(): void
{
$this->connectionWillFail = true;