mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
use blade as conmmands template (#444)
* use blade as conmmands template * fix lint * fix ssl
This commit is contained in:
@ -2,16 +2,17 @@
|
||||
|
||||
namespace App\SSH\Services\Firewall;
|
||||
|
||||
use App\SSH\HasScripts;
|
||||
use App\Exceptions\SSHError;
|
||||
|
||||
class Ufw extends AbstractFirewall
|
||||
{
|
||||
use HasScripts;
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function install(): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('ufw/install-ufw.sh'),
|
||||
view('ssh.services.firewall.ufw.install-ufw'),
|
||||
'install-ufw'
|
||||
);
|
||||
$this->service->server->os()->cleanup();
|
||||
@ -22,10 +23,13 @@ public function uninstall(): void
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function addRule(string $type, string $protocol, int $port, string $source, ?string $mask): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('ufw/add-rule.sh', [
|
||||
view('ssh.services.firewall.ufw.add-rule', [
|
||||
'type' => $type,
|
||||
'protocol' => $protocol,
|
||||
'port' => $port,
|
||||
@ -36,10 +40,13 @@ public function addRule(string $type, string $protocol, int $port, string $sourc
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function removeRule(string $type, string $protocol, int $port, string $source, ?string $mask): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('ufw/remove-rule.sh', [
|
||||
view('ssh.services.firewall.ufw.remove-rule', [
|
||||
'type' => $type,
|
||||
'protocol' => $protocol,
|
||||
'port' => $port,
|
||||
|
@ -1,11 +0,0 @@
|
||||
if ! sudo ufw __type__ from __source____mask__ to any proto __protocol__ port __port__; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw reload; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service ufw restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
@ -1,27 +0,0 @@
|
||||
if ! sudo ufw default deny incoming; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw default allow outgoing; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw allow from 0.0.0.0/0 to any proto tcp port 22; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw allow from 0.0.0.0/0 to any proto tcp port 80; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw allow from 0.0.0.0/0 to any proto tcp port 443; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw --force enable; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw reload; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
@ -1,11 +0,0 @@
|
||||
if ! sudo ufw delete __type__ from __source____mask__ to any proto __protocol__ port __port__; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw reload; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service ufw restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
Reference in New Issue
Block a user