Andrew Rioux 726e6dff13
feat: added cd
added cd and fixed all the warnings in the source code
2023-09-08 23:26:10 -04:00

114 lines
2.8 KiB
Rust

pub const CONFIG_SEPARATOR: &'static [u8] =
b"79101092eb6a40268337875896f1009da0af4fe4ae0d4c67834c54fe735f1763";
pub mod messages {
pub const CONNECT_MESSAGE: &'static [u8] = b"CONNECT";
pub const CONNECTED_MESSAGE: &'static [u8] = b"CONNECTED";
pub const FILE_TRANSFER_PACKET_SIZE: usize = 1024;
pub const FILE_BUFFER_BUFFER_SIZE: usize = 512;
use std::{ffi::OsString, path::PathBuf};
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
#[derive(Serialize, Deserialize, Debug)]
pub enum Command {
RunCommand(String),
SendStdin(Vec<u8>, u64),
Cd(PathBuf),
Ls(PathBuf),
OpenTTY,
CloseTTY(u64),
SendTTYData(u64, Vec<u8>),
SendTTYSignal(u64, u64),
StartUploadFile(PathBuf, u64),
SendFileSegment(u64, u64, Vec<u8>),
GetUploadStatus(u64, u64),
StartDownloadFile(PathBuf),
DownloadFileStatus(u64, Vec<u64>),
Disconnect,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum FileType {
File,
Dir,
Symlink(PathBuf),
Fifo,
Socket,
Block,
Char,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct UnixMetadata {
pub mode: u32,
pub uid: u32,
pub gid: u32,
pub ctime: i64,
pub mtime: i64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct DirEntry {
pub name: OsString,
pub size: u64,
pub unix: Option<UnixMetadata>,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum Response {
AckRunCommand(u64),
SendStderr(Vec<u8>, u64),
SendStdout(Vec<u8>, u64),
CommandDone(u64, i32),
CdDone(Result<PathBuf, String>),
LsResults(Vec<DirEntry>),
OpenedTTY(u64),
ClosedTTY(u64),
SendTTYData(u64, Vec<u8>),
UploadFileID(u64),
UploadFileStatus(u64, Vec<u64>),
StartDownloadFile(u64, u64),
GetDownloadFileStatus(u64, u64),
DownloadFileSegment(u64, u64, Vec<u8>),
}
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Copy)]
#[repr(u8)]
pub enum TransportType {
RawUdp,
Udp,
}
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Copy)]
#[repr(u8)]
pub enum OperatingSystem {
Windows,
Linux,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Capabilities {
pub cwd: PathBuf,
pub operating_system: OperatingSystem,
pub docker_container: bool,
pub docker_breakout: bool,
pub setuid: bool,
pub root: bool,
pub userent: Option<String>,
pub transport: TransportType,
pub hostname: Option<String>,
}
}