mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Fix core dump bug in tree path search
This commit is contained in:
+4
-3
@@ -1,11 +1,12 @@
|
|||||||
use alloc::{boxed::Box, string::String, vec::Vec};
|
use alloc::{boxed::Box, string::String, vec::Vec};
|
||||||
|
|
||||||
use crate::tree::request::{TreeRequest, TreeRequestType};
|
|
||||||
|
|
||||||
mod request;
|
mod request;
|
||||||
|
|
||||||
|
pub use request::{TreeRequest, TreeRequestType};
|
||||||
|
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Tree {
|
pub struct Tree {
|
||||||
endpoints: Vec<(Box<dyn Endpoint>, Vec<String>)>,
|
endpoints: Vec<(Box<dyn Endpoint>, Vec<String>)>,
|
||||||
}
|
}
|
||||||
@@ -24,7 +25,7 @@ impl Tree {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..search_path.len() {
|
for i in 0..endpoint_path.len() {
|
||||||
if search_path[i] != endpoint_path[i] {
|
if search_path[i] != endpoint_path[i] {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -25,14 +25,13 @@ pub struct TreeRequest {
|
|||||||
#[rkyv(compare(PartialEq), derive(Debug))]
|
#[rkyv(compare(PartialEq), derive(Debug))]
|
||||||
pub enum TreeRequestType {
|
pub enum TreeRequestType {
|
||||||
Return = 0,
|
Return = 0,
|
||||||
|
|
||||||
Read = 1,
|
Read = 1,
|
||||||
Write = 2,
|
GetProcedures = 2,
|
||||||
Submit = 3,
|
|
||||||
|
|
||||||
ListBranches = 10,
|
Write = 11,
|
||||||
|
CallProcedure = 12,
|
||||||
|
|
||||||
// CreateField = 3,
|
|
||||||
// DeleteField = 4,
|
|
||||||
UnnamedError = 100,
|
UnnamedError = 100,
|
||||||
NoBranchError = 101,
|
NoBranchError = 101,
|
||||||
ProtocolError = 102,
|
ProtocolError = 102,
|
||||||
|
|||||||
@@ -1,3 +1,16 @@
|
|||||||
|
use alloc::{string::String, vec::Vec};
|
||||||
|
|
||||||
use crate::obfuscate::sym;
|
use crate::obfuscate::sym;
|
||||||
|
|
||||||
pub const TYPE_NONE: &'static str = sym!("core/None");
|
pub const TYPE_NONE: &'static str = sym!("core/None");
|
||||||
|
|
||||||
|
pub const TYPE_PROCEDURE_CALL_DESCRIPTOR: &'static str = sym!("core/Procedure_call_descriptor");
|
||||||
|
pub struct ProcedureCallDescriptor {
|
||||||
|
name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const TYPE_PROCEDURE_CALL_DESCRIPTOR_LIST: &'static str =
|
||||||
|
sym!("core/Procedure_call_descriptor_list");
|
||||||
|
pub type ProcedureCallDescriptorList = Vec<ProcedureCallDescriptor>;
|
||||||
|
|
||||||
|
pub const TYPE_PROCEDURE_CALL_ARGUMENTS: &'static str = sym!("core/Procedure_call_arguments");
|
||||||
|
|||||||
+28
-106
@@ -1,117 +1,39 @@
|
|||||||
#![macro_use]
|
#![macro_use]
|
||||||
extern crate unshell;
|
extern crate unshell;
|
||||||
|
|
||||||
use unshell::{info, logger::PrettyLogger};
|
use unshell::{
|
||||||
|
info,
|
||||||
|
logger::PrettyLogger,
|
||||||
|
tree::{Endpoint, Tree, TreeRequest},
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EndpointTest;
|
||||||
|
|
||||||
|
impl Endpoint for EndpointTest {
|
||||||
|
fn request(&mut self, request: TreeRequest) -> TreeRequest {
|
||||||
|
info!("Got request");
|
||||||
|
TreeRequest {
|
||||||
|
request_type: request.request_type,
|
||||||
|
path: request.path,
|
||||||
|
content_type: request.content_type,
|
||||||
|
data: request.data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
PrettyLogger::init();
|
PrettyLogger::init();
|
||||||
|
|
||||||
// let mut manager = Tree::new();
|
info!("Initiated");
|
||||||
// manager.init_logger();
|
|
||||||
|
|
||||||
// println!("{}", sym!("TEST"));
|
let mut tree = Tree::default();
|
||||||
|
|
||||||
info!("Test thing!");
|
tree.add_endpoint(EndpointTest, vec!["path1".to_string()]);
|
||||||
// info!("Test thing!");
|
|
||||||
|
|
||||||
// loop {
|
tree.request(TreeRequest {
|
||||||
// if test123(&mut manager) {
|
path: vec!["path1".to_string(), "path2".to_string()],
|
||||||
// break;
|
request_type: unshell::tree::TreeRequestType::Read,
|
||||||
// }
|
content_type: "TEST".to_string(),
|
||||||
// }
|
data: Vec::new(),
|
||||||
|
});
|
||||||
// println!("Test");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn test123(manager: &mut Tree) -> bool {
|
|
||||||
// let result = manager.send_message(
|
|
||||||
// Value::String(sym!("Logger").to_string()),
|
|
||||||
// Value::String(symbols::CMD_GET.to_string()),
|
|
||||||
// );
|
|
||||||
|
|
||||||
// junk_asm!(20.);
|
|
||||||
|
|
||||||
// let is_null = result.is_null();
|
|
||||||
|
|
||||||
// // if let Ok(result) = serde_json::from_value::<Record>(result) {
|
|
||||||
// // log(&result);
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// is_null
|
|
||||||
|
|
||||||
// // println!("Logger: {}", result);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// use std::{any::Any, collections::HashMap, fs::File, io::Read};
|
|
||||||
|
|
||||||
// use static_init::dynamic;
|
|
||||||
// use unshell_lib::{
|
|
||||||
// ModuleError,
|
|
||||||
// config::{PayloadConfig, RuntimeConfig},
|
|
||||||
// module::{Manager, Module},
|
|
||||||
// };
|
|
||||||
// use unshell_obfuscate::{obs, symbol};
|
|
||||||
|
|
||||||
// #[macro_use]
|
|
||||||
// extern crate unshell_lib;
|
|
||||||
|
|
||||||
// // The main and initial 'configuration' for a payload
|
|
||||||
|
|
||||||
// #[dynamic]
|
|
||||||
// static PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
|
||||||
// id: symbol!("Test ID"),
|
|
||||||
// components: Vec::new(),
|
|
||||||
// runtime_config: vec![RuntimeConfig {
|
|
||||||
// parent_component: symbol!("client").to_string(),
|
|
||||||
// name: symbol!("client runtime").to_string(),
|
|
||||||
// config: HashMap::from([
|
|
||||||
// (symbol!("host").to_string(), obs!("localhost:1234")),
|
|
||||||
// (symbol!("retry").to_string(), obs!("1000")),
|
|
||||||
// ]),
|
|
||||||
// }],
|
|
||||||
// };
|
|
||||||
|
|
||||||
// fn main() {
|
|
||||||
|
|
||||||
// debug!("Initialized");
|
|
||||||
|
|
||||||
// match run() {
|
|
||||||
// Ok(_) => {}
|
|
||||||
// Err(e) => {
|
|
||||||
// error!("ERROR! '{:?}'", e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn run() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
// let args = std::env::args();
|
|
||||||
|
|
||||||
// // TEMPORARY, load the module paths from command line args.
|
|
||||||
// let mut modules = Vec::new();
|
|
||||||
// for arg in args.skip(1) {
|
|
||||||
// // debug!("Loading module: {}", arg);
|
|
||||||
|
|
||||||
// // let mut file = File::open(arg).map_err(|e| ModuleError::Error(e.to_string().into()))?;
|
|
||||||
// // let mut buffer = Vec::new();
|
|
||||||
// // file.read_to_end(&mut buffer)
|
|
||||||
// // .map_err(|e| ModuleError::Error(e.to_string().into()))?;
|
|
||||||
|
|
||||||
// debug!("Initializing module: {}", arg);
|
|
||||||
// let module = Module::new(&arg)?;
|
|
||||||
|
|
||||||
// modules.push(module);
|
|
||||||
|
|
||||||
// // modules.push(Module::new(&arg)?)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // let modules = vec
|
|
||||||
|
|
||||||
// debug!("Starting manager...");
|
|
||||||
|
|
||||||
// // Run the manager, this is blocking.
|
|
||||||
// let manager = Manager::start(&PAYLOAD_CONFIG, modules);
|
|
||||||
|
|
||||||
// Manager::join(manager);
|
|
||||||
|
|
||||||
// Ok(())
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user