ipv6_addressing

This commit is contained in:
Jedrzej Stuczynski
2020-01-06 14:43:19 +00:00
parent c3ce96afe9
commit d5a0e7d355
3 changed files with 12 additions and 8 deletions
Generated
+1
View File
@@ -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)",
+8 -7
View File
@@ -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,
}
}
+3 -1
View File
@@ -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(