Struct massh::MasshConfig [−][src]
pub struct MasshConfig {
pub default_auth: SshAuth,
pub default_port: u16,
pub default_user: String,
pub threads: u64,
pub timeout: u64,
pub hosts: Vec<MasshHostConfig>,
}
Expand description
Configuration for a MasshClient
.
Fields
default_auth: SshAuth
Default authentication method for all configured hosts.
default_port: u16
Default port number for all configured hosts.
default_user: String
Default username for all configured hosts.
threads: u64
Number of threads in the internal thread pool.
A value of zero signifies 1 thread per configured host.
timeout: u64
Timeout, in milliseconds, for blocking functions.
A value of zero signifies no timeout.
hosts: Vec<MasshHostConfig>
List of configured hosts.
Internally, every host is uniquely identified by the tuple (username, ip_address, port). Duplicates are discarded.
Implementations
Attempts to construct a new MasshConfig
from a JSON string.
Simple Example
{
"default_auth": "agent",
"default_port": 22,
"default_user": "username",
"threads": 0,
"timeout": 0,
"hosts": [
"1.1.1.1",
"2.2.2.2",
"3.3.3.3"
]
}
Complex Example
{
"default_auth": {
"pubkey": "/home/username/.ssh/id_rsa"
},
"default_port": 22,
"default_user": "username",
"threads": 2,
"timeout": 5000,
"hosts": [
"1.1.1.1",
"other-user-1@2.2.2.2",
"other-user-2@3.3.3.3:20022",
{
"addr": "4.4.4.4"
},
{
"addr": "5.5.5.5",
"auth": "agent",
"port": null,
"user": null
},
{
"addr": "6.6.6.6",
"auth": {
"password": "special-password"
},
"user": "other-user-3"
}
]
}
Usage
use massh::MasshConfig;
let json = std::fs::read_to_string("massh.json").unwrap();
let config = MasshConfig::from_json(&json).unwrap();
Attempts to construct a new MasshConfig
from a YAML string.
Simple Example
---
default_auth: agent
default_port: 22
default_user: username
threads: 0
timeout: 0
hosts:
- 1.1.1.1
- 2.2.2.2
- 3.3.3.3
Complex Example
---
default_auth:
pubkey: /home/username/.ssh/id_rsa
default_port: 22
default_user: username
threads: 2
timeout: 5000
hosts:
- 1.1.1.1
- other-user-1@2.2.2.2
- other-user-2@3.3.3.3:20022
- addr: 4.4.4.4
- addr: 5.5.5.5
auth: agent
port: ~
user: ~
- addr: 6.6.6.6
auth:
password: special-password
user: other-user-3
Usage
use massh::MasshConfig;
let yaml = std::fs::read_to_string("massh.yaml").unwrap();
let config = MasshConfig::from_yaml(&yaml).unwrap();
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more