Fix compilation errors after PostgreSQL removal
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

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:
Warren
2026-10-24 20:12:23 +08:00
parent 0802a47a5f
commit 45ae7099d2
7 changed files with 77 additions and 53 deletions
+7 -17
View File
@@ -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(())
}
}
+4 -1
View File
@@ -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(())
+1 -4
View File
@@ -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))
+6 -14
View File
@@ -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(),
};