refactor
This commit is contained in:
parent
59b836b501
commit
1258b7e38f
2 changed files with 2 additions and 9 deletions
|
|
@ -75,9 +75,7 @@ impl EncryptedStream {
|
||||||
pub fn read_packet(&mut self) -> Result<Vec<u8>, EncryptionError> {
|
pub fn read_packet(&mut self) -> Result<Vec<u8>, EncryptionError> {
|
||||||
// the first bytes should be the nonce
|
// the first bytes should be the nonce
|
||||||
let mut nonce_bytes = [0u8; 12];
|
let mut nonce_bytes = [0u8; 12];
|
||||||
if let Err(err) = self.socket.read(&mut nonce_bytes) {
|
self.socket.read(&mut nonce_bytes).map_err(|err| IO(err))?;
|
||||||
return Err(IO(err));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.reset(nonce_bytes);
|
self.reset(nonce_bytes);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use hermes::EncryptedStream;
|
use hermes::EncryptedStream;
|
||||||
use std::env::args;
|
use std::env::args;
|
||||||
use std::io::Write;
|
use std::net::TcpListener;
|
||||||
use std::net::{Shutdown, TcpListener};
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
@ -27,10 +26,6 @@ fn main() {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("successfully wrote data");
|
println!("successfully wrote data");
|
||||||
|
|
||||||
encrypted.flush().unwrap();
|
|
||||||
encrypted.shutdown(Shutdown::Both).unwrap();
|
|
||||||
println!("closed connection");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"c" => {
|
"c" => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue