mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
init
This commit is contained in:
56
app/SSHCommands/Firewall/AddRuleCommand.php
Executable file
56
app/SSHCommands/Firewall/AddRuleCommand.php
Executable file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Firewall;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class AddRuleCommand extends Command
|
||||
{
|
||||
use CommandContent;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $protocol;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $port;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $mask;
|
||||
|
||||
public function __construct($provider, $type, $protocol, $port, $source, $mask)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->type = $type;
|
||||
$this->protocol = $protocol;
|
||||
$this->port = $port;
|
||||
$this->source = $source;
|
||||
$this->mask = $mask;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/firewall/'.$this->provider.'/add-rule.sh'));
|
||||
}
|
||||
}
|
18
app/SSHCommands/Firewall/CommandContent.php
Executable file
18
app/SSHCommands/Firewall/CommandContent.php
Executable file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Firewall;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait CommandContent
|
||||
{
|
||||
public function content(string $os): string
|
||||
{
|
||||
$command = Str::replace('__type__', $this->type, $this->file($os));
|
||||
$command = Str::replace('__protocol__', $this->protocol, $command);
|
||||
$command = Str::replace('__source__', $this->source, $command);
|
||||
$command = Str::replace('__mask__', $this->mask, $command);
|
||||
|
||||
return Str::replace('__port__', $this->port, $command);
|
||||
}
|
||||
}
|
56
app/SSHCommands/Firewall/RemoveRuleCommand.php
Executable file
56
app/SSHCommands/Firewall/RemoveRuleCommand.php
Executable file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSHCommands\Firewall;
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class RemoveRuleCommand extends Command
|
||||
{
|
||||
use CommandContent;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $protocol;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $port;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $mask;
|
||||
|
||||
public function __construct($provider, $type, $protocol, $port, $source, $mask)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->type = $type;
|
||||
$this->protocol = $protocol;
|
||||
$this->port = $port;
|
||||
$this->source = $source;
|
||||
$this->mask = $mask;
|
||||
}
|
||||
|
||||
public function file(string $os): string
|
||||
{
|
||||
return File::get(base_path('system/commands/firewall/'.$this->provider.'/remove-rule.sh'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user