require all domains to have names
This commit is contained in:
1 parent
af69842fa0
commit
5d6bc3882c
5 files changed
+59
-7
No files matched your search
@@ -426,6 +426,10 @@ impl DaemonOptions {
|
||||
|
||||
#[derive(Default, Debug, Clone, Deserialize)]
|
||||
pub struct SshDomain {
|
||||
/// The name of this specific domain. Must be unique amongst
|
||||
/// all types of domain in the configuration file.
|
||||
pub name: String,
|
||||
|
||||
/// identifies the host:port pair of the remote server.
|
||||
pub remote_address: String,
|
||||
|
||||
@@ -445,6 +449,10 @@ pub struct SshDomain {
|
||||
/// with via a unix domain socket
|
||||
#[derive(Default, Debug, Clone, Deserialize)]
|
||||
pub struct UnixDomain {
|
||||
/// The name of this specific domain. Must be unique amongst
|
||||
/// all types of domain in the configuration file.
|
||||
pub name: String,
|
||||
|
||||
/// The path to the socket. If unspecified, a resonable default
|
||||
/// value will be computed.
|
||||
pub socket_path: Option<PathBuf>,
|
||||
@@ -527,6 +535,10 @@ pub struct TlsDomainServer {
|
||||
|
||||
#[derive(Default, Debug, Clone, Deserialize)]
|
||||
pub struct TlsDomainClient {
|
||||
/// The name of this specific domain. Must be unique amongst
|
||||
/// all types of domain in the configuration file.
|
||||
pub name: String,
|
||||
|
||||
/// identifies the host:port pair of the remote server.
|
||||
pub remote_address: String,
|
||||
|
||||
|
||||
+6
-3
@@ -259,8 +259,11 @@ fn run_ssh(config: Arc<config::Config>, opts: &SshCommand) -> Fallible<()> {
|
||||
|
||||
let sess = ssh::ssh_connect(¶ms.host_and_port, ¶ms.username)?;
|
||||
let pty_system = Box::new(portable_pty::ssh::SshSession::new(sess));
|
||||
let domain: Arc<dyn Domain> =
|
||||
Arc::new(ssh::RemoteSshDomain::with_pty_system(&config, pty_system));
|
||||
let domain: Arc<dyn Domain> = Arc::new(ssh::RemoteSshDomain::with_pty_system(
|
||||
&opts.user_at_host_and_port,
|
||||
&config,
|
||||
pty_system,
|
||||
));
|
||||
|
||||
let mux = Rc::new(mux::Mux::new(&config, &domain));
|
||||
Mux::set_mux(&mux);
|
||||
@@ -313,7 +316,7 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: &StartCommand) -> Fallibl
|
||||
None
|
||||
};
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new(&config)?);
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new("local", &config)?);
|
||||
let mux = Rc::new(mux::Mux::new(&config, &domain));
|
||||
Mux::set_mux(&mux);
|
||||
|
||||
|
||||
+16
-3
@@ -44,6 +44,9 @@ pub trait Domain: Downcast {
|
||||
/// a handle on the domain later.
|
||||
fn domain_id(&self) -> DomainId;
|
||||
|
||||
/// Returns the name of the domain
|
||||
fn domain_name(&self) -> &str;
|
||||
|
||||
/// Re-attach to any tabs that might be pre-existing in this domain
|
||||
fn attach(&self) -> Fallible<()>;
|
||||
|
||||
@@ -59,21 +62,27 @@ pub struct LocalDomain {
|
||||
pty_system: Box<dyn PtySystem>,
|
||||
config: Arc<Config>,
|
||||
id: DomainId,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl LocalDomain {
|
||||
pub fn new(config: &Arc<Config>) -> Result<Self, Error> {
|
||||
pub fn new(name: &str, config: &Arc<Config>) -> Result<Self, Error> {
|
||||
let pty_system = config.pty.get()?;
|
||||
Ok(Self::with_pty_system(config, pty_system))
|
||||
Ok(Self::with_pty_system(name, config, pty_system))
|
||||
}
|
||||
|
||||
pub fn with_pty_system(config: &Arc<Config>, pty_system: Box<dyn PtySystem>) -> Self {
|
||||
pub fn with_pty_system(
|
||||
name: &str,
|
||||
config: &Arc<Config>,
|
||||
pty_system: Box<dyn PtySystem>,
|
||||
) -> Self {
|
||||
let config = Arc::clone(config);
|
||||
let id = alloc_domain_id();
|
||||
Self {
|
||||
pty_system,
|
||||
config,
|
||||
id,
|
||||
name: name.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,6 +127,10 @@ impl Domain for LocalDomain {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn domain_name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
fn attach(&self) -> Fallible<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -61,6 +61,16 @@ pub enum ClientDomainConfig {
|
||||
Ssh(SshDomain),
|
||||
}
|
||||
|
||||
impl ClientDomainConfig {
|
||||
fn name(&self) -> &str {
|
||||
match self {
|
||||
ClientDomainConfig::Unix(unix) => &unix.name,
|
||||
ClientDomainConfig::Tls(tls) => &tls.name,
|
||||
ClientDomainConfig::Ssh(ssh) => &ssh.name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ClientInner {
|
||||
pub fn new(local_domain_id: DomainId, client: Client) -> Self {
|
||||
// Assumption: that the domain id on the other end is
|
||||
@@ -133,6 +143,10 @@ impl Domain for ClientDomain {
|
||||
self.local_domain_id
|
||||
}
|
||||
|
||||
fn domain_name(&self) -> &str {
|
||||
self.config.name()
|
||||
}
|
||||
|
||||
fn spawn(
|
||||
&self,
|
||||
size: PtySize,
|
||||
|
||||
+11
-1
@@ -227,16 +227,22 @@ pub struct RemoteSshDomain {
|
||||
pty_system: Box<dyn PtySystem>,
|
||||
config: Arc<Config>,
|
||||
id: DomainId,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl RemoteSshDomain {
|
||||
pub fn with_pty_system(config: &Arc<Config>, pty_system: Box<dyn PtySystem>) -> Self {
|
||||
pub fn with_pty_system(
|
||||
name: &str,
|
||||
config: &Arc<Config>,
|
||||
pty_system: Box<dyn PtySystem>,
|
||||
) -> Self {
|
||||
let config = Arc::clone(config);
|
||||
let id = alloc_domain_id();
|
||||
Self {
|
||||
pty_system,
|
||||
config,
|
||||
id,
|
||||
name: name.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,6 +287,10 @@ impl Domain for RemoteSshDomain {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn domain_name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
fn attach(&self) -> Fallible<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user