scanner: make plugin interface ffi-safe with handle-based registry
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I8e4790db3cc29f84f4e0d7d8eff36c2c6a6a6964
This commit is contained in:
parent
4f9c7057ff
commit
f4961c7f95
9 changed files with 93 additions and 44 deletions
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(improper_ctypes_definitions)]
|
||||
|
||||
use clap::Parser;
|
||||
use libloading::Library;
|
||||
use pscand_core::logging::{LogLevel, RingBufferLogger};
|
||||
|
|
@ -10,7 +12,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
|||
use tokio::sync::RwLock;
|
||||
use tokio::time::interval;
|
||||
|
||||
type ScannerCreator = unsafe extern "C" fn() -> Box<dyn Scanner>;
|
||||
type ScannerCreator = pscand_core::ScannerCreatorFfi;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(
|
||||
|
|
@ -452,7 +454,16 @@ async fn load_scanners(
|
|||
}
|
||||
};
|
||||
|
||||
let scanner = creator();
|
||||
let scanner = match pscand_core::get_scanner(creator()) {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
log::error!(
|
||||
"Failed to get scanner from library {}",
|
||||
path.display()
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let name = scanner.name().to_string();
|
||||
|
||||
let scanner_enabled = config.is_scanner_enabled(&name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue