Fix clippy warnings: unused imports, minor style fixes
This commit is contained in:
@@ -2,7 +2,6 @@ use axum::{extract::Request, response::IntoResponse, Extension};
|
|||||||
use clap::Subcommand;
|
use clap::Subcommand;
|
||||||
use dav_server::{fakels::FakeLs, DavHandler};
|
use dav_server::{fakels::FakeLs, DavHandler};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub enum WebdavCommand {
|
pub enum WebdavCommand {
|
||||||
|
|||||||
@@ -1340,7 +1340,7 @@ impl ChannelManager {
|
|||||||
|
|
||||||
/// ⭐⭐⭐⭐⭐ Phase 17: Check if a specific channel has an exec process
|
/// ⭐⭐⭐⭐⭐ Phase 17: Check if a specific channel has an exec process
|
||||||
pub fn channel_has_exec_process(&self, channel_id: u32) -> bool {
|
pub fn channel_has_exec_process(&self, channel_id: u32) -> bool {
|
||||||
self.channels.get(&channel_id).map_or(false, |ch| ch.exec_process.is_some())
|
self.channels.get(&channel_id).is_some_and(|ch| ch.exec_process.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 获取channel输出(Phase 6新增)
|
/// 获取channel输出(Phase 6新增)
|
||||||
@@ -2053,8 +2053,8 @@ impl ChannelManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if command.contains("rsync") {
|
} else if command.contains("rsync")
|
||||||
if command.contains("--server") {
|
&& command.contains("--server") {
|
||||||
let parts: Vec<&str> = command.split_whitespace().collect();
|
let parts: Vec<&str> = command.split_whitespace().collect();
|
||||||
for part in parts.iter().rev() {
|
for part in parts.iter().rev() {
|
||||||
if !part.starts_with("-") && !part.contains("--") && *part != "rsync" && *part != "--server" && *part != "--sender" {
|
if !part.starts_with("-") && !part.contains("--") && *part != "rsync" && *part != "--server" && *part != "--sender" {
|
||||||
@@ -2062,7 +2062,6 @@ impl ChannelManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use chacha20poly1305::{
|
|||||||
ChaCha20Poly1305, Key as ChaKey, Nonce as ChaNonce, // Phase 5: ChaCha20-Poly1305 AEAD
|
ChaCha20Poly1305, Key as ChaKey, Nonce as ChaNonce, // Phase 5: ChaCha20-Poly1305 AEAD
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use byteorder::{BigEndian, WriteBytesExt};
|
|
||||||
use cipher::{KeyIvInit, StreamCipher};
|
use cipher::{KeyIvInit, StreamCipher};
|
||||||
use ctr::Ctr128BE;
|
use ctr::Ctr128BE;
|
||||||
use hmac::{Hmac, Mac};
|
use hmac::{Hmac, Mac};
|
||||||
@@ -1046,7 +1045,7 @@ impl EncryptedPacket {
|
|||||||
let cipher = Aes256GcmAead::new_from_slice(&key_bytes[..32])
|
let cipher = Aes256GcmAead::new_from_slice(&key_bytes[..32])
|
||||||
.map_err(|e| anyhow!("AES-GCM key init failed: {}", e))?;
|
.map_err(|e| anyhow!("AES-GCM key init failed: {}", e))?;
|
||||||
let nonce = Nonce::from_slice(&prep.nonce_bytes);
|
let nonce = Nonce::from_slice(&prep.nonce_bytes);
|
||||||
let packet_length_bytes = (prep.packet_length as u32).to_be_bytes();
|
let packet_length_bytes = prep.packet_length.to_be_bytes();
|
||||||
let ciphertext = cipher
|
let ciphertext = cipher
|
||||||
.encrypt(
|
.encrypt(
|
||||||
nonce,
|
nonce,
|
||||||
@@ -1068,7 +1067,7 @@ impl EncryptedPacket {
|
|||||||
|
|
||||||
// Full packet: [packet_length (plaintext)] [ciphertext (payload + padding + tag)]
|
// Full packet: [packet_length (plaintext)] [ciphertext (payload + padding + tag)]
|
||||||
let mut full_buf = SshBuf::with_capacity(4 + ciphertext.len());
|
let mut full_buf = SshBuf::with_capacity(4 + ciphertext.len());
|
||||||
full_buf.put(&(prep.packet_length as u32).to_be_bytes())?;
|
full_buf.put(&prep.packet_length.to_be_bytes())?;
|
||||||
full_buf.put(&ciphertext)?;
|
full_buf.put(&ciphertext)?;
|
||||||
|
|
||||||
packets.push(Self {
|
packets.push(Self {
|
||||||
|
|||||||
@@ -261,8 +261,8 @@ impl SshBuf {
|
|||||||
|
|
||||||
/// 消费内部 Vec,提取有效数据(零拷贝)
|
/// 消费内部 Vec,提取有效数据(零拷贝)
|
||||||
/// 相当于 OpenSSH sshbuf_free() 但返回数据
|
/// 相当于 OpenSSH sshbuf_free() 但返回数据
|
||||||
pub fn into_vec(mut self) -> Vec<u8> {
|
pub fn into_vec(self) -> Vec<u8> {
|
||||||
let len = self.len();
|
let _len = self.len();
|
||||||
if self.off == 0 && self.size == self.data.len() {
|
if self.off == 0 && self.size == self.data.len() {
|
||||||
// 正好是完整 buffer,直接返回
|
// 正好是完整 buffer,直接返回
|
||||||
self.data
|
self.data
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use log::{info, warn, error};
|
use log::{info, error};
|
||||||
|
|
||||||
pub struct UploadHook {
|
pub struct UploadHook {
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
let entries = self
|
let entries = self
|
||||||
.runtime
|
.runtime
|
||||||
.block_on(client.list_directory(&mut *tree, &smb_path))
|
.block_on(client.list_directory(&mut tree, &smb_path))
|
||||||
.map_err(map_smb_error)?;
|
.map_err(map_smb_error)?;
|
||||||
|
|
||||||
Ok(entries
|
Ok(entries
|
||||||
@@ -171,7 +171,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
} else {
|
} else {
|
||||||
let data = self
|
let data = self
|
||||||
.runtime
|
.runtime
|
||||||
.block_on(client.read_file(&mut *tree, &smb_path))
|
.block_on(client.read_file(&mut tree, &smb_path))
|
||||||
.map_err(map_smb_error)?;
|
.map_err(map_smb_error)?;
|
||||||
let size = data.len() as u64;
|
let size = data.len() as u64;
|
||||||
Ok(Box::new(SmbVfsFile {
|
Ok(Box::new(SmbVfsFile {
|
||||||
@@ -198,7 +198,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
let info = self
|
let info = self
|
||||||
.runtime
|
.runtime
|
||||||
.block_on(client.stat(&mut *tree, &smb_path))
|
.block_on(client.stat(&mut tree, &smb_path))
|
||||||
.map_err(map_smb_error)?;
|
.map_err(map_smb_error)?;
|
||||||
|
|
||||||
Ok(VfsStat {
|
Ok(VfsStat {
|
||||||
@@ -225,7 +225,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
.map_err(|e| VfsError::Io(e.to_string()))?;
|
.map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
self.runtime
|
self.runtime
|
||||||
.block_on(client.create_directory(&mut *tree, &smb_path))
|
.block_on(client.create_directory(&mut tree, &smb_path))
|
||||||
.map_err(map_smb_error)
|
.map_err(map_smb_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
.map_err(|e| VfsError::Io(e.to_string()))?;
|
.map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
self.runtime
|
self.runtime
|
||||||
.block_on(client.delete_directory(&mut *tree, &smb_path))
|
.block_on(client.delete_directory(&mut tree, &smb_path))
|
||||||
.map_err(map_smb_error)
|
.map_err(map_smb_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
.map_err(|e| VfsError::Io(e.to_string()))?;
|
.map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
self.runtime
|
self.runtime
|
||||||
.block_on(client.delete_file(&mut *tree, &smb_path))
|
.block_on(client.delete_file(&mut tree, &smb_path))
|
||||||
.map_err(map_smb_error)
|
.map_err(map_smb_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
.map_err(|e| VfsError::Io(e.to_string()))?;
|
.map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
self.runtime
|
self.runtime
|
||||||
.block_on(client.rename(&mut *tree, &smb_from, &smb_to))
|
.block_on(client.rename(&mut tree, &smb_from, &smb_to))
|
||||||
.map_err(map_smb_error)
|
.map_err(map_smb_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,7 +436,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
let mut tree = self.tree.lock().map_err(|e| VfsError::Io(e.to_string()))?;
|
||||||
let _info = self
|
let _info = self
|
||||||
.runtime
|
.runtime
|
||||||
.block_on(client.stat(&mut *tree, &smb_path))
|
.block_on(client.stat(&mut tree, &smb_path))
|
||||||
.map_err(map_smb_error)?;
|
.map_err(map_smb_error)?;
|
||||||
Ok(path.to_path_buf())
|
Ok(path.to_path_buf())
|
||||||
}
|
}
|
||||||
@@ -452,7 +452,7 @@ impl VfsBackend for SmbVfs {
|
|||||||
Err(_) => return false,
|
Err(_) => return false,
|
||||||
};
|
};
|
||||||
self.runtime
|
self.runtime
|
||||||
.block_on(client.stat(&mut *tree, &smb_path))
|
.block_on(client.stat(&mut tree, &smb_path))
|
||||||
.is_ok()
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::vfs::open_flags::OpenFlags;
|
use crate::vfs::open_flags::OpenFlags;
|
||||||
use crate::vfs::{VfsBackend, VfsDirEntry, VfsStat};
|
use crate::vfs::{VfsBackend, VfsStat};
|
||||||
use crate::ssh_server::upload_hook::UploadHook;
|
use crate::ssh_server::upload_hook::UploadHook;
|
||||||
use bytes::{Buf, Bytes};
|
use bytes::{Buf, Bytes};
|
||||||
use dav_server::davpath::DavPath;
|
use dav_server::davpath::DavPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user