Skip to content

Commit

Permalink
add some more diagnostics for mux connections
Browse files Browse the repository at this point in the history
I suspect some race condition because adding these made the connect
time hang stop reproducing for me on my local network.

Will try this to the corp vpn.

refs: #127
  • Loading branch information
wez committed Feb 2, 2020
1 parent cb9ec2f commit 7257cf1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/server/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ fn client_thread(
next_serial += 1;
promises.insert(serial, promise);

pdu.encode(reconnectable.stream(), serial)?;
reconnectable.stream().flush()?;
pdu.encode(reconnectable.stream(), serial)
.context("encoding a PDU to send to the server")?;
reconnectable
.stream()
.flush()
.context("flushing PDU to server")?;
}
},
Err(TryRecvError::Empty) => break,
Expand Down Expand Up @@ -166,7 +170,8 @@ fn client_thread(
Ok(Some(decoded)) => {
log::trace!("decoded serial {}", decoded.serial);
if decoded.serial == 0 {
process_unilateral(local_domain_id, decoded)?;
process_unilateral(local_domain_id, decoded)
.context("processing unilateral PDU from server")?;
} else if let Some(mut promise) = promises.remove(&decoded.serial) {
promise.result(Ok(decoded.pdu));
} else {
Expand Down Expand Up @@ -582,7 +587,7 @@ impl Reconnectable {
.configure()?
.verify_hostname(!tls_client.accept_invalid_hostnames);

ui.output_str(&format!("Connecting to {}\n", remote_address));
ui.output_str(&format!("Connecting to {} using TLS\n", remote_address));
let stream = TcpStream::connect(remote_address)
.with_context(|| format!("connecting to {}", remote_address))?;
stream.set_nodelay(true)?;
Expand All @@ -606,7 +611,7 @@ impl Reconnectable {
)
})?,
);
ui.output_str("Connected!\n");
ui.output_str("TLS Connected!\n");
self.stream.replace(stream);
Ok(())
}
Expand Down
7 changes: 6 additions & 1 deletion src/server/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,14 @@ impl Domain for ClientDomain {
}
};

ui.output_str("Version check OK! Requesting tab list...\n");
let tabs = client.list_tabs().await?;

ui.output_str(&format!(
"Server has {} tabs. Attaching to local UI...\n",
tabs.tabs.len()
));
ClientDomain::finish_attach(domain_id, client, tabs)?;
ui.output_str("Attached!\n");
drop(activity);
ui.close();
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ pub fn ssh_connect_with_ui(
}
};

ui.output_str(&format!("Connecting to {}\n", remote_address));
ui.output_str(&format!("Connecting to {} using SSH\n", remote_address));

let tcp = TcpStream::connect(&remote_address)
.with_context(|| format!("ssh connecting to {}", remote_address))?;
ui.output_str("Connected OK!\n");
ui.output_str("SSH: Connected OK!\n");
tcp.set_nodelay(true)?;
sess.set_tcp_stream(tcp);
sess.handshake()
Expand Down Expand Up @@ -185,7 +185,7 @@ pub fn ssh_connect_with_ui(
"Password authentication for {}@{}\n",
username, remote_address
));
let pass = ui.password("Password: ")?;
let pass = ui.password("🔐 Password: ")?;
if let Err(err) = sess.userauth_password(username, &pass) {
log::error!("while attempting password auth: {}", err);
}
Expand Down

0 comments on commit 7257cf1

Please sign in to comment.