This commit is contained in:
Crom (Thibaut CHARLES) 2019-01-30 16:26:05 +01:00
commit d49728d842
Signed by: tcharles
GPG Key ID: 45A3D5F880B9E6D0
12 changed files with 151 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
**/*.rs.bk

46
Cargo.lock generated Normal file
View File

@ -0,0 +1,46 @@
[[package]]
name = "cc"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libloading"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rnetmon"
version = "0.1.0"
dependencies = [
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
"checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

8
Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "rnetmon"
version = "0.1.0"
authors = ["Thibaut CHARLES"]
edition = "2018"
[dependencies]
libloading = "0.5.0"

33
src/main.rs Normal file
View File

@ -0,0 +1,33 @@
extern crate libloading;
mod message;
mod monitor;
mod output;
mod plugins;
// use libloading::{Library, Symbol};
use crate::monitor::Monitor;
use crate::output::Output;
use crate::message::Message;
fn main() {
// let lib = Library::new("/home/crom/.gitprojects/rnetmon/plugins/output/stdout/target/debug/deps/libstdout.so").unwrap();
// unsafe {
// let handle_message: Symbol<unsafe fn()> = lib.get(b"handle_message").unwrap();
// handle_message();
// }
let msg = Message{
emitter: "me".to_string(),
level: 10,
msg_type: "string".to_string(),
text: "Consectetur duis do dolor deserunt est minim dolore tempor et non duis.".to_string(),
};
let input = plugins::monitor::tester::Tester::new();
let out = plugins::output::stdout::Stdout::new();
out.on_message(&msg);
}

9
src/message.rs Normal file
View File

@ -0,0 +1,9 @@
#[derive(Debug)]
pub struct Message {
pub emitter: String,
pub level: i32,
pub msg_type: String,
pub text: String,
}

7
src/monitor.rs Normal file
View File

@ -0,0 +1,7 @@
use crate::message::Message;
pub trait Monitor {
fn new() -> Self;
fn run(&self);
}

7
src/output.rs Normal file
View File

@ -0,0 +1,7 @@
use crate::message::Message;
pub trait Output {
fn new() -> Self;
fn on_message(&self, message: &Message);
}

2
src/plugins/mod.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod output;
pub mod monitor;

View File

@ -0,0 +1 @@
pub mod tester;

View File

@ -0,0 +1,17 @@
use crate::message::Message;
pub use crate::monitor::Monitor;
#[derive(Debug)]
pub struct Tester {
}
impl Monitor for Tester {
fn new() -> Self {
Tester{}
}
fn run(&self) {
}
}

View File

@ -0,0 +1 @@
pub mod stdout;

View File

@ -0,0 +1,18 @@
use crate::message::Message;
pub use crate::output::Output;
#[derive(Debug)]
pub struct Stdout {
}
impl Output for Stdout {
fn new() -> Self {
Stdout{}
}
fn on_message(&self, message: &Message){
println!("{:?}", message);
}
}