SkuldNorniern / fluere

Fluere is a powerful and versatile tool designed for network monitoring and analysis. It is capable of capturing network packets in pcap format and converting them into NetFlow data, providing a comprehensive view of network traffic. It also Provides Terminal User Interface.
Apache License 2.0
29 stars 3 forks source link

Implement plugin system for extended usage #60

Closed sweep-ai[bot] closed 10 months ago

sweep-ai[bot] commented 10 months ago

Description

This PR implements a plugin system for extended usage and diverse support in the fluere project. The current codebase already has a basic plugin system in place, but it needs to be extended to support more diverse usage. The plugin system allows for loading and executing plugins dynamically at runtime, enabling plugins to extend the functionality of the application without modifying the core codebase.

Summary of Changes

This PR introduces the necessary changes to implement a more flexible and extensible plugin system in the fluere project. It allows for the addition of new types of plugins and provides a mechanism for plugins to extend the functionality of the application. These changes enhance the usability and versatility of the fluere project.

Fixes #24.


To checkout this PR branch, run the following command in your terminal:

git checkout {pull_request.branch_name}

🎉 Latest improvements to Sweep:


💡 To get Sweep to edit this pull request, you can:

SkuldNorniern commented 10 months ago

resolve branch conflicts and

 failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:255:13
    |
255 |     plugin::manager::plugin_setup();
    |             ^^^^^^^ could not find `manager` in `plugin`
 failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:256:13
    |
256 |     plugin::manager::plugin_execute();
    |             ^^^^^^^ could not find `manager` in `plugin`
sweep-ai[bot] commented 10 months ago

resolve branch conflicts and

 failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:255:13
    |
255 |     plugin::manager::plugin_setup();
    |             ^^^^^^^ could not find `manager` in `plugin`
 failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:256:13
    |
256 |     plugin::manager::plugin_execute();
    |             ^^^^^^^ could not find `manager` in `plugin`

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
src/plugin/manager.rs Modify src/plugin/manager.rs with contents:
• Import the manager module in the plugin module by adding the following line at the top of the file:
```rust
use crate::plugin::manager;
```
src/main.rs Modify src/main.rs with contents:
• Import the manager module in the main module by adding the following line at the top of the file:
```rust
use crate::plugin::manager;
```
SkuldNorniern commented 10 months ago

error[E0433]: failed to resolve: could not find manager in plugin

--> src/main.rs:256:13

|

256 | plugin::manager::plugin_setup();

|             ^^^^^^^ could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find manager in plugin

--> src/main.rs:257:13

|

257 | plugin::manager::plugin_execute();

|             ^^^^^^^ could not find `manager` in `plugin`

For more information about this error, try rustc --explain E0433.

warning: fluere (bin "fluere") generated 1 warning

error: could not compile fluere (bin "fluere") due to 2 previous errors; 1 warning emitted

sweep-ai[bot] commented 10 months ago

error[E0433]: failed to resolve: could not find manager in plugin

--> src/main.rs:256:13

|

256 | plugin::manager::plugin_setup();

|             ^^^^^^^ could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find manager in plugin

--> src/main.rs:257:13

|

257 | plugin::manager::plugin_execute();

|             ^^^^^^^ could not find `manager` in `plugin`

For more information about this error, try rustc --explain E0433.

warning: fluere (bin "fluere") generated 1 warning

error: could not compile fluere (bin "fluere") due to 2 previous errors; 1 warning emitted

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
src/main.rs Modify src/main.rs with contents:
• Add the correct import statement for the manager module in the main.rs file.
• Replace the line plugin::manager::plugin_setup(); with crate::plugin::manager::plugin_setup();.
• Replace the line plugin::manager::plugin_execute(); with crate::plugin::manager::plugin_execute();.
SkuldNorniern commented 10 months ago
unresolved import `crate::plugin::manager`

error[E0432]: unresolved import `crate::plugin::manager`
  --> src/main.rs:14:5
   |
