work
This commit is contained in:
@@ -1,19 +1,14 @@
|
||||
use bytes::Bytes;
|
||||
|
||||
use crate::NetworkEvent;
|
||||
use crate::P2PSharedData;
|
||||
use crate::cryptographic_signature::{CryptographicSignature, formatPubKey, sign_message};
|
||||
use crate::get_socket_address;
|
||||
use crate::cryptographic_signature::CryptographicSignature;
|
||||
use crate::get_server_address;
|
||||
use crate::message_handling::EventType;
|
||||
use crate::messages_channels::MultipleSenders;
|
||||
use crate::messages_structure::construct_message;
|
||||
use crate::server_communication::generate_id;
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use std::collections::HashMap;
|
||||
use crossbeam_channel::Sender;
|
||||
use std::net::SocketAddr;
|
||||
use std::net::UdpSocket;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
|
||||
///
|
||||
/// sends the cryptographic signature to the server using a PUT request over the HTTP API.
|
||||
@@ -29,8 +24,13 @@ pub async fn register_with_the_server(
|
||||
let pubkey_bytes_minus = pubkey_bytes[1..].to_vec();
|
||||
let res = client.put(uri).body(pubkey_bytes_minus).send().await?;
|
||||
let res = res.error_for_status()?;
|
||||
println!("register ip adresses");
|
||||
Ok(())
|
||||
match res.error_for_status() {
|
||||
Ok(_) => {
|
||||
println!("register ip adresses");
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_addresses(input: &String) -> Vec<SocketAddr> {
|
||||
@@ -62,10 +62,11 @@ pub async fn perform_handshake(
|
||||
let senders = sd.senders_ref();
|
||||
|
||||
let id = generate_id();
|
||||
let server_addr_query = get_socket_address(username.clone(), ip.clone());
|
||||
let server_addr_query = get_server_address(username.clone(), ip.clone());
|
||||
match server_addr_query.await {
|
||||
Some(sockaddr_bytes) => {
|
||||
sd.set_servername(username);
|
||||
sd.set_serveraddress(sockaddr_bytes.to_string());
|
||||
// first: &SocketAddr
|
||||
let mut payload = Vec::new();
|
||||
payload.extend_from_slice(&0u32.to_be_bytes());
|
||||
@@ -115,8 +116,6 @@ pub async fn perform_handshake(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// Note this useful idiom: importing names from outer (for mod tests) scope.
|
||||
use super::*;
|
||||
|
||||
/*///
|
||||
/// does the procedure to register with the server
|
||||
|
||||
Reference in New Issue
Block a user