Files
vito/app/Services/Firewall/Ufw.php
Saeed Vaziry 131b828807 Plugins base (#613)
* wip

* wip

* cleanup

* notification channels

* phpstan

* services

* remove server types

* refactoring

* refactoring
2025-06-14 14:35:18 +02:00

58 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Services\Firewall;
use App\Enums\FirewallRuleStatus;
use App\Exceptions\SSHError;
class Ufw extends AbstractFirewall
{
public static function id(): string
{
return 'ufw';
}
public static function type(): string
{
return 'firewall';
}
public function unit(): string
{
return 'ufw';
}
/**
* @throws SSHError
*/
public function install(): void
{
$this->service->server->ssh()->exec(
view('ssh.services.firewall.ufw.install-ufw'),
'install-ufw'
);
$this->service->server->os()->cleanup();
}
public function uninstall(): void
{
//
}
/**
* @throws SSHError
*/
public function applyRules(): void
{
$rules = $this->service->server
->firewallRules()
->where('status', '!=', FirewallRuleStatus::DELETING)
->get();
$this->service->server->ssh()->exec(
view('ssh.services.firewall.ufw.apply-rules', ['rules' => $rules]),
'apply-rules'
);
}
}