Fix bug in proc_impl_switcher.rs

This commit is contained in:
Michael Mikovsky
2026-04-20 23:14:07 -06:00
parent 3fdabf96ff
commit 959ea469a8
3 changed files with 2 additions and 60 deletions
+1
View File
@@ -6,6 +6,7 @@
### Topology
- Move server and client components into their own cargo projects
- Write wire protocol spec: `PROTOCOL.md` or doc comment in the protocol module. Spec the two-part frame format `[u32 header_len][rkyv PacketHeader][u32 payload_len][rkyv payload]` with `PacketHeader { dst_path, src_path, packet_type }`. Required before router and payload implementations can be written independently without diverging. See design doc: ~/.gstack/projects/astatin3-unshell/astatin3-main-design-20260420-223152.md
### Obfuscation
- Implement custom ELF loading possibly using 'https://github.com/weizhiao/rust-dlopen'
-59
View File
@@ -1,59 +0,0 @@
/// Implement logging for the manager
use crossbeam_channel::{Receiver, Sender};
use serde_json::{Value, json};
use crate::{
logger::{Logger, Record},
tree::{Tree, TreeElement, symbols},
};
struct LoggerTX(Sender<Record>);
struct LoggerRX(Receiver<Record>);
impl Tree {
/// Initiate the unshell logger for the local binary, piped through the manager
/// This will allow access to the logs through the tree
pub fn init_logger(&mut self) {
// Create the logger through the TX element of the manager
let (tx, rx) = crossbeam_channel::unbounded();
let (tx, rx) = (LoggerTX(tx), LoggerRX(rx));
// Set the logger through unshell
crate::logger::set_logger_box(Box::new(tx));
// Add the logger to the tree
self.add_element(symbols::LOGGER.to_string(), Box::new(rx));
}
}
impl Logger for LoggerTX {
fn log(&self, log: crate::logger::Record) {
// This will never panic if the program is operating properly
self.0.send(log).unwrap();
}
}
impl TreeElement for LoggerRX {
fn get_type(&self) -> Value {
json!(symbols::TYPE_QUEUE)
}
fn send_message(&mut self, target: Value, message: Value) -> Value {
match (target, message) {
(Value::Null, Value::String(message)) => match message.as_ref() {
symbols::CMD_GET => {
if !self.0.is_empty() {
json!(self.0.recv().unwrap())
} else {
json!(Value::Null)
}
}
symbols::CMD_GET_LENGTH => {
json!(self.0.len())
}
_ => json!(symbols::ERR_INVALID_COMMAND),
},
_ => json!(symbols::ERR_INVALID_CHILD),
}
}
}
+1 -1
View File
@@ -59,7 +59,7 @@ pub mod proc_impl {
use syn::{LitStr, parse_macro_input};
passtrough!(xor, crate::obfuscate::xor);
delete!(junk_asm);
passtrough!(junk_asm, crate::obfuscate::junk_asm);
passtrough!(sym, crate::symbolic_ref::sym_ref);
passtrough!(sym_fn, crate::symbolic_ref::sym_ref_fn);