From 55f50714759455a9195372582092c38049534c92 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Fri, 17 Nov 2023 23:35:56 -0500 Subject: [PATCH] - Begin work on firewall --- meta/config.php | 11 +++++++++++ meta/definitions/software.php | 8 ++++++-- meta/definitions/storage.php | 2 +- src/Entity/Firewall/Connection.php | 13 ++++++++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/meta/config.php b/meta/config.php index 6afa6c0..81b22c8 100644 --- a/meta/config.php +++ b/meta/config.php @@ -6,4 +6,15 @@ return [ getenv('DEBUG') ? 'lean.console' : null, ] ], + + 'ulmus' => [ + 'connections' => [ + 'lean.console' => [ + 'adapter' => 'SQLite', + 'path' => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . "var/lean-console.sqlite3", + 'pragma_begin' => array_filter([ "foreign_keys=ON", "synchronous=NORMAL", getenv('DEBUG') ? "journal_mode=WAL" : "" ]), + 'pragma_close' => [ "analysis_limit=500", "optimize" ], + ], + ], + ], ]; diff --git a/meta/definitions/software.php b/meta/definitions/software.php index d6fcc5d..c42c4e6 100644 --- a/meta/definitions/software.php +++ b/meta/definitions/software.php @@ -24,7 +24,11 @@ return [ ], ], - 'ulmus' => [], + 'ulmus' => [ + 'entities' => [ + 'Lean\\Console\\Entity\\Firewall' => implode(DIRECTORY_SEPARATOR, [ $path , "src", "Entity", "Firewall" ]), + ], + ], 'tell' => [ 'json' => [ @@ -35,7 +39,7 @@ return [ ] ], - 'routes' => [ + 'routes' => ! getenv('DEBUG') ? [] : [ 'Lean\\Console\\Controller' => implode(DIRECTORY_SEPARATOR, [ $path, "src", "Controller", "" ]), ], ], diff --git a/meta/definitions/storage.php b/meta/definitions/storage.php index 5163015..6818b6e 100644 --- a/meta/definitions/storage.php +++ b/meta/definitions/storage.php @@ -11,7 +11,7 @@ use function DI\autowire, DI\create, DI\get; return [ 'console.adapter' => function($c) { - $adapter = new ConnectionAdapter('sqlite', $c->get('config')['ulmus'], true); + $adapter = new ConnectionAdapter('lean.console', $c->get('config')['ulmus'], false); $adapter->resolveConfiguration(); return $adapter; diff --git a/src/Entity/Firewall/Connection.php b/src/Entity/Firewall/Connection.php index 877d0df..26827fe 100644 --- a/src/Entity/Firewall/Connection.php +++ b/src/Entity/Firewall/Connection.php @@ -4,10 +4,13 @@ namespace Lean\Console\Entity\Firewall; use Ulmus\Attribute\Obj\Table; use Ulmus\Attribute\Property\Field; +use Ulmus\Entity\Field\Datetime; -#[Table(adapter: "lean.console")] -class Connection +#[Table(name:"firewall_connections", adapter: "lean.console")] +class Connection implements \JsonSerializable { + use \Ulmus\EntityTrait; + #[Field\Id] public string $id; @@ -18,7 +21,11 @@ class Connection public string $ipv6; #[Field] - public int $connectionTry = 0; + public bool $success; + #[Field(length: 255)] + public ? string $errorMessage; + #[Field\Datetime] + public Datetime $createdAt; } \ No newline at end of file