feat(ssh): Add ScpState state machine for SCP file transfer (Phase 8.3 init)
This commit is contained in:
BIN
data/auth.sqlite
BIN
data/auth.sqlite
Binary file not shown.
@@ -178,6 +178,7 @@ impl ChannelManager {
|
|||||||
exec_process: None, // Phase 14: 交互式exec
|
exec_process: None, // Phase 14: 交互式exec
|
||||||
sftp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.2修复:SFTP packet累积
|
sftp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.2修复:SFTP packet累积
|
||||||
scp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.4修复:SCP packet累积
|
scp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.4修复:SCP packet累积
|
||||||
|
scp_state: ScpState::Idle, // ⭐⭐⭐⭐⭐ Phase 8.3: SCP state machine
|
||||||
direct_tcpip: None,
|
direct_tcpip: None,
|
||||||
forwarded_tcpip: None,
|
forwarded_tcpip: None,
|
||||||
};
|
};
|
||||||
@@ -255,6 +256,7 @@ impl ChannelManager {
|
|||||||
exec_process: None,
|
exec_process: None,
|
||||||
sftp_input_buffer: Vec::new(),
|
sftp_input_buffer: Vec::new(),
|
||||||
scp_input_buffer: Vec::new(),
|
scp_input_buffer: Vec::new(),
|
||||||
|
scp_state: ScpState::Idle, // ⭐⭐⭐⭐⭐ Phase 8.3: SCP state machine
|
||||||
direct_tcpip: Some(direct_tcpip),
|
direct_tcpip: Some(direct_tcpip),
|
||||||
forwarded_tcpip: None,
|
forwarded_tcpip: None,
|
||||||
};
|
};
|
||||||
@@ -329,6 +331,7 @@ impl ChannelManager {
|
|||||||
exec_process: None, // Phase 14: 交互式exec
|
exec_process: None, // Phase 14: 交互式exec
|
||||||
sftp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.2修复
|
sftp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.2修复
|
||||||
scp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.4修复
|
scp_input_buffer: Vec::new(), // ⭐⭐⭐⭐⭐ Phase 14.4修复
|
||||||
|
scp_state: ScpState::Idle, // ⭐⭐⭐⭐⭐ Phase 8.3: SCP state machine
|
||||||
direct_tcpip: None,
|
direct_tcpip: None,
|
||||||
forwarded_tcpip: Some(forwarded_tcpip),
|
forwarded_tcpip: Some(forwarded_tcpip),
|
||||||
};
|
};
|
||||||
@@ -1945,6 +1948,8 @@ struct Channel {
|
|||||||
sftp_input_buffer: Vec<u8>, // Phase 14.2修复:累积不完整的SFTP packets
|
sftp_input_buffer: Vec<u8>, // Phase 14.2修复:累积不完整的SFTP packets
|
||||||
// ⭐⭐⭐⭐⭐ Phase 14.4:SCP packet累积buffer
|
// ⭐⭐⭐⭐⭐ Phase 14.4:SCP packet累积buffer
|
||||||
scp_input_buffer: Vec<u8>, // Phase 14.4修复:累积不完整的SCP packets
|
scp_input_buffer: Vec<u8>, // Phase 14.4修复:累积不完整的SCP packets
|
||||||
|
// ⭐⭐⭐⭐⭐ Phase 8.3: SCP file transfer state machine
|
||||||
|
scp_state: ScpState, // Phase 8.3: SCP state tracking
|
||||||
// Phase 13.3: 端口转发相关字段
|
// Phase 13.3: 端口转发相关字段
|
||||||
direct_tcpip: Option<DirectTcpipChannel>, // direct-tcpip channel(Remote forwarding)
|
direct_tcpip: Option<DirectTcpipChannel>, // direct-tcpip channel(Remote forwarding)
|
||||||
forwarded_tcpip: Option<ForwardedTcpipChannel>, // forwarded-tcpip channel(Local forwarding)
|
forwarded_tcpip: Option<ForwardedTcpipChannel>, // forwarded-tcpip channel(Local forwarding)
|
||||||
@@ -1957,6 +1962,21 @@ enum ChannelState {
|
|||||||
Closed,
|
Closed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ⭐⭐⭐⭐⭐ Phase 8.3: SCP file transfer state machine
|
||||||
|
/// Reference: OpenSSH scp.c: sink() (destination mode)
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
enum ScpState {
|
||||||
|
Idle,
|
||||||
|
FileCommandReceived {
|
||||||
|
size: u64,
|
||||||
|
filename: String,
|
||||||
|
remaining: u64,
|
||||||
|
},
|
||||||
|
DirectoryCreated {
|
||||||
|
dirname: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
/// SSH string读取辅助函数
|
/// SSH string读取辅助函数
|
||||||
fn read_ssh_string<R: std::io::Read>(reader: &mut R) -> Result<String> {
|
fn read_ssh_string<R: std::io::Read>(reader: &mut R) -> Result<String> {
|
||||||
let length = reader.read_u32::<BigEndian>()?;
|
let length = reader.read_u32::<BigEndian>()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user