Better static runtime config, work on connections.

This commit is contained in:
Michael Mikovsky
2025-11-25 14:27:06 -07:00
parent dc153774e5
commit 1efa3206ae
16 changed files with 634 additions and 122 deletions
+37 -11
View File
@@ -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!("> ");