cossh/ssh_config/
model.rs1use crate::inventory::{ConnectionProtocol, SshOptionMap, TreeFolder};
4use std::path::PathBuf;
5
6#[derive(Debug, Clone)]
8pub struct SshHost {
9 pub name: String,
11 pub protocol: ConnectionProtocol,
13 pub hostname: Option<String>,
15 pub user: Option<String>,
17 pub port: Option<u16>,
19 pub identity_files: Vec<String>,
21 pub identities_only: Option<bool>,
23 pub proxy_jump: Option<String>,
25 pub proxy_command: Option<String>,
27 pub forward_agent: Option<String>,
29 pub description: Option<String>,
31 pub profile: Option<String>,
33 pub pass_key: Option<String>,
35 pub rdp_domain: Option<String>,
37 pub rdp_args: Vec<String>,
39 pub hidden: bool,
41 pub local_forward: Vec<String>,
43 pub remote_forward: Vec<String>,
45 pub other_options: SshOptionMap,
47}
48
49impl SshHost {
50 pub fn new(name: String) -> Self {
52 Self {
53 name,
54 protocol: ConnectionProtocol::Ssh,
55 hostname: None,
56 user: None,
57 port: None,
58 identity_files: Vec::new(),
59 identities_only: None,
60 proxy_jump: None,
61 proxy_command: None,
62 forward_agent: None,
63 description: None,
64 profile: None,
65 pass_key: None,
66 rdp_domain: None,
67 rdp_args: Vec::new(),
68 hidden: false,
69 local_forward: Vec::new(),
70 remote_forward: Vec::new(),
71 other_options: SshOptionMap::new(),
72 }
73 }
74}
75
76#[derive(Debug, Clone)]
78pub struct SshHostTreeModel {
79 pub root: TreeFolder,
81 pub hosts: Vec<SshHost>,
83}
84
85impl SshHostTreeModel {
86 #[allow(dead_code)]
87 pub(super) fn empty(root_path: PathBuf) -> Self {
88 let root_name = root_path.file_name().and_then(|segment| segment.to_str()).unwrap_or("config").to_string();
89 Self {
90 root: TreeFolder {
91 id: 0,
92 name: root_name,
93 path: root_path,
94 children: Vec::new(),
95 host_indices: Vec::new(),
96 },
97 hosts: Vec::new(),
98 }
99 }
100}