14 | use crate::plugin::manager;
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `manager` in `plugin`
failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:258:20
    |
258 |     crate::plugin::manager::plugin_setup();
    |                    ^^^^^^^ could not find `manager` in `plugin`
failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:259:20
    |
259 |     crate::plugin::manager::plugin_execute();
    |                    ^^^^^^^ could not find `manager` in `plugin`

edit Cargo.toml

fluere_plugin = { path = "./plugin" } to

fluere_plugin = { path = "./plugin" }

sweep-ai[bot] commented 10 months ago
unresolved import `crate::plugin::manager`

error[E0432]: unresolved import `crate::plugin::manager`
  --> src/main.rs:14:5
   |
14 | use crate::plugin::manager;
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `manager` in `plugin`
failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:258:20
    |
258 |     crate::plugin::manager::plugin_setup();
    |                    ^^^^^^^ could not find `manager` in `plugin`
failed to resolve: could not find `manager` in `plugin`

error[E0433]: failed to resolve: could not find `manager` in `plugin`
   --> src/main.rs:259:20
    |
259 |     crate::plugin::manager::plugin_execute();
    |                    ^^^^^^^ could not find `manager` in `plugin`

edit Cargo.toml

fluere_plugin = { path = "./plugin" } to

fluere_plugin = { path = "./plugin" }

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
src/main.rs Modify src/main.rs with contents:
• Replace the import statement use crate::plugin::manager; with use crate::plugin::manager::PluginManager;.
fluereflow/Cargo.toml Modify fluereflow/Cargo.toml with contents:
• Change the line fluere_plugin = { path = "./plugin" } to fluere_plugin = { path = "../plugin" }.
SkuldNorniern commented 10 months ago

plugin is not in a same crate, import it usnig use fluere-plugin

sweep-ai[bot] commented 10 months ago

plugin is not in a same crate, import it usnig use fluere-plugin

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
src/plugin/manager.rs Modify src/plugin/manager.rs with contents:
• Modify the import statement to import the plugin using the correct crate name:
- Change use fluere_plugin::InProcessPlugin; to use fluere_plugin::InProcessPlugin;.
SkuldNorniern commented 10 months ago

module manager is private

error[E0603]: module manager is private --> src/main.rs:14:20 14 use crate::plugin::manager::PluginManager; ^^^^^^^ private module

note: the module manager is defined here --> src/plugin/mod.rs:1:1 | 1 | mod manager; | ^^^^^^^^^^^^

sweep-ai[bot] commented 10 months ago

module manager is private

error[E0603]: module manager is private --> src/main.rs:14:20 14 use crate::plugin::manager::PluginManager; ^^^^^^^ private module

note: the module manager is defined here --> src/plugin/mod.rs:1:1 | 1 | mod manager; | ^^^^^^^^^^^^

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
src/plugin/mod.rs Modify src/plugin/mod.rs with contents:
• Change line 1 from mod manager; to pub mod manager;
SkuldNorniern commented 10 months ago
error[E0432]: unresolved import crate::plugin::manager::PluginManager --> src/main.rs:14:5 14 use crate::plugin::manager::PluginManager; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no PluginManager in plugin::manager

help: consider importing this struct instead | 14 | use fluere_plugin::PluginManager; | ~~~~~~~~

error[E0432]: unresolved import fluereplugin --> src/plugin/manager.rs:1:5 1 use fluereplugin::InProcessPlugin; ^^^^^^^^^^^^ use of undeclared crate or module fluereplugin

help: there is a crate or module with a similar name | 1 | use fluere_plugin::InProcessPlugin; | ~~~~~

error[E0432]: unresolved import fluereplugin --> src/plugin/manager.rs:2:5 2 use fluereplugin::PluginManager; ^^^^^^^^^^^^ use of undeclared crate or module fluereplugin

help: there is a crate or module with a similar name | 2 | use fluere_plugin::PluginManager; | ~~~~~

