This commit is contained in:
2025-01-05 16:18:37 +08:00
parent 9bb6854125
commit f62fea3d2b
11 changed files with 400 additions and 42 deletions

View File

@@ -1,24 +1,69 @@
use std::io;
use std::{io, path::Path};
use app::App;
use session::connection::{Connection, ShConnection};
use base64::{engine::general_purpose::STANDARD, Engine as _};
use session::{
connection::{Connection, ConnectionManager, Connections, ShConnection, SshConnection},
credential::{Credential, CredentialManager, CredentialType},
SessionManager,
};
use util::file;
mod app;
mod session;
mod view;
mod global;
mod session;
mod util;
// fn main() -> io::Result<()> {
// let mut terminal = ratatui::init();
// let app_result = App::default().run(&mut terminal);
// ratatui::restore();
// app_result
// }
//
mod view;
fn main() -> io::Result<()> {
let sh = ShConnection::new("zsh".to_string(), "/usr/bin/nu".to_string(), None);
let _ = sh.exec_cmd();
Ok(())
let mut terminal = ratatui::init();
let app_result = App::default().run(&mut terminal);
ratatui::restore();
app_result
}
// fn main() -> io::Result<()> {
// // let sh = ShConnection::new("zsh".to_string(), "/usr/bin/nu".to_string(), None);
// // let _ = sh.exec_cmd();
// let ssh = SshConnection::new("".to_string(), "myhost.fallen-angle.com".to_string(), 7044, "rainbus".to_string(), "".to_string());
// ssh.exec_cmd();
// Ok(())
// }
/* fn main() -> io::Result<()> {
let mut cnm = ConnectionManager::default();
let sh = Connections::Sh(ShConnection::new(
"zsh".to_string(),
"/usr/bin/zsh".to_string(),
None,
));
let ssh_sec = Connections::Ssh(SshConnection::new(
"Tencent".to_string(),
"myhost.fallen-angle.com".to_string(),
22,
"rainbus".to_string(),
"Server".to_string(),
));
let ssh_pwd = Connections::Ssh(SshConnection::new(
"Aliyun".to_string(),
"myweb.fallen-angle.com".to_string(),
22,
"rainbus".to_string(),
"AliPwd".to_string(),
));
cnm.connections().extend([sh, ssh_sec, ssh_pwd]);
let mut crm = CredentialManager::default();
let ser_crd = Credential::new(
"Server".to_string(),
CredentialType::Secret(STANDARD.encode(file::read_file(Path::new("")))),
);
let pwd_crd = Credential::new(
"Alipwd".to_string(),
CredentialType::Password("20001001".to_string()),
);
crm.credentials().extend([ser_crd, pwd_crd]);
let sem = SessionManager::new(cnm, crm);
// println!("{}", toml::to_string_pretty(&sem).unwrap());
file::write_file(&global::CONFIG_DIR.join("tethers.toml"), toml::to_string_pretty(&sem).unwrap().as_str());
Ok(())
} */