mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-08 09:22:34 +00:00
Plugins base (#613)
* wip * wip * cleanup * notification channels * phpstan * services * remove server types * refactoring * refactoring
This commit is contained in:
7
app/Services/Firewall/AbstractFirewall.php
Executable file
7
app/Services/Firewall/AbstractFirewall.php
Executable file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Firewall;
|
||||
|
||||
use App\Services\AbstractService;
|
||||
|
||||
abstract class AbstractFirewall extends AbstractService implements Firewall {}
|
10
app/Services/Firewall/Firewall.php
Executable file
10
app/Services/Firewall/Firewall.php
Executable file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Firewall;
|
||||
|
||||
use App\Services\ServiceInterface;
|
||||
|
||||
interface Firewall extends ServiceInterface
|
||||
{
|
||||
public function applyRules(): void;
|
||||
}
|
57
app/Services/Firewall/Ufw.php
Executable file
57
app/Services/Firewall/Ufw.php
Executable file
@ -0,0 +1,57 @@
|
||||
<?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'
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user