An example event plugin demonstrating the OmniEdge plugin system.
This plugin implements the event-plugin-world interface and logs all VPN lifecycle events:
- State Changes: When the VPN connects, disconnects, or changes state
- Peer Discovery: When new peers are found on the network
- Peer Disconnection: When peers leave the network
- Network Events: When joining/leaving networks
- Statistics Updates: Periodic connection statistics
-
Install Rust and the WASM target:
rustup target add wasm32-wasip1
-
Install cargo-component (this may take 5-10 minutes on first install):
cargo install cargo-component
Note: cargo-component has many dependencies and takes a while to compile. If installation times out, simply re-run the command - it will continue from where it left off.
# Navigate to the plugin directory
cd examples/plugins/hello-world
# Debug build
cargo component build
# Release build
cargo component build --releaseThe compiled plugin will be at:
- Debug:
target/wasm32-wasip1/debug/hello_world_plugin.wasm - Release:
target/wasm32-wasip1/release/hello_world_plugin.wasm
To verify the Rust code syntax without building the WASM component:
# This checks syntax but won't verify WIT bindings
cargo check --target wasm32-wasip1-
Copy the
.wasmfile andmanifest.tomlto your OmniEdge plugins directory:mkdir -p ~/.omniedge/plugins/installed/com.omniedge.hello-world/ cp target/wasm32-wasip1/release/hello_world_plugin.wasm ~/.omniedge/plugins/installed/com.omniedge.hello-world/plugin.wasm cp manifest.toml ~/.omniedge/plugins/installed/com.omniedge.hello-world/
-
Enable the plugin in OmniEdge settings or via CLI:
omniedge plugin enable com.omniedge.hello-world
hello-world/
├── Cargo.toml # Rust package manifest with WASM component config
├── manifest.toml # OmniEdge plugin manifest
├── README.md # This file
└── src/
└── lib.rs # Plugin implementation
-
WIT Bindings: The
wit_bindgen::generate!macro generates Rust bindings from the WIT interface definitions. -
Plugin Traits: Implement
BasePluginGuestfor lifecycle hooks andEventPluginGuestfor event handlers. -
Host Functions: Use
omniedge::host::loggingto log messages that appear in the OmniEdge logs.
To add more functionality:
- Add configuration options in
manifest.toml - Use the
confighost interface to read configuration values - Use the
kv-storehost interface to persist state between restarts
Apache-2.0