mux server: register additional domains
Relocate the helper function to mux-server-impl and have both the GUI and the mux server call it at the appropriate times. Introduce default_mux_server_domain which is used instead of default_domain in the mux server. This is to avoid recursive cycles when starting up the mux; we don't want the default domain to be a unix client that connects to our selves because we'll try to connect to ourselves, then in act of handling that spawn in the default domain and try to connect to ourselves and repeat. refs: https://github.com/wez/wezterm/issues/3907
This commit is contained in:
9 files changed
+160
-82
No files matched your search
Generated
+1
@@ -6157,6 +6157,7 @@ dependencies = [
|
||||
"termwiz",
|
||||
"uds_windows",
|
||||
"url",
|
||||
"wezterm-client",
|
||||
"wezterm-term",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
@@ -789,6 +789,9 @@ pub struct Config {
|
||||
#[dynamic(default)]
|
||||
pub default_domain: Option<String>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub default_mux_server_domain: Option<String>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub default_workspace: Option<String>,
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* [exit_behavior_messaging](config/lua/config/exit_behavior_messaging.md)
|
||||
option to control output when holding a pane open after a process completes.
|
||||
#3423
|
||||
* [default_mux_server_domain](config/lua/config/default_mux_server_domain.md) for the
|
||||
(almost!) equivalent to [default_domain](config/lua/config/default_domain.md) in
|
||||
the context of the mux server.
|
||||
|
||||
#### Fixed
|
||||
|
||||
@@ -126,6 +129,9 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
`exit_behavior="CloseOnCleanExit"` if the command fails to spawn, and
|
||||
a more detailed error message is shown explaining what failed. #3928 #3950
|
||||
* macOS: middle mouse button dragging. Thanks to @JacobMalloy! #3908
|
||||
* Attempting to spawn a non-local domain via the mux server would fail with
|
||||
invalid domain because none of the additional domains from your config were
|
||||
registered with the mux server. #3907
|
||||
|
||||
#### Updated
|
||||
* Bundled harfbuzz to 8.0.0
|
||||
|
||||
@@ -6,6 +6,10 @@ tags:
|
||||
|
||||
{{since('20220319-142410-0fcdea07')}}
|
||||
|
||||
!!! note
|
||||
This option only applies to the GUI. For the equivalent option in
|
||||
the standalone mux server, see [default_mux_server_domain](default_mux_server_domain.md)
|
||||
|
||||
When starting the GUI (not using the `serial` or `connect` subcommands), by default wezterm will set the built-in `"local"` domain as the default multiplexing domain.
|
||||
|
||||
The `"local"` domain represents processes that are spawned directly on the local system.
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
tags:
|
||||
- multiplexing
|
||||
---
|
||||
# `default_mux_server_domain = "local"`
|
||||
|
||||
{{since('nightly')}}
|
||||
|
||||
!!! note
|
||||
This option only applies to the standalone mux server. For the equivalent option in
|
||||
the GUI, see [default_domain](default_domain.md)
|
||||
|
||||
When starting the mux server, by default wezterm will set the built-in
|
||||
`"local"` domain as the default multiplexing domain.
|
||||
|
||||
The `"local"` domain represents processes that are spawned directly on the
|
||||
local system.
|
||||
|
||||
This option allows you to change the default domain to some other domain, such
|
||||
as an [ExecDomain](../ExecDomain.md).
|
||||
|
||||
It is *not* possible to configure a client multiplexing domain such as a TLS,
|
||||
SSH or Unix domain as the default for the multiplexer server. That is
|
||||
prohibited in order to prevent recursion when a client connects to the server.
|
||||
|
||||
+2
-81
@@ -11,7 +11,6 @@ use config::keyassignment::{SpawnCommand, SpawnTabDomain};
|
||||
use config::{ConfigHandle, SerialDomain, SshDomain, SshMultiplexing};
|
||||
use mux::activity::Activity;
|
||||
use mux::domain::{Domain, LocalDomain};
|
||||
use mux::ssh::RemoteSshDomain;
|
||||
use mux::Mux;
|
||||
use mux_lua::MuxDomain;
|
||||
use portable_pty::cmdbuilder::CommandBuilder;
|
||||
@@ -27,9 +26,10 @@ use termwiz::cell::{CellAttributes, UnicodeVersion};
|
||||
use termwiz::surface::{Line, SEQ_ZERO};
|
||||
use unicode_normalization::UnicodeNormalization;
|
||||
use wezterm_bidi::Direction;
|
||||
use wezterm_client::domain::{ClientDomain, ClientDomainConfig};
|
||||
use wezterm_client::domain::ClientDomain;
|
||||
use wezterm_font::shaper::PresentationWidth;
|
||||
use wezterm_gui_subcommands::*;
|
||||
use wezterm_mux_server_impl::update_mux_domains;
|
||||
use wezterm_toast_notification::*;
|
||||
|
||||
mod colorease;
|
||||
@@ -244,24 +244,6 @@ fn run_serial(config: config::ConfigHandle, opts: SerialCommand) -> anyhow::Resu
|
||||
gui.run_forever()
|
||||
}
|
||||
|
||||
fn client_domains(config: &config::ConfigHandle) -> Vec<ClientDomainConfig> {
|
||||
let mut domains = vec![];
|
||||
for unix_dom in &config.unix_domains {
|
||||
domains.push(ClientDomainConfig::Unix(unix_dom.clone()));
|
||||
}
|
||||
|
||||
for ssh_dom in config.ssh_domains().into_iter() {
|
||||
if ssh_dom.multiplexing == SshMultiplexing::WezTerm {
|
||||
domains.push(ClientDomainConfig::Ssh(ssh_dom.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
for tls_client in &config.tls_clients {
|
||||
domains.push(ClientDomainConfig::Tls(tls_client.clone()));
|
||||
}
|
||||
domains
|
||||
}
|
||||
|
||||
fn have_panes_in_domain_and_ws(domain: &Arc<dyn Domain>, workspace: &Option<String>) -> bool {
|
||||
let mux = Mux::get();
|
||||
let have_panes_in_domain = mux
|
||||
@@ -348,67 +330,6 @@ async fn spawn_tab_in_domain_if_mux_is_empty(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
let mux = Mux::get();
|
||||
|
||||
for client_config in client_domains(&config) {
|
||||
if mux.get_domain_by_name(client_config.name()).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(ClientDomain::new(client_config));
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for ssh_dom in config.ssh_domains().into_iter() {
|
||||
if ssh_dom.multiplexing != SshMultiplexing::None {
|
||||
continue;
|
||||
}
|
||||
|
||||
if mux.get_domain_by_name(&ssh_dom.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(RemoteSshDomain::with_ssh_domain(&ssh_dom)?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for wsl_dom in config.wsl_domains() {
|
||||
if mux.get_domain_by_name(&wsl_dom.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new_wsl(wsl_dom.clone())?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for exec_dom in &config.exec_domains {
|
||||
if mux.get_domain_by_name(&exec_dom.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new_exec_domain(exec_dom.clone())?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for serial in &config.serial_ports {
|
||||
if mux.get_domain_by_name(&serial.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new_serial_domain(serial.clone())?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
if let Some(name) = &config.default_domain {
|
||||
if let Some(dom) = mux.get_domain_by_name(name) {
|
||||
mux.set_default_domain(&dom);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn connect_to_auto_connect_domains() -> anyhow::Result<()> {
|
||||
let mux = Mux::get();
|
||||
let domains = mux.iter_domains();
|
||||
|
||||
@@ -22,6 +22,7 @@ rangeset = { path = "../rangeset" }
|
||||
rcgen = "0.9"
|
||||
smol = "1.2"
|
||||
url = "2"
|
||||
wezterm-client = { path = "../wezterm-client" }
|
||||
wezterm-term = { path = "../term", features=["use_serde"] }
|
||||
termwiz = { path = "../termwiz", features=["use_serde"] }
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
use config::{ConfigHandle, SshMultiplexing};
|
||||
use mux::domain::{Domain, LocalDomain};
|
||||
use mux::ssh::RemoteSshDomain;
|
||||
use mux::Mux;
|
||||
use std::sync::Arc;
|
||||
use wezterm_client::domain::{ClientDomain, ClientDomainConfig};
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::net::{UnixListener, UnixStream};
|
||||
#[cfg(windows)]
|
||||
@@ -8,6 +15,104 @@ pub mod local;
|
||||
pub mod pki;
|
||||
pub mod sessionhandler;
|
||||
|
||||
fn client_domains(config: &config::ConfigHandle) -> Vec<ClientDomainConfig> {
|
||||
let mut domains = vec![];
|
||||
for unix_dom in &config.unix_domains {
|
||||
domains.push(ClientDomainConfig::Unix(unix_dom.clone()));
|
||||
}
|
||||
|
||||
for ssh_dom in config.ssh_domains().into_iter() {
|
||||
if ssh_dom.multiplexing == SshMultiplexing::WezTerm {
|
||||
domains.push(ClientDomainConfig::Ssh(ssh_dom.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
for tls_client in &config.tls_clients {
|
||||
domains.push(ClientDomainConfig::Tls(tls_client.clone()));
|
||||
}
|
||||
domains
|
||||
}
|
||||
|
||||
pub fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
update_mux_domains_impl(config, false)
|
||||
}
|
||||
|
||||
pub fn update_mux_domains_for_server(config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
update_mux_domains_impl(config, true)
|
||||
}
|
||||
|
||||
fn update_mux_domains_impl(config: &ConfigHandle, is_standalone_mux: bool) -> anyhow::Result<()> {
|
||||
let mux = Mux::get();
|
||||
|
||||
for client_config in client_domains(&config) {
|
||||
if mux.get_domain_by_name(client_config.name()).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(ClientDomain::new(client_config));
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for ssh_dom in config.ssh_domains().into_iter() {
|
||||
if ssh_dom.multiplexing != SshMultiplexing::None {
|
||||
continue;
|
||||
}
|
||||
|
||||
if mux.get_domain_by_name(&ssh_dom.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(RemoteSshDomain::with_ssh_domain(&ssh_dom)?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for wsl_dom in config.wsl_domains() {
|
||||
if mux.get_domain_by_name(&wsl_dom.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new_wsl(wsl_dom.clone())?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for exec_dom in &config.exec_domains {
|
||||
if mux.get_domain_by_name(&exec_dom.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new_exec_domain(exec_dom.clone())?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for serial in &config.serial_ports {
|
||||
if mux.get_domain_by_name(&serial.name).is_some() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(LocalDomain::new_serial_domain(serial.clone())?);
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
if is_standalone_mux {
|
||||
if let Some(name) = &config.default_mux_server_domain {
|
||||
if let Some(dom) = mux.get_domain_by_name(name) {
|
||||
if dom.is::<ClientDomain>() {
|
||||
anyhow::bail!("default_mux_server_domain cannot be set to a client domain!");
|
||||
}
|
||||
mux.set_default_domain(&dom);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(name) = &config.default_domain {
|
||||
if let Some(dom) = mux.get_domain_by_name(name) {
|
||||
mux.set_default_domain(&dom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref PKI: pki::Pki = pki::Pki::init().expect("failed to initialize PKI");
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use wezterm_gui_subcommands::*;
|
||||
use wezterm_mux_server_impl::update_mux_domains_for_server;
|
||||
|
||||
mod daemonize;
|
||||
|
||||
@@ -256,6 +257,18 @@ async fn trigger_mux_startup(lua: Option<Rc<mlua::Lua>>) -> anyhow::Result<()> {
|
||||
|
||||
async fn async_run(cmd: Option<CommandBuilder>) -> anyhow::Result<()> {
|
||||
let mux = Mux::get();
|
||||
let config = config::configuration();
|
||||
|
||||
update_mux_domains_for_server(&config)?;
|
||||
let _config_subscription = config::subscribe_to_config_reload(move || {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
if let Err(err) = update_mux_domains_for_server(&config::configuration()) {
|
||||
log::error!("Error updating mux domains: {:#}", err);
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
true
|
||||
});
|
||||
|
||||
let domain = mux.default_domain();
|
||||
|
||||
@@ -276,7 +289,6 @@ async fn async_run(cmd: Option<CommandBuilder>) -> anyhow::Result<()> {
|
||||
let window_id = mux.new_empty_window(workspace, position);
|
||||
domain.attach(Some(*window_id)).await?;
|
||||
|
||||
let config = config::configuration();
|
||||
let _tab = mux
|
||||
.default_domain()
|
||||
.spawn(config.initial_size(0), cmd, None, *window_id)
|
||||
|
||||
Reference in new issue
Block a user