This commit is contained in:
TIBERGHIEN corentin
2026-01-08 19:12:07 +01:00
parent dc1767abe4
commit cd2f87cb81
4 changed files with 34 additions and 21 deletions

View File

@@ -4,7 +4,7 @@ use crate::{
CryptographicSignature, get_peer_key, sign_message, verify_signature,
},
messages_channels::MultipleSenders,
messages_structure::HandshakeMessage,
messages_structure::{HandshakeMessage, constructMessage},
registration,
};
use std::sync::{Arc, Mutex};
@@ -141,6 +141,7 @@ pub fn parse_message(
received_name: String,
id: i32,
username: String,
crypto_pair: &CryptographicSignature
) -> Option<Vec<u8>> {
let id_bytes: [u8; 4] = received_message[0..ID]
.try_into()
@@ -161,7 +162,6 @@ pub fn parse_message(
.unwrap()
.block_on(get_peer_key(&received_name))
.expect("failed to retrieve public key");
let signature: [u8; SIGNATURE] = received_message
[LENGTH + msg_length..LENGTH + msg_length + SIGNATURE]
.try_into()
@@ -195,6 +195,7 @@ pub fn parse_message(
//
HELLO => {
let username_size = username.len();
let helloreply = constructMessage(msgtype, payload, &id, crypto_pair)
let hello_handshake =
HandshakeMessage::helloReply(id as u32, username_size as u16 + 4, username.clone());
//HandshakeMessage::display(&hello_handshake);