From e708abcefa5ad1c34fb0d9471f2d576f41af16bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Mon, 25 Dec 2023 01:08:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:rocket:=20=E4=BF=AE=E8=AE=A2=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=9D=83=E8=BD=AC=E7=A7=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api.rs | 8 ++--- src/models/client.rs | 46 ++++++++++++++--------------- src/models/packet.rs | 66 +++++++++++++++++------------------------- src/models/render.rs | 4 +-- src/models/router.rs | 8 ++--- src/models/server.rs | 11 +++---- src/utils/gear.rs | 9 +++--- src/utils/generator.rs | 14 +++++++-- src/utils/parser.rs | 20 ++++++------- 9 files changed, 88 insertions(+), 98 deletions(-) diff --git a/src/api.rs b/src/api.rs index 66def28..2944418 100644 --- a/src/api.rs +++ b/src/api.rs @@ -33,12 +33,8 @@ pub async fn get(olps: &str, tfo: bool) -> Result { request("get", olps, None, None, tfo).await } -pub async fn post( - olps: &str, - data: Option, - tfo: bool, -) -> Result { - request("post", olps, data, None, tfo).await +pub async fn post(olps: &str, data: Value, tfo: bool) -> Result { + request("post", olps, Some(data), None, tfo).await } pub async fn put( diff --git a/src/models/client.rs b/src/models/client.rs index dd15f48..c833cac 100644 --- a/src/models/client.rs +++ b/src/models/client.rs @@ -21,10 +21,10 @@ pub struct Response { impl Response { pub fn new(header: String, content: Vec, olps: String, status_code: i32) -> Self { Self { - header: header, - content: content, - olps: olps, - status_code: status_code, + header, + content, + olps, + status_code, } } @@ -90,13 +90,13 @@ impl Request { let oblivion = Oblivion::new(&method, &olps)?; let plain_text = oblivion.plain_text(); Ok(Self { - method: method, - olps: olps, - path: path, - data: data, - file: file, - tfo: tfo, - plain_text: plain_text, + method, + olps, + path, + data, + file, + tfo, + plain_text, prepared: false, private_key: None, public_key: None, @@ -130,10 +130,7 @@ impl Request { self.send_header().await?; - let mut oke = OKE::new( - Some(&self.private_key.as_ref().unwrap()), - self.public_key.clone(), - )?; + let mut oke = OKE::new(Some(&self.private_key.as_ref().unwrap()), self.public_key)?; let mut oke = oke .from_stream_with_salt(self.tcp.as_mut().unwrap()) .await?; @@ -161,32 +158,33 @@ impl Request { let mut oed = if self.method == "POST" { let oed = if self.data.is_none() { let mut oed = OED::new(self.aes_key.clone()); - let oed = oed.from_dict(json!({})); + oed.from_dict(json!({}))?; oed } else { let mut oed = OED::new(self.aes_key.clone()); - let oed = oed.from_dict(self.data.clone().unwrap()); + oed.from_dict(self.data.clone().unwrap())?; oed }; oed } else if self.method == "PUT" { let mut oed = if self.data.is_none() { let mut oed = OED::new(self.aes_key.clone()); - let oed = oed.from_dict(json!({}))?; + oed.from_dict(json!({}))?; oed } else { let mut oed = OED::new(self.aes_key.clone()); - let oed = oed.from_dict(self.data.clone().unwrap())?; + oed.from_dict(self.data.clone().unwrap())?; oed }; + oed.to_stream(tcp, 5).await?; let mut oed = OED::new(self.aes_key.clone()); - let oed = oed.from_bytes(self.file.clone().unwrap()); + oed.from_bytes(self.file.clone().unwrap())?; oed } else { - Err(OblivionException::UnsupportedMethod(None)) - }?; + return Err(OblivionException::UnsupportedMethod(None)); + }; oed.to_stream(tcp, 5).await?; Ok(()) @@ -199,7 +197,7 @@ impl Request { Err(OblivionException::ErrorNotPrepared(None)) } else { let mut oed = OED::new(self.aes_key.clone()); - let mut oed = oed.from_stream(tcp, 5).await?; + oed.from_stream(tcp, 5).await?; let mut osc = OSC::from_stream(tcp).await?; @@ -214,6 +212,6 @@ impl Request { } pub fn is_prepared(&mut self) -> bool { - self.prepared.clone() + self.prepared } } diff --git a/src/models/packet.rs b/src/models/packet.rs index 3ba5d78..a3288d9 100644 --- a/src/models/packet.rs +++ b/src/models/packet.rs @@ -72,7 +72,7 @@ impl OSC { } pub fn get_status_code(&mut self) -> i32 { - self.status_code.clone() + self.status_code } } @@ -102,11 +102,11 @@ impl<'a> OKE<'a> { fn clone(&mut self) -> Self { Self { - length: self.length.clone(), + length: self.length, public_key: self.public_key, private_key: self.private_key, salt: self.salt.clone(), - remote_public_key: self.remote_public_key.clone(), + remote_public_key: self.remote_public_key, shared_aes_key: self.shared_aes_key.clone(), } } @@ -122,7 +122,8 @@ impl<'a> OKE<'a> { pub async fn from_stream(&mut self, stream: &mut Socket) -> Result, OblivionException> { let remote_public_key_length = stream.recv_len().await?; let remote_public_key_bytes = stream.recv(remote_public_key_length).await; - self.remote_public_key = Some(PublicKey::from_sec1_bytes(&remote_public_key_bytes).unwrap()); + self.remote_public_key = + Some(PublicKey::from_sec1_bytes(&remote_public_key_bytes).unwrap()); self.shared_aes_key = Some(generate_shared_key( self.private_key.as_ref().unwrap(), self.remote_public_key.unwrap(), @@ -137,7 +138,8 @@ impl<'a> OKE<'a> { ) -> Result, OblivionException> { let remote_public_key_length = stream.recv_len().await?; let remote_public_key_bytes = stream.recv(remote_public_key_length).await; - self.remote_public_key = Some(PublicKey::from_sec1_bytes(&remote_public_key_bytes).unwrap()); + self.remote_public_key = + Some(PublicKey::from_sec1_bytes(&remote_public_key_bytes).unwrap()); let salt_length = stream.recv_len().await?; self.salt = Some(stream.recv(salt_length).await); self.shared_aes_key = Some(generate_shared_key( @@ -165,7 +167,7 @@ impl<'a> OKE<'a> { } pub fn plain_salt(&mut self) -> Vec { - let salt_bytes = self.salt.clone().unwrap(); + let salt_bytes = self.salt.as_ref().unwrap(); let mut plain_salt_bytes = length(&salt_bytes).unwrap(); plain_salt_bytes.extend(salt_bytes); plain_salt_bytes @@ -177,7 +179,6 @@ impl<'a> OKE<'a> { } pub struct OED { - length: Option, aes_key: Option>, data: Option>, encrypted_data: Option>, @@ -189,7 +190,6 @@ pub struct OED { impl OED { pub fn new(aes_key: Option>) -> Self { Self { - length: None, aes_key: aes_key, data: None, encrypted_data: None, @@ -199,18 +199,6 @@ impl OED { } } - fn clone(&mut self) -> Self { - Self { - length: self.length.clone(), - aes_key: self.aes_key.clone(), - data: self.data.clone(), - encrypted_data: self.encrypted_data.clone(), - tag: self.tag.clone(), - nonce: self.nonce.clone(), - chunk_size: self.chunk_size.clone(), - } - } - fn serialize_bytes(&self, data: &[u8], size: Option) -> Vec> { let size = if size.is_none() { let size: usize = 1024; @@ -245,39 +233,39 @@ impl OED { serialized_bytes } - pub fn from_json_or_string(&mut self, json_or_str: String) -> Result { + pub fn from_json_or_string(&mut self, json_or_str: String) -> Result<&mut Self, ()> { let (encrypted_data, tag, nonce) = - encrypt_message(json_or_str, &self.aes_key.clone().unwrap()); + encrypt_message(json_or_str, &self.aes_key.as_ref().unwrap()); (self.encrypted_data, self.tag, self.nonce) = (Some(encrypted_data), Some(tag), Some(nonce)); - Ok(self.clone()) + Ok(self) } - pub fn from_dict(&mut self, dict: Value) -> Result { + pub fn from_dict(&mut self, dict: Value) -> Result<&mut Self, OblivionException> { let (encrypted_data, tag, nonce) = - encrypt_message(dict.to_string(), &self.aes_key.clone().unwrap()); + encrypt_message(dict.to_string(), &self.aes_key.as_ref().unwrap()); (self.encrypted_data, self.tag, self.nonce) = (Some(encrypted_data), Some(tag), Some(nonce)); - Ok(self.clone()) + Ok(self) } - pub fn from_encrypted_data(&mut self, data: Vec) -> Result { + pub fn from_encrypted_data(&mut self, data: Vec) -> Result<&mut Self, ()> { self.encrypted_data = Some(data); - Ok(self.clone()) + Ok(self) } - pub fn from_bytes(&mut self, data: Vec) -> Result { - let (encrypted_data, tag, nonce) = encrypt_bytes(data, &self.aes_key.clone().unwrap()); + pub fn from_bytes(&mut self, data: Vec) -> Result<&mut Self, OblivionException> { + let (encrypted_data, tag, nonce) = encrypt_bytes(data, &self.aes_key.as_ref().unwrap()); (self.encrypted_data, self.tag, self.nonce) = (Some(encrypted_data), Some(tag), Some(nonce)); - Ok(self.clone()) + Ok(self) } pub async fn from_stream( &mut self, stream: &mut Socket, total_attemps: i32, - ) -> Result { + ) -> Result<&mut Self, OblivionException> { let mut attemp = 0; let mut ack = false; @@ -297,7 +285,7 @@ impl OED { loop { let prefix = stream.recv_len().await?; if prefix == 0 { - self.encrypted_data = Some(encrypted_data.clone()); + self.encrypted_data = Some(encrypted_data); break; } @@ -338,7 +326,7 @@ impl OED { )))); } - Ok(self.clone()) + Ok(self) } pub async fn to_stream( @@ -357,7 +345,7 @@ impl OED { self.chunk_size = 0; for bytes in self - .serialize_bytes(&self.encrypted_data.clone().unwrap(), None) + .serialize_bytes(&self.encrypted_data.as_ref().unwrap(), None) .iter() { stream.send(&bytes).await; @@ -382,11 +370,11 @@ impl OED { } pub fn plain_data(&mut self) -> Vec { - let nonce_bytes = self.nonce.clone().unwrap(); - let tag_bytes = self.tag.clone().unwrap(); + let nonce_bytes = self.nonce.as_ref().unwrap(); + let tag_bytes = self.tag.as_ref().unwrap(); - let mut plain_bytes = length(&nonce_bytes).unwrap(); - plain_bytes.extend(length(&tag_bytes).unwrap()); + let mut plain_bytes = length(nonce_bytes).unwrap(); + plain_bytes.extend(length(tag_bytes).unwrap()); plain_bytes.extend(nonce_bytes); plain_bytes.extend(tag_bytes); diff --git a/src/models/render.rs b/src/models/render.rs index 11ef269..b700d40 100644 --- a/src/models/render.rs +++ b/src/models/render.rs @@ -29,7 +29,7 @@ impl TextResponse { } pub fn get_status_code(&mut self) -> i32 { - self.status_code.clone() + self.status_code } } @@ -51,7 +51,7 @@ impl JsonResponse { } pub fn get_status_code(&mut self) -> i32 { - self.status_code.clone() + self.status_code } } diff --git a/src/models/router.rs b/src/models/router.rs index f80aaef..4be7db7 100644 --- a/src/models/router.rs +++ b/src/models/router.rs @@ -75,15 +75,15 @@ impl Router { &mut self, path: RoutePath, handler: fn(OblivionRequest) -> BoxFuture<'static, BaseResponse>, - ) -> Self { + ) -> &mut Self { self.routes - .insert(path.to_owned(), Route { handler: handler }); - self.to_owned() + .insert(path.clone(), Route { handler: handler }); + self } pub fn regist(&mut self, path: RoutePath, route: Route) { let route = route; - self.routes.insert(path.to_owned(), route); + self.routes.insert(path.clone(), route); } pub fn get_handler(&self, path: String) -> Route { diff --git a/src/models/server.rs b/src/models/server.rs index 2d25385..cd60245 100644 --- a/src/models/server.rs +++ b/src/models/server.rs @@ -50,16 +50,16 @@ impl ServerConnection { if request.get_method() == "POST" { let mut oed = OED::new(self.aes_key.clone()); - let mut oed = oed.from_stream(stream, 5).await?; + oed.from_stream(stream, 5).await?; request.set_post(from_slice(&oed.get_data()).unwrap()); } else if request.get_method() == "GET" { } else if request.get_method() == "PUT" { let mut oed = OED::new(self.aes_key.clone()); - let mut oed = oed.from_stream(stream, 5).await?; + oed.from_stream(stream, 5).await?; request.set_post(from_slice(&oed.get_data()).unwrap()); let mut oed = OED::new(self.aes_key.clone()); - let mut oed = oed.from_stream(stream, 5).await?; + oed.from_stream(stream, 5).await?; request.set_put(oed.get_data()); } else { return Err(OblivionException::UnsupportedMethod(Some( @@ -87,7 +87,8 @@ pub async fn response( let handler = route.get_handler(); let mut callback = handler(request).await; - let mut oed = OED::new(Some(aes_key)).from_bytes(callback.as_bytes()?)?; + let mut oed = OED::new(Some(aes_key)); + oed.from_bytes(callback.as_bytes()?)?; oed.to_stream(stream, 5).await?; let mut osc = OSC::from_int(callback.get_status_code()?)?; @@ -120,7 +121,7 @@ async fn _handle( Err(_) => return Err(OblivionException::ServerError(None, 501)), }; - Ok((request.to_owned(), status_code)) + Ok((request.clone(), status_code)) } pub async fn handle(router: Router, stream: TcpStream, peer: SocketAddr) { diff --git a/src/utils/gear.rs b/src/utils/gear.rs index 8e253d4..582ca8c 100644 --- a/src/utils/gear.rs +++ b/src/utils/gear.rs @@ -1,4 +1,4 @@ -use crate::exceptions; +use crate::exceptions::OblivionException; use ring::{ aead::{Nonce, NonceSequence}, error::Unspecified, @@ -13,7 +13,6 @@ pub struct RandNonceSequence { } impl NonceSequence for RandNonceSequence { - // called once for each seal operation fn advance(&mut self) -> Result { Nonce::try_assume_unique_for_key(&self.nonce) } @@ -38,7 +37,7 @@ impl Socket { self.tcp.set_ttl(ttl).unwrap() } - pub async fn recv_len(&mut self) -> Result { + pub async fn recv_len(&mut self) -> Result { let mut len_bytes: Vec = vec![0; 4]; let _ = self.tcp.read_exact(&mut len_bytes).await.unwrap(); @@ -51,7 +50,7 @@ impl Socket { Ok(len) } - pub async fn recv_int(&mut self, len: usize) -> Result { + pub async fn recv_int(&mut self, len: usize) -> Result { let mut len_bytes: Vec = vec![0; len]; let _ = self.tcp.read_exact(&mut len_bytes).await.unwrap(); @@ -69,7 +68,7 @@ impl Socket { recv_bytes } - pub async fn recv_str(&mut self, len: usize) -> Result { + pub async fn recv_str(&mut self, len: usize) -> Result { let mut recv_bytes: Vec = vec![0; len]; let _ = self.tcp.read_exact(&mut recv_bytes).await.unwrap(); diff --git a/src/utils/generator.rs b/src/utils/generator.rs index 4eb3d7b..8577d7d 100644 --- a/src/utils/generator.rs +++ b/src/utils/generator.rs @@ -7,8 +7,16 @@ use ring::aead::AES_128_GCM; use ring::rand::{SecureRandom, SystemRandom}; use scrypt::{scrypt, Params}; +/// 创建 ECC 密钥 +/// +/// `generate_key_pair`将创建一个`ECC`密钥。 +/// +/// ```rust +/// use oblivion::utils::generator::generate_key_pair; +/// +/// let (private_key, public_key) = generate_key_pair(); +/// ``` pub fn generate_key_pair() -> (EphemeralSecret, PublicKey) { - // 生成 ECC 密钥对 let private_key = EphemeralSecret::random(&mut OsRng); let pk_bytes = EncodedPoint::from(private_key.public_key()); let public_key = @@ -16,12 +24,12 @@ pub fn generate_key_pair() -> (EphemeralSecret, PublicKey) { (private_key, public_key) } +/// 创建 ECDH 共享密钥 pub fn generate_shared_key( private_key: &EphemeralSecret, public_key: PublicKey, salt: &[u8], ) -> Vec { - // 生成共享密钥对 let shared_key = private_key.diffie_hellman(&public_key); let mut aes_key = [0u8; 16]; let _ = scrypt( @@ -33,8 +41,8 @@ pub fn generate_shared_key( aes_key.to_vec() } +/// 生成随机的盐值 pub fn generate_random_salt() -> Vec { - // 生成随机的盐值 let rand = SystemRandom::new(); let mut key_bytes = vec![0; AES_128_GCM.key_len()]; match rand.fill(&mut key_bytes) { diff --git a/src/utils/parser.rs b/src/utils/parser.rs index 312c978..707fecc 100644 --- a/src/utils/parser.rs +++ b/src/utils/parser.rs @@ -212,16 +212,16 @@ impl OblivionRequest { pub fn clone(&mut self) -> Self { Self { - method: self.method.clone(), - olps: self.olps.clone(), - protocol: self.protocol.clone(), - version: self.version.clone(), - data: self.data.clone(), - plain_text: self.plain_text.clone(), - post: self.post.clone(), - put: self.put.clone(), - remote_addr: self.remote_addr.clone(), - remote_port: self.remote_port.clone(), + method: self.method.to_owned(), + olps: self.olps.to_owned(), + protocol: self.protocol.to_owned(), + version: self.version.to_owned(), + data: self.data.to_owned(), + plain_text: self.plain_text.to_owned(), + post: self.post.to_owned(), + put: self.put.to_owned(), + remote_addr: self.remote_addr.to_owned(), + remote_port: self.remote_port.to_owned(), } } From 524f701a0283a9c06e22817d81532bbec317ab5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Mon, 25 Dec 2023 22:07:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:fire:=20=E6=B8=85=E7=90=86=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84clone=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/parser.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/utils/parser.rs b/src/utils/parser.rs index 707fecc..1d9b3b7 100644 --- a/src/utils/parser.rs +++ b/src/utils/parser.rs @@ -210,21 +210,6 @@ impl OblivionRequest { } } - pub fn clone(&mut self) -> Self { - Self { - method: self.method.to_owned(), - olps: self.olps.to_owned(), - protocol: self.protocol.to_owned(), - version: self.version.to_owned(), - data: self.data.to_owned(), - plain_text: self.plain_text.to_owned(), - post: self.post.to_owned(), - put: self.put.to_owned(), - remote_addr: self.remote_addr.to_owned(), - remote_port: self.remote_port.to_owned(), - } - } - pub fn set_remote_peer(&mut self, peer: SocketAddr) { self.remote_addr = Some(peer.ip().to_string()); self.remote_port = Some(peer.port().into()) From 412ffaf6bccb5bbc152a6eaaa8f63ffba9163dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Mon, 25 Dec 2023 22:18:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:recycle:=20=E4=BF=AE=E8=AE=A2OKE=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=89=80=E6=9C=89=E6=9D=83=E8=BD=AC=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/client.rs | 3 +-- src/models/packet.rs | 38 ++++++++++++++------------------------ src/models/router.rs | 3 +-- src/models/server.rs | 2 +- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/models/client.rs b/src/models/client.rs index c833cac..76fcf41 100644 --- a/src/models/client.rs +++ b/src/models/client.rs @@ -131,8 +131,7 @@ impl Request { self.send_header().await?; let mut oke = OKE::new(Some(&self.private_key.as_ref().unwrap()), self.public_key)?; - let mut oke = oke - .from_stream_with_salt(self.tcp.as_mut().unwrap()) + oke.from_stream_with_salt(self.tcp.as_mut().unwrap()) .await?; self.aes_key = Some(oke.get_aes_key()); oke.to_stream(self.tcp.as_mut().unwrap()).await; diff --git a/src/models/packet.rs b/src/models/packet.rs index a3288d9..d66ef4e 100644 --- a/src/models/packet.rs +++ b/src/models/packet.rs @@ -77,7 +77,6 @@ impl OSC { } pub struct OKE<'a> { - length: Option, public_key: Option, private_key: Option<&'a EphemeralSecret>, salt: Option>, @@ -91,35 +90,26 @@ impl<'a> OKE<'a> { public_key: Option, ) -> Result { Ok(Self { - length: None, - public_key: public_key, - private_key: private_key, + public_key, + private_key, salt: Some(generate_random_salt()), remote_public_key: None, shared_aes_key: None, }) } - fn clone(&mut self) -> Self { - Self { - length: self.length, - public_key: self.public_key, - private_key: self.private_key, - salt: self.salt.clone(), - remote_public_key: self.remote_public_key, - shared_aes_key: self.shared_aes_key.clone(), - } - } - pub fn from_public_key_bytes( &mut self, public_key_bytes: &[u8], - ) -> Result { + ) -> Result<&mut Self, OblivionException> { self.public_key = Some(PublicKey::from_sec1_bytes(public_key_bytes).unwrap()); - Ok(self.clone()) + Ok(self) } - pub async fn from_stream(&mut self, stream: &mut Socket) -> Result, OblivionException> { + pub async fn from_stream( + &mut self, + stream: &mut Socket, + ) -> Result<&mut Self, OblivionException> { let remote_public_key_length = stream.recv_len().await?; let remote_public_key_bytes = stream.recv(remote_public_key_length).await; self.remote_public_key = @@ -129,13 +119,13 @@ impl<'a> OKE<'a> { self.remote_public_key.unwrap(), &self.salt.as_mut().unwrap(), )); - Ok(self.clone()) + Ok(self) } pub async fn from_stream_with_salt( &mut self, stream: &mut Socket, - ) -> Result, OblivionException> { + ) -> Result<&mut Self, OblivionException> { let remote_public_key_length = stream.recv_len().await?; let remote_public_key_bytes = stream.recv(remote_public_key_length).await; self.remote_public_key = @@ -147,7 +137,7 @@ impl<'a> OKE<'a> { self.remote_public_key.unwrap(), &self.salt.as_mut().unwrap(), )); - Ok(self.clone()) + Ok(self) } pub async fn to_stream(&mut self, stream: &mut Socket) { @@ -300,9 +290,9 @@ impl OED { match decrypt_bytes( self.encrypted_data.clone().unwrap(), - &self.tag.as_ref().unwrap(), - &self.aes_key.as_ref().unwrap(), - &self.nonce.as_ref().unwrap(), + self.tag.as_ref().unwrap(), + self.aes_key.as_ref().unwrap(), + self.nonce.as_ref().unwrap(), ) { Ok(data) => { self.data = Some(data); diff --git a/src/models/router.rs b/src/models/router.rs index 4be7db7..38e7669 100644 --- a/src/models/router.rs +++ b/src/models/router.rs @@ -76,8 +76,7 @@ impl Router { path: RoutePath, handler: fn(OblivionRequest) -> BoxFuture<'static, BaseResponse>, ) -> &mut Self { - self.routes - .insert(path.clone(), Route { handler: handler }); + self.routes.insert(path.clone(), Route { handler: handler }); self } diff --git a/src/models/server.rs b/src/models/server.rs index cd60245..ad96e23 100644 --- a/src/models/server.rs +++ b/src/models/server.rs @@ -45,7 +45,7 @@ impl ServerConnection { let mut oke = OKE::new(Some(&self.private_key), Some(self.public_key))?; oke.to_stream_with_salt(stream).await; - let mut oke = oke.from_stream(stream).await?; + oke.from_stream(stream).await?; self.aes_key = Some(oke.get_aes_key()); if request.get_method() == "POST" {