Moved sphinx packet encapsulation and poisson delay sampling to mix client
This commit is contained in:
Generated
+4
-2
@@ -1256,9 +1256,13 @@ dependencies = [
|
||||
name = "mix-client"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"addressing",
|
||||
"log",
|
||||
"rand 0.7.2",
|
||||
"rand_distr",
|
||||
"sphinx",
|
||||
"tokio 0.2.9",
|
||||
"topology",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1358,8 +1362,6 @@ dependencies = [
|
||||
"pem",
|
||||
"pemstore",
|
||||
"provider-client",
|
||||
"rand 0.7.2",
|
||||
"rand_distr",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -8,7 +8,14 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.8"
|
||||
rand = "0.7.2"
|
||||
rand_distr = "0.2.2"
|
||||
tokio = { version = "0.2", features = ["full"] }
|
||||
|
||||
## internal
|
||||
addressing = {path = "../../addressing"}
|
||||
topology = {path = "../../topology"}
|
||||
|
||||
## will be moved to proper dependencies once released
|
||||
sphinx = { git = "https://github.com/nymtech/sphinx", rev="1d8cefcb6a0cb8e87d00d89eb1ccf2839e92aa1f" }
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ use sphinx::SphinxPacket;
|
||||
use std::net::SocketAddr;
|
||||
use tokio::prelude::*;
|
||||
|
||||
pub mod packet;
|
||||
pub mod poisson;
|
||||
|
||||
pub struct MixClient {}
|
||||
|
||||
impl MixClient {
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::net::SocketAddr;
|
||||
use topology::NymTopology;
|
||||
|
||||
pub const LOOP_COVER_MESSAGE_PAYLOAD: &[u8] = b"The cake is a lie!";
|
||||
pub const LOOP_COVER_MESSAGE_AVERAGE_DELAY: f64 = 2.0;
|
||||
|
||||
pub fn loop_cover_message<T: NymTopology>(
|
||||
our_address: DestinationAddressBytes,
|
||||
@@ -13,21 +14,20 @@ pub fn loop_cover_message<T: NymTopology>(
|
||||
) -> (SocketAddr, SphinxPacket) {
|
||||
let destination = Destination::new(our_address, surb_id);
|
||||
|
||||
encapsulate_message(destination, LOOP_COVER_MESSAGE_PAYLOAD.to_vec(), topology)
|
||||
encapsulate_message(destination, LOOP_COVER_MESSAGE_PAYLOAD.to_vec(), topology, LOOP_COVER_MESSAGE_AVERAGE_DELAY)
|
||||
}
|
||||
|
||||
pub fn encapsulate_message<T: NymTopology>(
|
||||
recipient: Destination,
|
||||
message: Vec<u8>,
|
||||
topology: &T,
|
||||
average_delay: f64,
|
||||
) -> (SocketAddr, SphinxPacket) {
|
||||
let mut providers = topology.get_mix_provider_nodes();
|
||||
let provider = providers.pop().unwrap().into();
|
||||
|
||||
let route = topology.route_to(provider).unwrap();
|
||||
|
||||
// Set average packet delay to an arbitrary but at least not super-slow value for testing.
|
||||
let average_delay = 0.1;
|
||||
|
||||
let delays = sphinx::header::delays::generate(route.len(), average_delay);
|
||||
|
||||
// build the packet
|
||||
@@ -1,8 +1,5 @@
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
pub mod built_info;
|
||||
pub mod config;
|
||||
pub mod client;
|
||||
pub mod commands;
|
||||
pub mod sockets;
|
||||
pub mod utils;
|
||||
mod commands;
|
||||
pub mod config;
|
||||
mod sockets;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
|
||||
pub mod built_info;
|
||||
@@ -7,7 +5,6 @@ pub mod client;
|
||||
mod commands;
|
||||
pub mod config;
|
||||
mod sockets;
|
||||
pub mod utils;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod poisson;
|
||||
pub mod sphinx;
|
||||
Reference in New Issue
Block a user