mirror of
https://github.com/Noratrieb/cluelessh.git
synced 2026-01-14 16:35:06 +01:00
Start implementing SFTP
This commit is contained in:
parent
a9e2edc572
commit
2ad87d3a14
11 changed files with 549 additions and 32 deletions
|
|
@ -14,6 +14,7 @@ impl std::error::Error for ParseError {}
|
|||
|
||||
pub type Result<T, E = ParseError> = std::result::Result<T, E>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Reader<'a>(&'a [u8]);
|
||||
|
||||
impl<'a> Reader<'a> {
|
||||
|
|
@ -123,6 +124,10 @@ impl Writer {
|
|||
self.raw(&u32::to_be_bytes(v));
|
||||
}
|
||||
|
||||
pub fn u64(&mut self, v: u64) {
|
||||
self.raw(&u64::to_be_bytes(v));
|
||||
}
|
||||
|
||||
pub fn raw(&mut self, v: &[u8]) {
|
||||
self.0.extend_from_slice(v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,3 +111,56 @@ consts! {
|
|||
}
|
||||
|
||||
pub const SSH_EXTENDED_DATA_STDERR: u32 = 1;
|
||||
|
||||
consts! {
|
||||
u8, fn sftp_message_type_to_string,
|
||||
const SSH_FXP_INIT = 1;
|
||||
const SSH_FXP_VERSION = 2;
|
||||
const SSH_FXP_OPEN = 3;
|
||||
const SSH_FXP_CLOSE = 4;
|
||||
const SSH_FXP_READ = 5;
|
||||
const SSH_FXP_WRITE = 6;
|
||||
const SSH_FXP_LSTAT = 7;
|
||||
const SSH_FXP_FSTAT = 8;
|
||||
const SSH_FXP_SETSTAT = 9;
|
||||
const SSH_FXP_FSETSTAT = 10;
|
||||
const SSH_FXP_OPENDIR = 11;
|
||||
const SSH_FXP_READDIR = 12;
|
||||
const SSH_FXP_REMOVE = 13;
|
||||
const SSH_FXP_MKDIR = 14;
|
||||
const SSH_FXP_RMDIR = 15;
|
||||
const SSH_FXP_REALPATH = 16;
|
||||
const SSH_FXP_STAT = 17;
|
||||
const SSH_FXP_RENAME = 18;
|
||||
const SSH_FXP_READLINK = 19;
|
||||
const SSH_FXP_SYMLINK = 20;
|
||||
const SSH_FXP_STATUS = 101;
|
||||
const SSH_FXP_HANDLE = 102;
|
||||
const SSH_FXP_DATA = 103;
|
||||
const SSH_FXP_NAME = 104;
|
||||
const SSH_FXP_ATTRS = 105;
|
||||
const SSH_FXP_EXTENDED = 200;
|
||||
const SSH_FXP_EXTENDED_REPLY = 201;
|
||||
}
|
||||
|
||||
consts! {
|
||||
u32, fn sftp_error_code_to_string,
|
||||
const SSH_FX_OK = 0;
|
||||
const SSH_FX_EOF = 1;
|
||||
const SSH_FX_NO_SUCH_FILE = 2;
|
||||
const SSH_FX_PERMISSION_DENIED = 3;
|
||||
const SSH_FX_FAILURE = 4;
|
||||
const SSH_FX_BAD_MESSAGE = 5;
|
||||
const SSH_FX_NO_CONNECTION = 6;
|
||||
const SSH_FX_CONNECTION_LOST = 7;
|
||||
const SSH_FX_OP_UNSUPPORTED = 8;
|
||||
}
|
||||
|
||||
consts! {
|
||||
u32, fn sftp_file_attr_flag_to_string,
|
||||
const SSH_FILEXFER_ATTR_SIZE = 0x00000001;
|
||||
const SSH_FILEXFER_ATTR_UIDGID = 0x00000002;
|
||||
const SSH_FILEXFER_ATTR_PERMISSIONS = 0x00000004;
|
||||
const SSH_FILEXFER_ATTR_ACMODTIME = 0x00000008;
|
||||
const SSH_FILEXFER_ATTR_EXTENDED = 0x80000000;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue