mirror of
https://github.com/wez/wezterm.git
synced 2024-11-26 08:25:50 +03:00
mux: proxy: extract unix domain from connected client
This resolves an issue where `WEZTERM_UNIX_SOCKET=something wezterm cli proxy` would use `something` for the unix domain path when checking that an existing instance was up and running, but would then use the default implicit socket path when dropping into the proxy passthrough stage. What we do here is transform the connected client into its configuration and use that instead of trying to re-derive the socket from incomplete information. The motivating example is using SSH to get into a workstation that is running a GUI wezterm with no explicit unix domain mux.
This commit is contained in:
parent
d2fa4e9842
commit
6b66b6674a
@ -52,6 +52,7 @@ pub struct Client {
|
||||
sender: Sender<ReaderMessage>,
|
||||
local_domain_id: Option<DomainId>,
|
||||
client_id: ClientId,
|
||||
client_domain_config: ClientDomainConfig,
|
||||
pub is_reconnectable: bool,
|
||||
pub is_local: bool,
|
||||
}
|
||||
@ -1015,6 +1016,7 @@ impl Reconnectable {
|
||||
|
||||
impl Client {
|
||||
fn new(local_domain_id: Option<DomainId>, mut reconnectable: Reconnectable) -> Self {
|
||||
let client_domain_config = reconnectable.config.clone();
|
||||
let is_reconnectable = reconnectable.reconnectable();
|
||||
let is_local = reconnectable.is_local();
|
||||
let (sender, mut receiver) = unbounded();
|
||||
@ -1112,9 +1114,14 @@ impl Client {
|
||||
is_reconnectable,
|
||||
is_local,
|
||||
client_id,
|
||||
client_domain_config,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_client_domain_config(self) -> ClientDomainConfig {
|
||||
self.client_domain_config
|
||||
}
|
||||
|
||||
pub async fn verify_version_compat(
|
||||
&self,
|
||||
ui: &ConnectionUI,
|
||||
|
@ -5,20 +5,26 @@ use mux::Mux;
|
||||
use std::io::{Read, Write};
|
||||
use std::sync::Arc;
|
||||
use wezterm_client::client::{unix_connect_with_retry, Client};
|
||||
use wezterm_client::domain::ClientDomainConfig;
|
||||
|
||||
#[derive(Debug, Parser, Clone)]
|
||||
pub struct ProxyCommand {}
|
||||
|
||||
impl ProxyCommand {
|
||||
pub async fn run(&self, client: Client, config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
pub async fn run(&self, client: Client, _config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
// The client object we created above will have spawned
|
||||
// the server if needed, so now all we need to do is turn
|
||||
// ourselves into basically netcat.
|
||||
drop(client);
|
||||
|
||||
// Extract the selected configuration from the client,
|
||||
// closing it in the process
|
||||
let ClientDomainConfig::Unix(unix_dom) = client.into_client_domain_config() else {
|
||||
anyhow::bail!("expected client to have connected to a unix domain");
|
||||
};
|
||||
|
||||
let mux = Arc::new(mux::Mux::new(None));
|
||||
Mux::set_mux(&mux);
|
||||
let unix_dom = config.unix_domains.first().unwrap();
|
||||
|
||||
let target = unix_dom.target();
|
||||
let stream = unix_connect_with_retry(&target, false, None)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user