diff --git a/Cargo.lock b/Cargo.lock index 5b16669dec..f8a87bb65c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1068,6 +1068,7 @@ name = "nym-client" version = "0.1.0" dependencies = [ "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "built 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 64cbe02ed7..b71824ee95 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -1,21 +1,22 @@ +use curve25519_dalek::digest::Digest; +use nym_client::utils::addressing; +use std::convert::TryInto; use std::error::Error; -use std::net::{Ipv4Addr, SocketAddrV4}; +use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use tokio::prelude::*; #[derive(Debug)] pub struct MixPeer { - connection: SocketAddrV4, + connection: SocketAddr, } impl MixPeer { // note that very soon `next_hop_address` will be changed to `next_hop_metadata` pub fn new(next_hop_address: [u8; 32]) -> MixPeer { - let b = next_hop_address; - let host = Ipv4Addr::new(b[0], b[1], b[2], b[3]); - let port: u16 = u16::from_be_bytes([b[4], b[5]]); - let socket_address = SocketAddrV4::new(host, port); + let next_hop_socket_address = + addressing::socket_address_from_encoded_bytes(next_hop_address); MixPeer { - connection: socket_address, + connection: next_hop_socket_address, } } diff --git a/src/node/mod.rs b/src/node/mod.rs index 9284d346e6..eec733dfbb 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -10,6 +10,7 @@ use std::time::Duration; use tokio::prelude::*; use tokio::runtime::Runtime; +use crate::mix_peer; use crate::mix_peer::MixPeer; use crate::node::metrics::MetricsReporter; use futures::SinkExt; @@ -36,6 +37,7 @@ impl Config { #[derive(Debug)] pub enum MixProcessingError { + InvalidPeerAddressError, SphinxRecoveryError, ReceivedFinalHopError, } @@ -98,7 +100,7 @@ impl ProcessingData { } } -struct PacketProcessor {} +struct PacketProcessor; impl PacketProcessor { pub async fn process_sphinx_data_packet(