Revert "Start work on handling TLS for the RPC endpoint"

This reverts commit 193c704875.
This commit is contained in:
Antonio Scandurra
2021-07-07 15:19:00 +02:00
parent 193c704875
commit ee962eab9b
6 changed files with 21 additions and 114 deletions
+5 -15
View File
@@ -115,23 +115,14 @@ impl Client {
access_token: String,
executor: &Arc<Background>,
) -> surf::Result<()> {
// TODO - If the `ZED_SERVER_URL` uses https, then wrap this stream in
// a TLS stream using `native-tls`.
let stream = smol::net::TcpStream::connect(&address).await?;
let connection_id = if ZED_SERVER_URL.starts_with("https") {
let host = address.split(':').next().unwrap();
let stream = async_native_tls::connect(host, stream)
.await
.context("failed to establish TLS connection")?;
let (conn_id, handler) = self.peer.add_connection(stream).await;
executor.spawn(handler.run()).detach();
conn_id
} else {
let (conn_id, handler) = self.peer.add_connection(stream).await;
executor.spawn(handler.run()).detach();
conn_id
};
log::info!("connected to rpc address {}", address);
let (connection_id, handler) = self.peer.add_connection(stream).await;
executor.spawn(handler.run()).detach();
let auth_response = self
.peer
.request(
@@ -147,7 +138,6 @@ impl Client {
Err(anyhow!("failed to authenticate with RPC server"))?;
}
log::info!("authenticated rpc connection as user {}", user_id);
self.state.write().await.connection_id = Some(connection_id);
Ok(())
}