mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Better static runtime config, work on connections.
This commit is contained in:
+37
-11
@@ -1,21 +1,47 @@
|
||||
use lazy_static::lazy_static;
|
||||
use unshell_lib::{config::PayloadConfig, module::Manager};
|
||||
use unshell_obfuscate::symbol;
|
||||
use std::collections::HashMap;
|
||||
|
||||
lazy_static! {
|
||||
static ref PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
||||
id: symbol!("Test ID"),
|
||||
components: unshell_lib::get_components(),
|
||||
runtime_config: vec![],
|
||||
};
|
||||
use static_init::dynamic;
|
||||
use unshell_lib::{
|
||||
config::{PayloadConfig, RuntimeConfig},
|
||||
module::Manager,
|
||||
};
|
||||
use unshell_obfuscate::{obs, symbol};
|
||||
|
||||
#[dynamic]
|
||||
static PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
||||
id: symbol!("Test ID"),
|
||||
components: unshell_lib::get_components(),
|
||||
runtime_config: vec![],
|
||||
};
|
||||
|
||||
use std::alloc::{Layout, alloc};
|
||||
use std::ptr;
|
||||
|
||||
fn leak<T>(value: T) -> &'static mut T {
|
||||
unsafe {
|
||||
let layout = Layout::new::<T>();
|
||||
let ptr = alloc(layout) as *mut T;
|
||||
ptr::write(ptr, value);
|
||||
&mut *ptr
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
unshell_lib::logger::PrettyLogger::init();
|
||||
|
||||
Manager::run(&PAYLOAD_CONFIG, Vec::new());
|
||||
let manager = Manager::start(&PAYLOAD_CONFIG, Vec::new());
|
||||
|
||||
// let mut serverruntime = unshell_lib::server::ListenerRuntime::new();
|
||||
let runtime = leak(RuntimeConfig {
|
||||
parent_component: symbol!("server").to_string(),
|
||||
name: symbol!("server runtime").to_string(),
|
||||
config: HashMap::from([(symbol!("host").to_string(), obs!("localhost:1234"))]),
|
||||
});
|
||||
|
||||
Manager::start_runtime(manager.clone(), runtime);
|
||||
|
||||
// Manager::st
|
||||
|
||||
Manager::join(manager);
|
||||
|
||||
// loop {
|
||||
// print!("> ");
|
||||
|
||||
Reference in New Issue
Block a user