cttps 0.1.2

Crypto Transfer Protocol Secure (CTTPS) - A high-performance secure transport protocol using X25519 and AES-256-GCM.
use cttps::CttpsStream;
use tokio::net::TcpStream;
use tokio::io::{self, AsyncBufReadExt, BufReader};
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let addr = "127.0.0.1:8080";
    let stream = TcpStream::connect(addr).await?;
    println!("Connected to {}", addr);

    let mut cttps_stream = CttpsStream::connect(stream).await?;
    println!("Handshake successful. Encrypted tunnel established.");

    println!("Type something to send (press Enter):");
    let mut stdin_reader = BufReader::new(io::stdin());
    let mut line = String::new();

    while stdin_reader.read_line(&mut line).await? > 0 {
        let msg = line.trim();
        if msg.is_empty() {
            line.clear();
            continue;
        }

        cttps_stream.write_packet(msg.as_bytes()).await?;
        
        let resp = cttps_stream.read_packet().await?;
        println!("Server: {}", String::from_utf8_lossy(&resp));
        
        line.clear();
    }

    Ok(())
}