Fix compilation errors after PostgreSQL removal
Changes: - Remove pg_conn field from SshServerConfig struct - Remove pg_conn parameter from run_ssh_server function - Remove pg_conn CLI argument from ssh-start command - Remove non-existent user management API routes - Add missing dependencies: sysinfo, dirs - Fix CLI web.rs to pass home directory to server::run - Fix SSH server stream type (tokio -> std TcpStream) All compilation errors resolved.
This commit is contained in:
Generated
+57
-17
@@ -1405,6 +1405,15 @@ dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "7.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.5.0"
|
||||
@@ -3034,6 +3043,7 @@ dependencies = [
|
||||
"ctr 0.9.2",
|
||||
"dashmap",
|
||||
"dav-server",
|
||||
"dirs 7.0.0",
|
||||
"ed25519-dalek 2.2.0",
|
||||
"env_logger",
|
||||
"filetime",
|
||||
@@ -3052,7 +3062,6 @@ dependencies = [
|
||||
"nix 0.29.0",
|
||||
"once_cell",
|
||||
"poly1305 0.8.0",
|
||||
"postgres",
|
||||
"pulldown-cmark",
|
||||
"rand 0.8.6",
|
||||
"rayon",
|
||||
@@ -3072,10 +3081,10 @@ dependencies = [
|
||||
"smb2",
|
||||
"ssh-key",
|
||||
"ssh2",
|
||||
"sysinfo",
|
||||
"tar",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tokio-postgres",
|
||||
"tokio-util",
|
||||
"toml",
|
||||
"tower-http 0.5.2",
|
||||
@@ -3134,7 +3143,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"dirs",
|
||||
"dirs 6.0.0",
|
||||
"filetree",
|
||||
"rusqlite",
|
||||
"serde",
|
||||
@@ -3496,6 +3505,15 @@ dependencies = [
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.50.3"
|
||||
@@ -3712,6 +3730,27 @@ dependencies = [
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-io-kit"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"objc2-core-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-open-directory"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb82bed227edf5201dfedf072bba4015a33d3d4a98519837295a90f0a23f676d"
|
||||
dependencies = [
|
||||
"objc2",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-system-configuration"
|
||||
version = "0.3.2"
|
||||
@@ -4202,20 +4241,6 @@ dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "postgres"
|
||||
version = "0.19.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33ad20e0aa0b24f5a394eab4f78c781d248982b22b25cecc7e3aa46a681605bd"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fallible-iterator 0.2.0",
|
||||
"futures-util",
|
||||
"log",
|
||||
"tokio",
|
||||
"tokio-postgres",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "postgres-protocol"
|
||||
version = "0.6.12"
|
||||
@@ -5771,6 +5796,21 @@ dependencies = [
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.39.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2071df9448915b71c4fe6d25deaf1c22f12bd234f01540b77312bb8e41361e6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"memchr",
|
||||
"ntapi",
|
||||
"objc2-core-foundation",
|
||||
"objc2-io-kit",
|
||||
"objc2-open-directory",
|
||||
"windows 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration"
|
||||
version = "0.7.0"
|
||||
|
||||
Binary file not shown.
@@ -90,6 +90,8 @@ ldap3 = { version = "0.11", optional = true } # Async LDAP client (compatible w
|
||||
|
||||
# === NFS Server (Phase 11) ===
|
||||
nfsserve = { version = "0.11", optional = true } # NFSv3/NFSv4 server implementation
|
||||
sysinfo = "0.39.6"
|
||||
dirs = "7.0.0"
|
||||
|
||||
[features]
|
||||
default = [] # 默认不启用可选格式
|
||||
|
||||
@@ -6,30 +6,20 @@ pub enum SshCommand {
|
||||
Start {
|
||||
#[arg(short, long, default_value = "2024")]
|
||||
port: u16,
|
||||
|
||||
/// PostgreSQL connection string for SFTPGo-compatible auth (e.g. "host=127.0.0.1 port=5432 dbname=sftpgo user=sftpgo password=sftpgo_pass_2026")
|
||||
#[arg(long)]
|
||||
pg_conn: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
pub async fn handle_ssh_command(cmd: SshCommand) -> anyhow::Result<()> {
|
||||
match cmd {
|
||||
SshCommand::Start { port, pg_conn } => {
|
||||
println!("=== MarkBase SSH Server (Hand-written Implementation) ===");
|
||||
println!("Port: {}", port);
|
||||
println!("Implementation: SSH-2.0-MarkBaseSSH_1.0");
|
||||
println!("Features: SSH + SFTP + SCP + rsync");
|
||||
if pg_conn.is_some() {
|
||||
println!("Auth Provider: PostgreSQL (SFTPGo-compatible)");
|
||||
} else {
|
||||
println!("Auth Provider: SQLite");
|
||||
}
|
||||
println!("Security: ⭐⭐⭐⭐⭐ (RustCrypto authoritative libraries)");
|
||||
SshCommand::Start { port } => {
|
||||
println!("🚀 Starting SSH server (MarkBaseSSH 1.0)");
|
||||
println!(" Port: {}", port);
|
||||
println!(" Auth Provider: SQLite");
|
||||
println!(" Security: ⭐⭐⭐⭐⭐ (RustCrypto authoritative libraries)");
|
||||
println!();
|
||||
|
||||
crate::ssh_server::server::run_ssh_server(Some(port), pg_conn.as_deref()).await?;
|
||||
crate::ssh_server::server::run_ssh_server(Some(port)).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
use clap::Subcommand;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum WebCommand {
|
||||
@@ -14,7 +15,9 @@ pub enum WebCommand {
|
||||
pub async fn handle_web_command(cmd: WebCommand) -> anyhow::Result<()> {
|
||||
match cmd {
|
||||
WebCommand::Start { port, file } => {
|
||||
crate::server::run(port, file).await?;
|
||||
let home = dirs::home_dir()
|
||||
.ok_or_else(|| anyhow::anyhow!("Cannot determine home directory"))?;
|
||||
crate::server::run(port, file, home).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -298,10 +298,7 @@ pub async fn run(port: u16, file: Option<String>, home: PathBuf) -> anyhow::Resu
|
||||
// Admin authentication API endpoints (public)
|
||||
.route("/api/v2/admin/login", post(crate::api::admin::admin_login_handler))
|
||||
.route("/api/v2/admin/verify", get(crate::api::admin::admin_verify_handler))
|
||||
// User management endpoints (require admin token)
|
||||
.route("/api/v2/admin/users", get(crate::api::admin::list_users_handler).post(crate::api::admin::create_user_handler))
|
||||
.route("/api/v2/admin/users/:username", delete(crate::api::admin::delete_user_handler).put(crate::api::admin::update_user_handler))
|
||||
.route("/api/v2/admin/users/:username/password", post(crate::api::admin::change_password_handler))
|
||||
// User management endpoints removed - PostgreSQL functionality deleted
|
||||
// Service management endpoints
|
||||
.route("/api/v2/service/stop", post(service_stop_handler))
|
||||
.route("/api/v2/service/start", post(service_start_handler))
|
||||
|
||||
@@ -25,7 +25,6 @@ pub struct SshServerConfig {
|
||||
pub port: u16,
|
||||
pub bind_address: String,
|
||||
pub security_config: SshSecurityConfig,
|
||||
pub pg_conn: Option<String>,
|
||||
pub upload_hook_config: crate::config::UploadHookSection,
|
||||
}
|
||||
|
||||
@@ -35,7 +34,6 @@ impl Default for SshServerConfig {
|
||||
port: 2024,
|
||||
bind_address: "0.0.0.0".to_string(), // ⭐⭐⭐⭐⭐ Phase 8.3: Allow Docker container access
|
||||
security_config: SshSecurityConfig::enterprise_default(),
|
||||
pg_conn: None,
|
||||
upload_hook_config: crate::config::UploadHookSection::default(),
|
||||
}
|
||||
}
|
||||
@@ -49,7 +47,6 @@ impl SshServerConfig {
|
||||
port: 2024,
|
||||
bind_address: "0.0.0.0".to_string(), // ⭐⭐⭐⭐⭐ Phase 8.3: Allow Docker container access
|
||||
security_config: config,
|
||||
pg_conn: None,
|
||||
upload_hook_config: crate::config::UploadHookSection::default(),
|
||||
})
|
||||
}
|
||||
@@ -84,7 +81,6 @@ impl SshServer {
|
||||
);
|
||||
|
||||
let security_config = self.security_config.clone();
|
||||
let pg_conn = self.config.pg_conn.clone();
|
||||
let upload_hook_config = self.config.upload_hook_config.clone();
|
||||
|
||||
loop {
|
||||
@@ -93,7 +89,6 @@ impl SshServer {
|
||||
info!("New SSH connection from {}", addr);
|
||||
|
||||
let security_config_clone = security_config.clone();
|
||||
let pg_conn_clone = pg_conn.clone();
|
||||
let upload_hook_config_clone = upload_hook_config.clone();
|
||||
|
||||
// ⭐⭐⭐⭐⭐ Convert tokio TcpStream to std TcpStream for blocking handler
|
||||
@@ -104,12 +99,11 @@ impl SshServer {
|
||||
tokio::spawn(async move {
|
||||
// Run the existing sync connection handler in a blocking thread
|
||||
if let Err(e) = tokio::task::spawn_blocking(move || {
|
||||
handle_connection_complete(
|
||||
std_stream,
|
||||
security_config_clone,
|
||||
pg_conn_clone,
|
||||
upload_hook_config_clone,
|
||||
)
|
||||
handle_connection_complete(
|
||||
std_stream,
|
||||
security_config_clone,
|
||||
upload_hook_config_clone,
|
||||
)
|
||||
}).await.unwrap_or(Err(anyhow!("Task join error")))
|
||||
{
|
||||
error!("SSH connection error: {}", e);
|
||||
@@ -128,7 +122,6 @@ impl SshServer {
|
||||
fn handle_connection_complete(
|
||||
stream: TcpStream,
|
||||
security_config: Arc<Mutex<SshSecurityConfig>>,
|
||||
pg_conn: Option<String>,
|
||||
upload_hook_config: crate::config::UploadHookSection,
|
||||
) -> Result<()> {
|
||||
info!("Handling client connection (Phase 1-13 complete flow with port forwarding)");
|
||||
@@ -783,12 +776,11 @@ fn extract_username_from_auth_request(
|
||||
}
|
||||
|
||||
/// SSH服务器CLI入口
|
||||
pub async fn run_ssh_server(port: Option<u16>, pg_conn: Option<&str>) -> Result<()> {
|
||||
pub async fn run_ssh_server(port: Option<u16>) -> Result<()> {
|
||||
let config = SshServerConfig {
|
||||
port: port.unwrap_or(2024),
|
||||
bind_address: "0.0.0.0".to_string(), // ⭐⭐⭐⭐⭐ Phase 8.3: Allow Docker container access
|
||||
security_config: SshSecurityConfig::enterprise_default(),
|
||||
pg_conn: pg_conn.map(|s| s.to_string()),
|
||||
upload_hook_config: crate::config::UploadHookSection::default(),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user