shitty message client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 regels
870 B

  1. // namespacing
  2. use crate::config::ClientConfig as Config;
  3. use crate::Result;
  4. use async_std::net::TcpStream;
  5. use futures_util::io::AsyncReadExt;
  6. use ilmp::encrypt;
  7. /// wraps the client
  8. pub async fn client(port: u16) -> Result<()> {
  9. let _config = Config::load()?;
  10. let stream = TcpStream::connect(format!("127.0.0.1:{}", &port)).await?;
  11. println!("connection established to: {}:{}", stream.peer_addr()?.ip(), port);
  12. let (mut read, mut write) = stream.split();
  13. let key = crate::initialize_connection(&mut read, &mut write).await?;
  14. let encryption = encrypt::SymmetricEncrypt::new(key);
  15. println!("successfully hardened connection");
  16. let message = ilmp::Message::new(
  17. "Isabelle".to_owned(),
  18. "oh god oh fuck this shit actually works".to_owned(),
  19. );
  20. ilmp::write(&mut write, message, &encryption).await?;
  21. loop {}
  22. }