mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Move files into old directory
This commit is contained in:
Generated
+13
-4183
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -14,14 +14,14 @@ include = ["LICENSE-APACHE", "LICENSE-MIT", "**/*.rs", "Cargo.toml"]
|
||||
[workspace]
|
||||
members = [
|
||||
# Binaries
|
||||
"ush-gui",
|
||||
# "ush-gui",
|
||||
|
||||
# UnShell Binaries
|
||||
"ush-server",
|
||||
# "ush-server",
|
||||
"ush-payload",
|
||||
|
||||
# Libraries
|
||||
"ush-manager",
|
||||
# "ush-manager",
|
||||
"ush-obfuscate"
|
||||
, "core-modules/server2"]
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
+76
-3
@@ -6,16 +6,89 @@
|
||||
//! - connections: Container for peer connections
|
||||
//! - components: Extensible component system (accessed via tree messages)
|
||||
|
||||
use crossbeam_channel::Sender;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::tree::component::ComponentRegistry;
|
||||
use crate::tree::connection::{create_channel_pair, Connection, Connections};
|
||||
use crate::tree::queue::Queue;
|
||||
use crate::tree::readonly::ReadOnly;
|
||||
use crate::tree::symbols::TYPE_ENDPOINT;
|
||||
use crate::tree::symbols::{self, TYPE_CONNECTION, TYPE_ENDPOINT};
|
||||
use crate::tree::{Branch, TreeElement};
|
||||
|
||||
pub(crate) struct Connection {
|
||||
id: String,
|
||||
peer_id: String,
|
||||
sender: Sender<Value>,
|
||||
receiver: Receiver<Value>,
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
pub(crate) fn new(
|
||||
id: String,
|
||||
peer_id: String,
|
||||
sender: Sender<Value>,
|
||||
receiver: Receiver<Value>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
peer_id,
|
||||
sender,
|
||||
receiver,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn id(&self) -> &str {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub(crate) fn send(&self, message: Value) {
|
||||
let _ = self.sender.send(message);
|
||||
}
|
||||
|
||||
pub(crate) fn recv(&self) -> Option<Value> {
|
||||
self.receiver.recv().ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeElement for Connections {
|
||||
fn get_type(&self) -> Value {
|
||||
json!(symbols::TYPE_CONNECTIONS)
|
||||
}
|
||||
|
||||
fn send_message(&mut self, _target: Value, _message: Value) -> Value {
|
||||
json!(symbols::ERR_UNSUPPORTED_METHOD)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Connections {
|
||||
connections: HashMap<String, Connection>,
|
||||
branch: Branch,
|
||||
}
|
||||
|
||||
impl Connections {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self {
|
||||
connections: HashMap::new(),
|
||||
branch: Branch::new(symbols::TYPE_CONNECTIONS),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn add(&mut self, id: String, connection: Connection) {
|
||||
self.connections.insert(id.clone(), connection);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_channel_pair() -> (
|
||||
(Sender<Value>, Receiver<Value>),
|
||||
(Sender<Value>, Receiver<Value>),
|
||||
) {
|
||||
let (tx1, rx1) = crossbeam_channel::unbounded::<Value>();
|
||||
let (tx2, rx2) = crossbeam_channel::unbounded::<Value>();
|
||||
((tx1, rx2), (tx2, rx1))
|
||||
}
|
||||
|
||||
pub struct EndpointManager {
|
||||
branch: Branch,
|
||||
logs_sender: Sender<Value>,
|
||||
|
||||
@@ -5,15 +5,12 @@
|
||||
|
||||
pub mod branch;
|
||||
pub mod component;
|
||||
pub mod connection;
|
||||
pub mod endpoint;
|
||||
pub mod log;
|
||||
pub mod message;
|
||||
pub mod protocols;
|
||||
pub mod queue;
|
||||
pub mod readonly;
|
||||
pub mod symbols;
|
||||
pub mod tcp;
|
||||
|
||||
pub use branch::Branch;
|
||||
pub use component::ComponentRegistry;
|
||||
|
||||
@@ -12,4 +12,8 @@ obfuscate = ["unshell/obfuscate"]
|
||||
|
||||
[dependencies]
|
||||
unshell.path = "../"
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
crossbeam-channel = "0.5.15"
|
||||
thiserror = "2.0"
|
||||
base64 = "0.22"
|
||||
|
||||
@@ -6,8 +6,8 @@ use std::collections::HashMap;
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::tree::symbols::{self, TYPE_CONNECTION, TYPE_CONNECTIONS};
|
||||
use crate::tree::{Branch, TreeElement};
|
||||
use unshell::tree::symbols::{self, TYPE_CONNECTION, TYPE_CONNECTIONS};
|
||||
use unshell::tree::{Branch, TreeElement};
|
||||
|
||||
/// A bidirectional connection to another endpoint.
|
||||
/// Wraps sender/receiver channels for message passing.
|
||||
@@ -0,0 +1,17 @@
|
||||
//! Payload module for network protocols and transports.
|
||||
//!
|
||||
//! This module provides protocol stacking, TCP client/server implementations,
|
||||
//! and connection management for testing and payload operations.
|
||||
|
||||
pub mod connection;
|
||||
pub mod protocols;
|
||||
pub mod tcp;
|
||||
|
||||
pub use connection::{create_channel_pair, Connection, Connections};
|
||||
pub use protocols::{
|
||||
Base64Config, HttpConfig, Protocol, ProtocolConfig, ProtocolError, ProtocolStack, TcpConfig,
|
||||
WebSocketConfig,
|
||||
};
|
||||
pub use tcp::{
|
||||
ConnectionStatus, ListenerStatus, TcpClient, TcpClientConfig, TcpServer, TcpServerConfig,
|
||||
};
|
||||
@@ -11,9 +11,9 @@ use std::time::Duration;
|
||||
|
||||
use serde_json::json;
|
||||
use unshell::tree::message::TreeMessage;
|
||||
use unshell::tree::protocols::{ProtocolConfig, ProtocolStack};
|
||||
use unshell::tree::tcp::{TcpClient, TcpServer};
|
||||
use unshell::tree::{ComponentRegistry, EndpointManager, TreeElement};
|
||||
use ush_payload::protocols::{ProtocolConfig, ProtocolStack};
|
||||
use ush_payload::tcp::{TcpClient, TcpServer};
|
||||
|
||||
fn main() {
|
||||
println!("=== Tree Protocol Test Harness ===\n");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Base64 encoding/decoding protocol.
|
||||
|
||||
use crate::tree::protocols::stack::{Base64Config, Protocol, ProtocolError};
|
||||
use super::stack::{Base64Config, Protocol, ProtocolError};
|
||||
use serde_json::Value;
|
||||
|
||||
/// Base64 encoding protocol
|
||||
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! This protocol wraps data in HTTP requests/responses for traffic blending.
|
||||
|
||||
use crate::tree::protocols::stack::{HttpConfig, Protocol, ProtocolError};
|
||||
use super::stack::{HttpConfig, Protocol, ProtocolError};
|
||||
use serde_json::Value;
|
||||
|
||||
/// HTTP protocol for tree communication.
|
||||
@@ -6,7 +6,9 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::tree::message::TreeMessage;
|
||||
use super::base64::{Base64Protocol, IdentityProtocol};
|
||||
use super::http::HttpProtocol;
|
||||
use unshell::tree::message::TreeMessage;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ProtocolError {
|
||||
@@ -207,15 +209,15 @@ impl ProtocolStack {
|
||||
pub fn push(&mut self, config: &ProtocolConfig) -> Result<(), ProtocolError> {
|
||||
let (protocol, name) = match config {
|
||||
ProtocolConfig::Identity => {
|
||||
let p = crate::tree::protocols::base64::IdentityProtocol::new();
|
||||
let p = IdentityProtocol::new();
|
||||
(Box::new(p) as Box<dyn Protocol>, "identity".to_string())
|
||||
}
|
||||
ProtocolConfig::Base64(cfg) => {
|
||||
let p = crate::tree::protocols::base64::Base64Protocol::new(cfg.clone());
|
||||
let p = Base64Protocol::new(cfg.clone());
|
||||
(Box::new(p) as Box<dyn Protocol>, "base64".to_string())
|
||||
}
|
||||
ProtocolConfig::Http(cfg) => {
|
||||
let p = crate::tree::protocols::http::HttpProtocol::new(cfg.clone());
|
||||
let p = HttpProtocol::new(cfg.clone());
|
||||
(Box::new(p) as Box<dyn Protocol>, "http".to_string())
|
||||
}
|
||||
ProtocolConfig::Tcp(cfg) => {
|
||||
@@ -11,12 +11,12 @@ use std::time::Duration;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::tree::component::Component;
|
||||
use crate::tree::message::TreeMessage;
|
||||
use crate::tree::protocols::{ProtocolConfig, ProtocolStack};
|
||||
use crate::tree::symbols;
|
||||
use crate::tree::tcp::config::{ConnectionStatus, TcpClientConfig};
|
||||
use crate::tree::{Branch, TreeElement};
|
||||
use crate::protocols::{ProtocolConfig, ProtocolStack};
|
||||
use crate::tcp::config::{ConnectionStatus, TcpClientConfig};
|
||||
use unshell::tree::component::Component;
|
||||
use unshell::tree::message::TreeMessage;
|
||||
use unshell::tree::symbols;
|
||||
use unshell::tree::{Branch, TreeElement};
|
||||
|
||||
/// TCP Client component with protocol stacking support.
|
||||
///
|
||||
@@ -12,12 +12,12 @@ use std::time::Duration;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::tree::component::Component;
|
||||
use crate::tree::message::TreeMessage;
|
||||
use crate::tree::protocols::{ProtocolConfig, ProtocolStack};
|
||||
use crate::tree::symbols;
|
||||
use crate::tree::tcp::config::{ListenerStatus, TcpServerConfig};
|
||||
use crate::tree::{Branch, TreeElement};
|
||||
use crate::protocols::{ProtocolConfig, ProtocolStack};
|
||||
use crate::tcp::config::{ListenerStatus, TcpServerConfig};
|
||||
use unshell::tree::component::Component;
|
||||
use unshell::tree::message::TreeMessage;
|
||||
use unshell::tree::symbols;
|
||||
use unshell::tree::{Branch, TreeElement};
|
||||
|
||||
/// A connected client managed by the server
|
||||
#[derive(Debug)]
|
||||
Reference in New Issue
Block a user