use log::error;
mod handshake;
pub async fn establish_connection(
adr: &str,
key: &[u8],
port: u16,
) -> Option<tokio::net::TcpStream> {
let mut connection = match tokio::net::TcpStream::connect(&adr).await {
Ok(c) => c,
Err(e) => {
error!("Establishing-Connection: {}", e);
return None;
}
};
if !handshake::perform(&mut connection, key, port).await {
return None;
}
Some(connection)
}