sweep-ai[bot] commented 10 months ago
error[E0432]: unresolved import crate::plugin::manager::PluginManager --> src/main.rs:14:5 14 use crate::plugin::manager::PluginManager; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no PluginManager in plugin::manager

help: consider importing this struct instead | 14 | use fluere_plugin::PluginManager; | ~~~~~~~~

error[E0432]: unresolved import fluereplugin --> src/plugin/manager.rs:1:5 1 use fluereplugin::InProcessPlugin; ^^^^^^^^^^^^ use of undeclared crate or module fluereplugin

help: there is a crate or module with a similar name | 1 | use fluere_plugin::InProcessPlugin; | ~~~~~

error[E0432]: unresolved import fluereplugin --> src/plugin/manager.rs:2:5 2 use fluereplugin::PluginManager; ^^^^^^^^^^^^ use of undeclared crate or module fluereplugin

help: there is a crate or module with a similar name | 2 | use fluere_plugin::PluginManager; | ~~~~~

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
src/main.rs Modify src/main.rs with contents:
• Change the import use crate::plugin::manager::PluginManager; to use fluereplugin::PluginManager;.
src/plugin/manager.rs Modify src/plugin/manager.rs with contents:
• Change the import use fluereplugin::InProcessPlugin; to use fluere_plugin::InProcessPlugin;.
• Change the import use fluereplugin::PluginManager; to use fluere_plugin::PluginManager;.
SkuldNorniern commented 10 months ago

at the manager.rs there is no such thing called PluginManager

sweep-ai[bot] commented 10 months ago

at the manager.rs there is no such thing called PluginManager

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
src/plugin/manager.rs Modify src/plugin/manager.rs with contents:
• Add the following code snippet at the top of the file:
```rust
use fluere_plugin::PluginManager;
```
SkuldNorniern commented 10 months ago

can you also start editing the linker.rs, loader.rs scheduler.rs so it can be called from the online/offline/live code

sweep-ai[bot] commented 10 months ago

can you also start editing the linker.rs, loader.rs scheduler.rs so it can be called from the online/offline/live code

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
plugin/src/linker.rs Create plugin/src/linker.rs with contents:
• Add a public function or method that can be called from the online/offline/live code.
• Ensure that the existing functionality of the linker.rs file is not affected.
plugin/src/loader.rs Create plugin/src/loader.rs with contents:
• Add a public function or method that can be called from the online/offline/live code.
• Ensure that the existing functionality of the loader.rs file is not affected.
plugin/src/scheduler.rs Create plugin/src/scheduler.rs with contents:
• Add a public function or method that can be called from the online/offline/live code.
• Ensure that the existing functionality of the scheduler.rs file is not affected.
SkuldNorniern commented 10 months ago

revert the changes done at the plugin folder, linker.rs, loader.rs, scheduler.rs are inside the fluereplugin/src write the code that can link the program/script and communicate with it at linker.rs and the one that check the programs and load it to the process at loader.rs schedule the loaded progam's execute schedule at scheduler.rs

sweep-ai[bot] commented 10 months ago

revert the changes done at the plugin folder, linker.rs, loader.rs, scheduler.rs are inside the fluereplugin/src write the code that can link the program/script and communicate with it at linker.rs and the one that check the programs and load it to the process at loader.rs schedule the loaded progam's execute schedule at scheduler.rs

Hi @SkuldNorniern,

I decided to make the following changes:

File Path Proposed Changes
plugin/src/linker.rs Modify plugin/src/linker.rs with contents:
• Remove the existing code in linker.rs.
• Add code to link the program/script and enable communication with it.
plugin/src/loader.rs Modify plugin/src/loader.rs with contents:
• Remove the existing code in loader.rs.
• Add code to check the programs and load them into the process.
plugin/src/scheduler.rs Modify plugin/src/scheduler.rs with contents:
• Remove the existing code in scheduler.rs.
• Add code to schedule the execution of the loaded programs.