Pure Rust (D27): russh + russh-sftp with ring, suppaftp with rustls/ring, keyring (Windows Credential Manager, macOS Keychain). Lutra's own known-hosts file, refuse on mismatch. In-process SFTP and FTP test servers behind the testserver feature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1 KiB
Rust
26 lines
1 KiB
Rust
//! Runs the local SFTP and FTP test servers for a live check:
|
|
//! `cargo run -p lutra-deploy --features testserver --example testserver -- DIR USER PASSWORD`.
|
|
//! Both listen on 127.0.0.1 only and serve `DIR`. Prints their ports and
|
|
//! the SFTP host key, then runs until standard input closes.
|
|
|
|
use std::io::Read;
|
|
use std::path::PathBuf;
|
|
|
|
use lutra_deploy::testserver::{FtpServer, SftpServer};
|
|
|
|
fn main() -> std::io::Result<()> {
|
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
|
let [dir, user, password] = args.as_slice() else {
|
|
eprintln!("usage: testserver DIR USER PASSWORD");
|
|
std::process::exit(2);
|
|
};
|
|
let dir = PathBuf::from(dir);
|
|
std::fs::create_dir_all(&dir)?;
|
|
let sftp = SftpServer::start(&dir, user, Some(password), None, 9)?;
|
|
let ftp = FtpServer::start(&dir, user, password)?;
|
|
println!("sftp {} {} {}", sftp.addr, sftp.algorithm, sftp.fingerprint);
|
|
println!("ftp {}", ftp.addr);
|
|
let mut sink = Vec::new();
|
|
std::io::stdin().read_to_end(&mut sink)?;
|
|
Ok(())
|
|
}
|