diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-04-20 12:44:20 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-04-20 12:44:20 +0200 |
commit | 11dc8c730dda2c5bd38cb386f96331c5ce3cac9c (patch) | |
tree | b2c03112114af00e33ce8e1276194906064fcf93 /src/UfwModule.php | |
parent | d4d5ae3bb6566311b2d42cf888e463b62f6cf0dc (diff) |
Adds a bunch of new Modules
Diffstat (limited to 'src/UfwModule.php')
-rw-r--r-- | src/UfwModule.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/UfwModule.php b/src/UfwModule.php new file mode 100644 index 0000000..1ec4452 --- /dev/null +++ b/src/UfwModule.php @@ -0,0 +1,39 @@ +<?php + +namespace PHPIAC\Modules; + +use PHPIAC\Connection; +use PHPIAC\Module\Module; +use PHPIAC\Module\State; + +class UfwModule extends Module +{ + protected string $rule; + protected string $name; + + protected string $state = State::ENABLED; + + /** + * @inheritDoc + */ + public function checkState(): bool + { + return false; + } + + /** + * @inheritDoc + */ + public function getCommands(): array + { + Connection::exec(implode(PHP_EOL, [ + "sudo ufw $this->rule $this->name", + match ($this->state) { + State::ENABLED => "sudo ufw --force enable", + State::DISABLED => "sudo ufw disable", + }, + ])); + + return []; + } +} |