mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
2.9 KiB
2.9 KiB
Protocol Testbed Report
Summary
Built a tree-based routing protocol testbed with the following components:
Files Created
ush-treetest/
├── Cargo.toml
├── src/
│ ├── main.rs # CLI entry point with serve/connect modes
│ ├── protocol/
│ │ ├── mod.rs # Module exports
│ │ ├── types.rs # FrameHeader, FrameType, TreeRequest, TreeResponse
│ │ └── transport.rs # Transport trait, TcpTransport, frame helpers
│ ├── tree/
│ │ ├── mod.rs # Tree, routing logic, node management
│ │ └── endpoint.rs # Endpoint trait
│ ├── leaves/
│ │ ├── mod.rs # Leaf module exports
│ │ ├── shell.rs # RemoteShell (command execution)
│ │ └── tty.rs # TTY (PTY support)
│ └── cli/
│ └── mod.rs # Interactive CLI
Protocol Implemented
Frame Types:
- Request (0x01): Tree operations
- Response (0x02): Operation results
- StreamOpen (0x03): Open bidirectional stream
- StreamData (0x04): Fastpath streaming data
- StreamClose (0x05): Close stream
- Handshake (0x10): Connection setup
- HandshakeAck (0x11): Connection acceptance
Routing:
- Longest-prefix match on dst_path for Request/StreamOpen
- Stream ID lookup for StreamData/StreamClose
What Works
- ✅ Basic project structure with proper module organization
- ✅ Protocol types with rkyv serialization
- ✅ TCP transport with length-prefixed framing
- ✅ Tree routing with prefix matching
- ✅ RemoteShell leaf implementation
- ✅ Basic CLI with commands (ls, exec, cd, connect, etc.)
Challenges Encountered
-
rkyv API Complexity: The rkyv serialization library has complex feature flags and API requirements:
from_bytesrequiresvalidationfeatureto_bytesrequires specifying const generic size parameter- Error handling requires careful trait bounds
-
Trait Object Sending: The
dyn Endpointtrait object doesn't implementSend, preventing the server from spawning threads with tree handlers -
Borrow Checker Issues: Complex borrowing patterns in tree traversal with mutable references
-
no_std + alloc Complexity: The
alloccrate requires explicit linking in Rust 2021 edition
Recommendations for Fixing
- Use
serdewithbincodeinstead ofrkyvfor simpler serialization - Use
Arc<Mutex<Tree>>for thread-safe shared state - Simplify the borrow patterns in tree operations
- For no_std, add proper
extern crate allocdeclarations
Protocol Observations
- The protocol design is sound - separating request/response from streaming is good
- The frame type enum should be repr(u8) for efficiency
- Longest-prefix matching works well for hierarchical routing
- The handshake pattern is simple but effective
- Consider adding compression for large payloads