feat(ssh): Add SCP subsystem initialization (Phase 8 partial)
This commit is contained in:
@@ -555,14 +555,14 @@ impl ChannelManager {
|
||||
|
||||
info!("Subsystem: {}", subsystem);
|
||||
|
||||
// 检查subsystem支持(OpenSSH支持:sftp)
|
||||
// 检查subsystem支持(OpenSSH支持:sftp, scp)
|
||||
if subsystem == "sftp" {
|
||||
info!("SFTP subsystem requested");
|
||||
|
||||
// Phase 7: 初始化SFTP handler(使用用户home目录,SFTPGo兼容)
|
||||
let root_dir = self.home_dir.clone();
|
||||
|
||||
// ⭐⭐⭐⭐⭐ Phase 4: 获取 client maxpack 限制(从 Channel 中获取)
|
||||
// ⭐⭐⭐⭐⭐ Phase 4: 获取 client maxpacket 限制(从 Channel 中获取)
|
||||
let maxpacket = if let Some(ch) = self.channels.get(&channel) {
|
||||
ch.remote_maxpacket // 来自 SSH_MSG_CHANNEL_OPEN 的 maximum_packet_size
|
||||
} else {
|
||||
@@ -584,6 +584,25 @@ impl ChannelManager {
|
||||
info!("SFTP handler initialized for channel {}", channel);
|
||||
}
|
||||
|
||||
if want_reply {
|
||||
Ok(Some(self.build_channel_success(channel)?))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
} else if subsystem == "scp" {
|
||||
info!("SCP subsystem requested");
|
||||
|
||||
// ⭐⭐⭐⭐⭐ Phase 8: 初始化SCP handler(使用用户home目录)
|
||||
let root_dir = self.home_dir.clone();
|
||||
let vfs = Box::new(crate::vfs::local_fs::LocalFs::new());
|
||||
let scp_handler = ScpHandler::new(root_dir, vfs);
|
||||
|
||||
// 存储到channel
|
||||
if let Some(ch) = self.channels.get_mut(&channel) {
|
||||
ch.scp_handler = Some(scp_handler);
|
||||
info!("SCP handler initialized for channel {}", channel);
|
||||
}
|
||||
|
||||
if want_reply {
|
||||
Ok(Some(self.build_channel_success(channel)?))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user