remove unused code
This commit is contained in:
@@ -55,21 +55,18 @@ impl Default for GurtClientConfig {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Connection {
|
enum Connection {
|
||||||
Plain(TcpStream),
|
Plain(TcpStream),
|
||||||
Tls(tokio_rustls::client::TlsStream<TcpStream>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
async fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
async fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
||||||
match self {
|
match self {
|
||||||
Connection::Plain(stream) => stream.read(buf).await.map_err(|e| GurtError::connection(e.to_string())),
|
Connection::Plain(stream) => stream.read(buf).await.map_err(|e| GurtError::connection(e.to_string())),
|
||||||
Connection::Tls(stream) => stream.read(buf).await.map_err(|e| GurtError::connection(e.to_string())),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn write_all(&mut self, buf: &[u8]) -> Result<()> {
|
async fn write_all(&mut self, buf: &[u8]) -> Result<()> {
|
||||||
match self {
|
match self {
|
||||||
Connection::Plain(stream) => stream.write_all(buf).await.map_err(|e| GurtError::connection(e.to_string())),
|
Connection::Plain(stream) => stream.write_all(buf).await.map_err(|e| GurtError::connection(e.to_string())),
|
||||||
Connection::Tls(stream) => stream.write_all(buf).await.map_err(|e| GurtError::connection(e.to_string())),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,10 +80,6 @@ impl PooledConnection {
|
|||||||
fn new(stream: TcpStream) -> Self {
|
fn new(stream: TcpStream) -> Self {
|
||||||
Self { connection: Connection::Plain(stream) }
|
Self { connection: Connection::Plain(stream) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_tls(stream: tokio_rustls::client::TlsStream<TcpStream>) -> Self {
|
|
||||||
Self { connection: Connection::Tls(stream) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GurtClient {
|
pub struct GurtClient {
|
||||||
@@ -259,7 +252,6 @@ impl GurtClient {
|
|||||||
|
|
||||||
let tcp_stream = match plain_conn.connection {
|
let tcp_stream = match plain_conn.connection {
|
||||||
Connection::Plain(stream) => stream,
|
Connection::Plain(stream) => stream,
|
||||||
_ => return Err(GurtError::protocol("Expected plain connection for handshake")),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.upgrade_to_tls(tcp_stream, host).await
|
self.upgrade_to_tls(tcp_stream, host).await
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::time::{timeout, Duration};
|
use tokio::time::Duration;
|
||||||
use tokio_rustls::{TlsAcceptor, server::TlsStream};
|
use tokio_rustls::{TlsAcceptor, server::TlsStream};
|
||||||
use rustls::pki_types::CertificateDer;
|
use rustls::pki_types::CertificateDer;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user