//! 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 = 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(()) }