From f4a62fd64cde02f233dbe9320ca22bc0db73a2f5 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 28 Nov 2019 19:33:20 +0000 Subject: [PATCH 01/66] Initial commit --- .gitignore | 3 + Cargo.lock | 767 ++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 11 + src/main.rs | 47 +++ src/mix_peer.rs | 24 ++ 5 files changed, 852 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs create mode 100644 src/mix_peer.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..e3b9e18094 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +/target +**/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000..509cf8b8e7 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,767 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aes-ctr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aes-soft" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aesni" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "arc-swap" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "arrayref" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "blake2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "block-cipher-trait" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bytes" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "c2-chacha" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cc" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "clear_on_drop" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ctr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "curve25519-dalek" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "getrandom" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hermit-abi" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hkdf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "keystream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lioness" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memchr" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "mio" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mio-named-pipes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mio-uds" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miow" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "net2" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num_cpus" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nym-mixnode" +version = "0.1.0" +dependencies = [ + "sphinx 0.1.0", + "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "pin-project-lite" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ppv-lite86" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro2" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_distr" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "sha2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "signal-hook-registry" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "socket2" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sphinx" +version = "0.1.0" +dependencies = [ + "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hkdf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lioness 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "stream-cipher" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "subtle" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "syn" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-macros 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-macros" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "typenum" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasi" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[metadata] +"checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" +"checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +"checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +"checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" +"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +"checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +"checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c85319f157e4e26c703678e68e26ab71a46c0199286fa670b21cc9fec13d895" +"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" +"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" +"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +"checksum chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +"checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +"checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" +"checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" +"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" +"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" +"checksum hkdf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" +"checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum lioness 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +"checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" +"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +"checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" +"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" +"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +"checksum pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f0af6cbca0e6e3ce8692ee19fb8d734b641899e07b68eb73e9bbbd32f1703991" +"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +"checksum rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96977acbdd3a6576fb1d27391900035bf3863d4a16422973a409b488cf29ffb2" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" +"checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" +"checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +"checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" +"checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" +"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" +"checksum tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "beeef686ef92a222de07e089f455d9f8478bbba9651718f9e4b276babe829082" +"checksum tokio-macros 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5795a71419535c6dcecc9b6ca95bdd3c2d6142f7e8343d7beb9923f129aa87e" +"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000..6d6ff75829 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "nym-mixnode" +version = "0.1.0" +authors = ["Dave Hrycyszyn "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +sphinx = { path = "../sphinx" } +tokio = { version = "0.2", features = ["full"] } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000000..a2341148b6 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,47 @@ +use tokio::net::TcpListener; +use tokio::prelude::*; +use crate::mix_peer::MixPeer; + +mod mix_peer; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let my_address = "127.0.0.1:8080"; + let mut listener = TcpListener::bind(my_address).await?; + + println!("Starting echo server on address {:?}", my_address); + println!("Waiting for input..."); + + loop { + let (mut inbound, _) = listener.accept().await?; + + tokio::spawn(async move { + let mut buf = [0; 1024]; + + loop { + let _ = match inbound.read(&mut buf).await { + Ok(length) if length == 0 => + { + println!("Remote connection closed."); + return + } + Ok(length) => { +// println!("Received: {:?}", String::from_utf8(buf[0..length].to_vec()).unwrap()); + let next_mix = MixPeer::new(); + match next_mix.send(buf).await { + Ok(()) => length, + Err(e) => { + println!("failed to write bytes to next mix peer. err = {:?}", e); + return; + } + } + } + Err(e) => { + println!("failed to read from socket; err = {:?}", e); + return; + } + }; + } + }); + } +} diff --git a/src/mix_peer.rs b/src/mix_peer.rs new file mode 100644 index 0000000000..900272ed86 --- /dev/null +++ b/src/mix_peer.rs @@ -0,0 +1,24 @@ +use tokio::net::TcpStream; +use tokio::prelude::*; +use std::error::Error; + + +pub struct MixPeer { + connection: &'static str, +} + +impl MixPeer { + pub fn new() -> MixPeer { + let next_hop_address = "127.0.0.1:8081"; + let node = MixPeer { + connection: next_hop_address, + }; + node + } + + pub async fn send(&self, buf: [u8; 1024]) -> Result<(), Box>{ + let mut stream = TcpStream::connect(self.connection).await?; + stream.write_all(&buf).await?; + Ok(()) + } +} \ No newline at end of file From d7ed6b5a13383fd212c943dbd74c7fa913d9232f Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 29 Nov 2019 12:26:12 +0000 Subject: [PATCH 02/66] WIP --- src/main.rs | 12 ++++++++---- src/mix_peer.rs | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index a2341148b6..2904cf32bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use tokio::net::TcpListener; use tokio::prelude::*; use crate::mix_peer::MixPeer; +use sphinx::SphinxPacket; mod mix_peer; @@ -9,7 +10,7 @@ async fn main() -> Result<(), Box> { let my_address = "127.0.0.1:8080"; let mut listener = TcpListener::bind(my_address).await?; - println!("Starting echo server on address {:?}", my_address); + println!("Starting Nym mixnode on address {:?}", my_address); println!("Waiting for input..."); loop { @@ -26,12 +27,15 @@ async fn main() -> Result<(), Box> { return } Ok(length) => { -// println!("Received: {:?}", String::from_utf8(buf[0..length].to_vec()).unwrap()); + let packet = SphinxPacket::from_bytes(buf.to_vec()).unwrap(); + let (next_packet, _) = packet.process(Default::default()); + let next_mix = MixPeer::new(); - match next_mix.send(buf).await { + + match next_mix.send(next_packet.to_bytes()).await { Ok(()) => length, Err(e) => { - println!("failed to write bytes to next mix peer. err = {:?}", e); + println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); return; } } diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 900272ed86..bdc5d2d50b 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -16,9 +16,9 @@ impl MixPeer { node } - pub async fn send(&self, buf: [u8; 1024]) -> Result<(), Box>{ + pub async fn send(&self, bytes: Vec) -> Result<(), Box>{ let mut stream = TcpStream::connect(self.connection).await?; - stream.write_all(&buf).await?; + stream.write_all(&bytes).await?; Ok(()) } } \ No newline at end of file From 2c0a4b11db0d93d709c9c0a48e53b175e8885a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Fri, 29 Nov 2019 12:32:14 +0000 Subject: [PATCH 03/66] Added README - git was asking so nicely to do it : ) --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..0329495058 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# nym-mixnode +A Rust mixnode implementation From e8472e07f9255607934c95095b677428a6d9ebb2 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 29 Nov 2019 15:54:34 +0000 Subject: [PATCH 04/66] Updating to work with constant sized packets --- Cargo.lock | 1 + src/main.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 509cf8b8e7..39fc7cfe20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -558,6 +558,7 @@ dependencies = [ "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "hkdf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/main.rs b/src/main.rs index 2904cf32bf..9ac9552423 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use tokio::net::TcpListener; use tokio::prelude::*; use crate::mix_peer::MixPeer; -use sphinx::SphinxPacket; +use sphinx::{SphinxPacket, ProcessedPacket}; mod mix_peer; @@ -17,7 +17,7 @@ async fn main() -> Result<(), Box> { let (mut inbound, _) = listener.accept().await?; tokio::spawn(async move { - let mut buf = [0; 1024]; + let mut buf = [0; 1024 + 333]; loop { let _ = match inbound.read(&mut buf).await { @@ -28,7 +28,10 @@ async fn main() -> Result<(), Box> { } Ok(length) => { let packet = SphinxPacket::from_bytes(buf.to_vec()).unwrap(); - let (next_packet, _) = packet.process(Default::default()); + let next_packet = match packet.process(Default::default()){ + ProcessedPacket::ProcessedPacketForwardHop(packet,_,_) => Some(packet) , + _ => None, + }.unwrap(); let next_mix = MixPeer::new(); From 94784608937114c668b9d915e5ad9dc622432216 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Thu, 5 Dec 2019 17:08:46 +0000 Subject: [PATCH 05/66] Waiting 2s before forwarding packet --- Cargo.lock | 1 + Cargo.toml | 3 +- src/main.rs | 276 ++++++++++++++++++++++++++++++++++++++++-------- src/mix_peer.rs | 21 ++-- 4 files changed, 245 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39fc7cfe20..f985b23e65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,6 +396,7 @@ dependencies = [ name = "nym-mixnode" version = "0.1.0" dependencies = [ + "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 6d6ff75829..a59e50b6fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,5 @@ edition = "2018" [dependencies] sphinx = { path = "../sphinx" } -tokio = { version = "0.2", features = ["full"] } \ No newline at end of file +tokio = { version = "0.2", features = ["full"] } +curve25519-dalek = "1.2.3" diff --git a/src/main.rs b/src/main.rs index 9ac9552423..5c79d5286d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,54 +1,238 @@ -use tokio::net::TcpListener; +use sphinx::{ProcessedPacket, SphinxPacket}; use tokio::prelude::*; +use tokio::runtime::Runtime; +use curve25519_dalek::scalar::Scalar; +use std::time::{Duration, Instant}; use crate::mix_peer::MixPeer; -use sphinx::{SphinxPacket, ProcessedPacket}; +use crate::MixProcessingError::SphinxRecoveryError; +use sphinx::header::delays::{Delay as SphinxDelay}; +use tokio::time::Delay as TokioDelay; +use std::marker::PhantomData; mod mix_peer; -#[tokio::main] -async fn main() -> Result<(), Box> { - let my_address = "127.0.0.1:8080"; - let mut listener = TcpListener::bind(my_address).await?; +// TODO: this will probably need to be moved elsewhere I imagine +#[derive(Debug)] +pub enum MixProcessingError { + SphinxRecoveryError, + ReceivedFinalHopError, +} - println!("Starting Nym mixnode on address {:?}", my_address); - println!("Waiting for input..."); - - loop { - let (mut inbound, _) = listener.accept().await?; - - tokio::spawn(async move { - let mut buf = [0; 1024 + 333]; - - loop { - let _ = match inbound.read(&mut buf).await { - Ok(length) if length == 0 => - { - println!("Remote connection closed."); - return - } - Ok(length) => { - let packet = SphinxPacket::from_bytes(buf.to_vec()).unwrap(); - let next_packet = match packet.process(Default::default()){ - ProcessedPacket::ProcessedPacketForwardHop(packet,_,_) => Some(packet) , - _ => None, - }.unwrap(); - - let next_mix = MixPeer::new(); - - match next_mix.send(next_packet.to_bytes()).await { - Ok(()) => length, - Err(e) => { - println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); - return; - } - } - } - Err(e) => { - println!("failed to read from socket; err = {:?}", e); - return; - } - }; - } - }); +impl From for MixProcessingError { + // for time being just have a single error instance for all possible results of sphinx::ProcessingError + fn from(_: sphinx::ProcessingError) -> Self { + SphinxRecoveryError } } + +struct ForwardingData<'a> { + packet: SphinxPacket, + delay: SphinxDelay, + recipient: MixPeer<'a> +} + +// TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data +impl<'a> ForwardingData<'a> { + fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer<'a>) -> Self { + ForwardingData { + packet, + delay, + recipient + } + } +} + +// just because lifetimes are annoying +type DUMMY_TEMP_TYPE = u8; + +struct PacketProcessor<'a, T> { + phantom: PhantomData<&'a T>, +} + +impl<'a, T> PacketProcessor<'a, T> { + fn new() -> Self { + PacketProcessor{ + phantom: PhantomData + } + } + + async fn wait_and_forward(&self, fwd_data: ForwardingData<'a>) { + let delay_duration = Duration::from_nanos(fwd_data.delay.get_value()); + // for now just hardcode some value + let delay_duration = Duration::from_secs(2); + println!("gonna wait 2 seconds!"); + tokio::time::delay_for(delay_duration).await; + println!("waited 2 seconds!"); + + +// let task = TokioDelay::new + + match fwd_data.recipient.send(fwd_data.packet.to_bytes()).await { + Ok(()) => (), + Err(e) => { + println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); + } + } + } + + pub fn process_sphinx_data_packet(&self, packet_data: &[u8], secret_key: &Scalar) -> Result { + let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; + let (next_packet, next_hop_address, delay) = match packet.process(*secret_key) { + ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), + _ => return Err(MixProcessingError::ReceivedFinalHopError), + }; + + let next_mix = MixPeer::new(); + +// let next_mix = MixPeer::new(next_hop_address.to_vec()); + + let fwd_data = ForwardingData::new(next_packet, delay, next_mix); + Ok(fwd_data) + +// match next_mix.send(next_packet.to_bytes()).await { +// Ok(()) => (), +// Err(e) => { +// println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); +// return; +// } +// } + + + } +} + + +// the MixNode will live for whole duration of this program +struct MixNode { + network_address: &'static str, + secret_key: Scalar +} + +impl MixNode{ + pub fn new(network_address: &'static str, secret_key: Scalar) -> Self { + MixNode { + network_address, + secret_key + } + } + + + + pub fn start_listening(&self) -> Result<(), Box> { + // Create the runtime + let mut rt = Runtime::new()?; + + // AGAIN TEMPORARY BECAUSE LIFETIMES (and async move) + let secret_key_copy = self.secret_key; + + // Spawn the root task + rt.block_on(async { + let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; + + loop { + let (mut socket, _) = listener.accept().await?; + + tokio::spawn(async move { + let mut buf = [0u8; sphinx::PACKET_SIZE]; + + // In a loop, read data from the socket and write the data back. + loop { + match socket.read(&mut buf).await { + // socket closed + Ok(n) if n == 0 => { + println!("Remote connection closed."); + return; + } + Ok(_) => { +// let fwd_data = self.process_sphinx_data_packet(buf.as_ref()).unwrap(); +// let packet = SphinxPacket::from_bytes(buf.to_vec()).unwrap(); +// let (next_packet, next_hop_address, delay) = match packet.process(self.secret_key) { +// ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), +// _ => panic!("tmp foomp"), +// }; + + let processor = PacketProcessor::<'_,DUMMY_TEMP_TYPE>::new(); + let fwd_data = processor.process_sphinx_data_packet(buf.as_ref(), &secret_key_copy).unwrap(); + processor.wait_and_forward(fwd_data).await; +// +// let dummy_address = b"foomp".to_vec(); +// let next_mix = MixPeer::new(dummy_address); +// +// match next_mix.send(next_packet.to_bytes()).await { +// Ok(()) => (), +// Err(e) => { +// println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); +// return; +// } +// } + } + Err(e) => { + println!("failed to read from socket; err = {:?}", e); + return; + } + }; + + // Write the some data back + if let Err(e) = socket.write_all(b"foomp").await { + println!("failed to write to socket; err = {:?}", e); + return; + } + } + }); + } + }) + } +} + +fn main() { + let mix = MixNode::new("127.0.0.1:8080", Default::default()); + mix.start_listening().unwrap(); +} +// +//#[tokio::main] +//async fn main() -> Result<(), Box> { +// let my_address = "127.0.0.1:8080"; +// let mut listener = TcpListener::bind(my_address).await?; +// +// println!("Starting Nym mixnode on address {:?}", my_address); +// println!("Waiting for input..."); +// +// loop { +// let (mut inbound, _) = listener.accept().await?; +// +// tokio::spawn(async move { +// let mut buf = [0; 1024 + 333]; +// +// loop { +// let _ = match inbound.read(&mut buf).await { +// Ok(length) if length == 0 => +// { +// println!("Remote connection closed."); +// return; +// } +// Ok(length) => { +// let packet = SphinxPacket::from_bytes(buf.to_vec()).unwrap(); +// let next_packet = match packet.process(Default::default()) { +// ProcessedPacket::ProcessedPacketForwardHop(packet, _, _) => Some(packet), +// _ => None, +// }.unwrap(); +// +// let next_mix = MixPeer::new(); +// +// match next_mix.send(next_packet.to_bytes()).await { +// Ok(()) => length, +// Err(e) => { +// println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); +// return; +// } +// } +// } +// Err(e) => { +// println!("failed to read from socket; err = {:?}", e); +// return; +// } +// }; +// } +// }); +// } +//} diff --git a/src/mix_peer.rs b/src/mix_peer.rs index bdc5d2d50b..3d58d83ffd 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -3,17 +3,20 @@ use tokio::prelude::*; use std::error::Error; -pub struct MixPeer { - connection: &'static str, +pub struct MixPeer<'a> { + connection: &'a str, } -impl MixPeer { - pub fn new() -> MixPeer { - let next_hop_address = "127.0.0.1:8081"; - let node = MixPeer { - connection: next_hop_address, - }; - node +impl<'a> MixPeer<'a> { + // for now completely ignore data we're sending. + // also note that very soon next_hop_address will be changed to next_hop_metadata +// pub fn new(nex_hop_address: Vec) -> MixPeer<'a> { + pub fn new() -> MixPeer<'a> { + + let next_hop_address_fixture: &'a str = "127.0.0.1:8081"; + MixPeer { + connection: next_hop_address_fixture, + } } pub async fn send(&self, bytes: Vec) -> Result<(), Box>{ From 2c2ecfb785dcc783ad5083a0d60838eaf457771e Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 12:58:51 +0000 Subject: [PATCH 06/66] Initial minor cleanup + actually waiting for time specified in the packet --- src/main.rs | 33 ++++++++------------------------- src/mix_peer.rs | 11 +++++------ 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5c79d5286d..d456b30431 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,14 +58,9 @@ impl<'a, T> PacketProcessor<'a, T> { async fn wait_and_forward(&self, fwd_data: ForwardingData<'a>) { let delay_duration = Duration::from_nanos(fwd_data.delay.get_value()); - // for now just hardcode some value - let delay_duration = Duration::from_secs(2); - println!("gonna wait 2 seconds!"); + println!("client says to wait for {:?}", delay_duration); tokio::time::delay_for(delay_duration).await; - println!("waited 2 seconds!"); - - -// let task = TokioDelay::new + println!("waited {:?} - time to forward the packet!", delay_duration); match fwd_data.recipient.send(fwd_data.packet.to_bytes()).await { Ok(()) => (), @@ -82,22 +77,10 @@ impl<'a, T> PacketProcessor<'a, T> { _ => return Err(MixProcessingError::ReceivedFinalHopError), }; - let next_mix = MixPeer::new(); - -// let next_mix = MixPeer::new(next_hop_address.to_vec()); + let next_mix = MixPeer::new(next_hop_address); let fwd_data = ForwardingData::new(next_packet, delay, next_mix); Ok(fwd_data) - -// match next_mix.send(next_packet.to_bytes()).await { -// Ok(()) => (), -// Err(e) => { -// println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); -// return; -// } -// } - - } } @@ -118,16 +101,16 @@ impl MixNode{ - pub fn start_listening(&self) -> Result<(), Box> { + pub fn start_listening(network_address: &str, secret_key: Scalar) -> Result<(), Box> { // Create the runtime let mut rt = Runtime::new()?; // AGAIN TEMPORARY BECAUSE LIFETIMES (and async move) - let secret_key_copy = self.secret_key; +// let secret_key_copy = self.secret_key; // Spawn the root task rt.block_on(async { - let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; + let mut listener = tokio::net::TcpListener::bind(network_address).await?; loop { let (mut socket, _) = listener.accept().await?; @@ -152,7 +135,7 @@ impl MixNode{ // }; let processor = PacketProcessor::<'_,DUMMY_TEMP_TYPE>::new(); - let fwd_data = processor.process_sphinx_data_packet(buf.as_ref(), &secret_key_copy).unwrap(); + let fwd_data = processor.process_sphinx_data_packet(buf.as_ref(), &secret_key).unwrap(); processor.wait_and_forward(fwd_data).await; // // let dummy_address = b"foomp".to_vec(); @@ -186,7 +169,7 @@ impl MixNode{ fn main() { let mix = MixNode::new("127.0.0.1:8080", Default::default()); - mix.start_listening().unwrap(); + MixNode::start_listening(mix.network_address, mix.secret_key).unwrap(); } // //#[tokio::main] diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 3d58d83ffd..53dada08a2 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -1,7 +1,7 @@ -use tokio::net::TcpStream; -use tokio::prelude::*; use std::error::Error; +use tokio::net::TcpStream; +use tokio::prelude::*; pub struct MixPeer<'a> { connection: &'a str, @@ -11,15 +11,14 @@ impl<'a> MixPeer<'a> { // for now completely ignore data we're sending. // also note that very soon next_hop_address will be changed to next_hop_metadata // pub fn new(nex_hop_address: Vec) -> MixPeer<'a> { - pub fn new() -> MixPeer<'a> { - - let next_hop_address_fixture: &'a str = "127.0.0.1:8081"; + pub fn new(next_hop_address: [u8; 32]) -> MixPeer<'a> { + let next_hop_address_fixture: &'a str = "127.0.0.1:8081"; MixPeer { connection: next_hop_address_fixture, } } - pub async fn send(&self, bytes: Vec) -> Result<(), Box>{ + pub async fn send(&self, bytes: Vec) -> Result<(), Box> { let mut stream = TcpStream::connect(self.connection).await?; stream.write_all(&bytes).await?; Ok(()) From 2fbf2456eca37f0c6db53581222267231fba5eee Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 13:18:50 +0000 Subject: [PATCH 07/66] More async cleanup --- src/main.rs | 80 +++++++++++++++---------------------------------- src/mix_peer.rs | 7 ++--- 2 files changed, 26 insertions(+), 61 deletions(-) diff --git a/src/main.rs b/src/main.rs index d456b30431..3655d730a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,12 +2,10 @@ use sphinx::{ProcessedPacket, SphinxPacket}; use tokio::prelude::*; use tokio::runtime::Runtime; use curve25519_dalek::scalar::Scalar; -use std::time::{Duration, Instant}; +use std::time::{Duration}; use crate::mix_peer::MixPeer; use crate::MixProcessingError::SphinxRecoveryError; use sphinx::header::delays::{Delay as SphinxDelay}; -use tokio::time::Delay as TokioDelay; -use std::marker::PhantomData; mod mix_peer; @@ -42,35 +40,11 @@ impl<'a> ForwardingData<'a> { } } -// just because lifetimes are annoying -type DUMMY_TEMP_TYPE = u8; - -struct PacketProcessor<'a, T> { - phantom: PhantomData<&'a T>, +struct PacketProcessor { } -impl<'a, T> PacketProcessor<'a, T> { - fn new() -> Self { - PacketProcessor{ - phantom: PhantomData - } - } - - async fn wait_and_forward(&self, fwd_data: ForwardingData<'a>) { - let delay_duration = Duration::from_nanos(fwd_data.delay.get_value()); - println!("client says to wait for {:?}", delay_duration); - tokio::time::delay_for(delay_duration).await; - println!("waited {:?} - time to forward the packet!", delay_duration); - - match fwd_data.recipient.send(fwd_data.packet.to_bytes()).await { - Ok(()) => (), - Err(e) => { - println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); - } - } - } - - pub fn process_sphinx_data_packet(&self, packet_data: &[u8], secret_key: &Scalar) -> Result { +impl PacketProcessor { + pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], secret_key: &Scalar) -> Result, MixProcessingError> { let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; let (next_packet, next_hop_address, delay) = match packet.process(*secret_key) { ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), @@ -82,6 +56,20 @@ impl<'a, T> PacketProcessor<'a, T> { let fwd_data = ForwardingData::new(next_packet, delay, next_mix); Ok(fwd_data) } + + async fn wait_and_forward(forwarding_data: ForwardingData<'_>) { + let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); + println!("client says to wait for {:?}", delay_duration); + tokio::time::delay_for(delay_duration).await; + println!("waited {:?} - time to forward the packet!", delay_duration); + + match forwarding_data.recipient.send(forwarding_data.packet.to_bytes()).await { + Ok(()) => (), + Err(e) => { + println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); + } + } + } } @@ -102,12 +90,9 @@ impl MixNode{ pub fn start_listening(network_address: &str, secret_key: Scalar) -> Result<(), Box> { - // Create the runtime + // Create the runtime, probably later move it to MixNode itself? let mut rt = Runtime::new()?; - // AGAIN TEMPORARY BECAUSE LIFETIMES (and async move) -// let secret_key_copy = self.secret_key; - // Spawn the root task rt.block_on(async { let mut listener = tokio::net::TcpListener::bind(network_address).await?; @@ -127,27 +112,8 @@ impl MixNode{ return; } Ok(_) => { -// let fwd_data = self.process_sphinx_data_packet(buf.as_ref()).unwrap(); -// let packet = SphinxPacket::from_bytes(buf.to_vec()).unwrap(); -// let (next_packet, next_hop_address, delay) = match packet.process(self.secret_key) { -// ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), -// _ => panic!("tmp foomp"), -// }; - - let processor = PacketProcessor::<'_,DUMMY_TEMP_TYPE>::new(); - let fwd_data = processor.process_sphinx_data_packet(buf.as_ref(), &secret_key).unwrap(); - processor.wait_and_forward(fwd_data).await; -// -// let dummy_address = b"foomp".to_vec(); -// let next_mix = MixPeer::new(dummy_address); -// -// match next_mix.send(next_packet.to_bytes()).await { -// Ok(()) => (), -// Err(e) => { -// println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); -// return; -// } -// } + let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), &secret_key).unwrap(); + PacketProcessor::wait_and_forward(fwd_data).await; } Err(e) => { println!("failed to read from socket; err = {:?}", e); @@ -157,7 +123,7 @@ impl MixNode{ // Write the some data back if let Err(e) = socket.write_all(b"foomp").await { - println!("failed to write to socket; err = {:?}", e); + println!("failed to write reply to socket; err = {:?}", e); return; } } @@ -171,6 +137,8 @@ fn main() { let mix = MixNode::new("127.0.0.1:8080", Default::default()); MixNode::start_listening(mix.network_address, mix.secret_key).unwrap(); } + + // //#[tokio::main] //async fn main() -> Result<(), Box> { diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 53dada08a2..eb2e71eaf6 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -1,6 +1,4 @@ use std::error::Error; - -use tokio::net::TcpStream; use tokio::prelude::*; pub struct MixPeer<'a> { @@ -10,8 +8,7 @@ pub struct MixPeer<'a> { impl<'a> MixPeer<'a> { // for now completely ignore data we're sending. // also note that very soon next_hop_address will be changed to next_hop_metadata -// pub fn new(nex_hop_address: Vec) -> MixPeer<'a> { - pub fn new(next_hop_address: [u8; 32]) -> MixPeer<'a> { + pub fn new(_next_hop_address: [u8; 32]) -> MixPeer<'a> { let next_hop_address_fixture: &'a str = "127.0.0.1:8081"; MixPeer { connection: next_hop_address_fixture, @@ -19,7 +16,7 @@ impl<'a> MixPeer<'a> { } pub async fn send(&self, bytes: Vec) -> Result<(), Box> { - let mut stream = TcpStream::connect(self.connection).await?; + let mut stream = tokio::net::TcpStream::connect(self.connection).await?; stream.write_all(&bytes).await?; Ok(()) } From ad289e531b183b10e7aba241e137477c5bd4cacc Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 13:26:47 +0000 Subject: [PATCH 08/66] Calling start_listening on mix node instance --- src/main.rs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3655d730a6..0e69d8ddc8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use std::time::{Duration}; use crate::mix_peer::MixPeer; use crate::MixProcessingError::SphinxRecoveryError; use sphinx::header::delays::{Delay as SphinxDelay}; +use std::borrow::Borrow; mod mix_peer; @@ -40,13 +41,29 @@ impl<'a> ForwardingData<'a> { } } +// ProcessingData defines all data required to correctly unwrap sphinx packets +// Do note that we're copying this struct around and hence the secret_key. +// It might, or might not be, what we want +#[derive(Clone, Copy)] +struct ProcessingData { + secret_key: Scalar +} + +impl ProcessingData { + fn new(secret_key: Scalar) -> Self { + ProcessingData{ + secret_key: secret_key.clone() + } + } +} + struct PacketProcessor { } impl PacketProcessor { - pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], secret_key: &Scalar) -> Result, MixProcessingError> { + pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], secret_key: Scalar) -> Result, MixProcessingError> { let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; - let (next_packet, next_hop_address, delay) = match packet.process(*secret_key) { + let (next_packet, next_hop_address, delay) = match packet.process(secret_key) { ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), _ => return Err(MixProcessingError::ReceivedFinalHopError), }; @@ -86,16 +103,16 @@ impl MixNode{ secret_key } } - - - - pub fn start_listening(network_address: &str, secret_key: Scalar) -> Result<(), Box> { + + pub fn start_listening(&self) -> Result<(), Box> { // Create the runtime, probably later move it to MixNode itself? let mut rt = Runtime::new()?; // Spawn the root task rt.block_on(async { - let mut listener = tokio::net::TcpListener::bind(network_address).await?; + let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; + + let processing_data = ProcessingData::new(self.secret_key); loop { let (mut socket, _) = listener.accept().await?; @@ -112,7 +129,7 @@ impl MixNode{ return; } Ok(_) => { - let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), &secret_key).unwrap(); + let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data.secret_key).unwrap(); PacketProcessor::wait_and_forward(fwd_data).await; } Err(e) => { @@ -135,7 +152,7 @@ impl MixNode{ fn main() { let mix = MixNode::new("127.0.0.1:8080", Default::default()); - MixNode::start_listening(mix.network_address, mix.secret_key).unwrap(); + mix.start_listening().unwrap(); } From 0fb9c352d6f3887802ffb463a964705188e93b56 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 13:30:39 +0000 Subject: [PATCH 09/66] - --- src/main.rs | 54 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0e69d8ddc8..5175067df7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,6 @@ use std::time::{Duration}; use crate::mix_peer::MixPeer; use crate::MixProcessingError::SphinxRecoveryError; use sphinx::header::delays::{Delay as SphinxDelay}; -use std::borrow::Borrow; mod mix_peer; @@ -103,7 +102,7 @@ impl MixNode{ secret_key } } - + pub fn start_listening(&self) -> Result<(), Box> { // Create the runtime, probably later move it to MixNode itself? let mut rt = Runtime::new()?; @@ -113,11 +112,11 @@ impl MixNode{ let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; let processing_data = ProcessingData::new(self.secret_key); - loop { let (mut socket, _) = listener.accept().await?; tokio::spawn(async move { + // NOTE: processing_data is copied here!! let mut buf = [0u8; sphinx::PACKET_SIZE]; // In a loop, read data from the socket and write the data back. @@ -155,52 +154,3 @@ fn main() { mix.start_listening().unwrap(); } - -// -//#[tokio::main] -//async fn main() -> Result<(), Box> { -// let my_address = "127.0.0.1:8080"; -// let mut listener = TcpListener::bind(my_address).await?; -// -// println!("Starting Nym mixnode on address {:?}", my_address); -// println!("Waiting for input..."); -// -// loop { -// let (mut inbound, _) = listener.accept().await?; -// -// tokio::spawn(async move { -// let mut buf = [0; 1024 + 333]; -// -// loop { -// let _ = match inbound.read(&mut buf).await { -// Ok(length) if length == 0 => -// { -// println!("Remote connection closed."); -// return; -// } -// Ok(length) => { -// let packet = SphinxPacket::from_bytes(buf.to_vec()).unwrap(); -// let next_packet = match packet.process(Default::default()) { -// ProcessedPacket::ProcessedPacketForwardHop(packet, _, _) => Some(packet), -// _ => None, -// }.unwrap(); -// -// let next_mix = MixPeer::new(); -// -// match next_mix.send(next_packet.to_bytes()).await { -// Ok(()) => length, -// Err(e) => { -// println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); -// return; -// } -// } -// } -// Err(e) => { -// println!("failed to read from socket; err = {:?}", e); -// return; -// } -// }; -// } -// }); -// } -//} From 2aaf2465e41f9f8c9659954b9836ade9306f072b Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 14:47:14 +0000 Subject: [PATCH 10/66] Moved mix code to separate module --- Cargo.lock | 62 ++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 151 +----------------------------------------------- src/node/mod.rs | 150 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 215 insertions(+), 149 deletions(-) create mode 100644 src/node/mod.rs diff --git a/Cargo.lock b/Cargo.lock index f985b23e65..5fa6a24b4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,6 +31,14 @@ dependencies = [ "stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "arc-swap" version = "0.4.4" @@ -41,6 +49,15 @@ name = "arrayref" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "atty" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -126,6 +143,20 @@ dependencies = [ "keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clear_on_drop" version = "0.2.3" @@ -396,6 +427,7 @@ dependencies = [ name = "nym-mixnode" version = "0.1.0" dependencies = [ + "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)", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -579,6 +611,11 @@ dependencies = [ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "subtle" version = "1.0.0" @@ -599,6 +636,14 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio" version = "0.2.1" @@ -635,11 +680,21 @@ name = "typenum" version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "wasi" version = "0.7.0" @@ -687,8 +742,10 @@ dependencies = [ "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" @@ -701,6 +758,7 @@ dependencies = [ "checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" @@ -753,13 +811,17 @@ dependencies = [ "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" "checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" "checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "beeef686ef92a222de07e089f455d9f8478bbba9651718f9e4b276babe829082" "checksum tokio-macros 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5795a71419535c6dcecc9b6ca95bdd3c2d6142f7e8343d7beb9923f129aa87e" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" diff --git a/Cargo.toml b/Cargo.toml index a59e50b6fd..9095ca85da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,4 @@ edition = "2018" sphinx = { path = "../sphinx" } tokio = { version = "0.2", features = ["full"] } curve25519-dalek = "1.2.3" +clap = "2.33.0" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5175067df7..a193869c13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,156 +1,9 @@ -use sphinx::{ProcessedPacket, SphinxPacket}; -use tokio::prelude::*; -use tokio::runtime::Runtime; -use curve25519_dalek::scalar::Scalar; -use std::time::{Duration}; -use crate::mix_peer::MixPeer; -use crate::MixProcessingError::SphinxRecoveryError; -use sphinx::header::delays::{Delay as SphinxDelay}; +use crate::node::MixNode; mod mix_peer; - -// TODO: this will probably need to be moved elsewhere I imagine -#[derive(Debug)] -pub enum MixProcessingError { - SphinxRecoveryError, - ReceivedFinalHopError, -} - -impl From for MixProcessingError { - // for time being just have a single error instance for all possible results of sphinx::ProcessingError - fn from(_: sphinx::ProcessingError) -> Self { - SphinxRecoveryError - } -} - -struct ForwardingData<'a> { - packet: SphinxPacket, - delay: SphinxDelay, - recipient: MixPeer<'a> -} - -// TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data -impl<'a> ForwardingData<'a> { - fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer<'a>) -> Self { - ForwardingData { - packet, - delay, - recipient - } - } -} - -// ProcessingData defines all data required to correctly unwrap sphinx packets -// Do note that we're copying this struct around and hence the secret_key. -// It might, or might not be, what we want -#[derive(Clone, Copy)] -struct ProcessingData { - secret_key: Scalar -} - -impl ProcessingData { - fn new(secret_key: Scalar) -> Self { - ProcessingData{ - secret_key: secret_key.clone() - } - } -} - -struct PacketProcessor { -} - -impl PacketProcessor { - pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], secret_key: Scalar) -> Result, MixProcessingError> { - let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; - let (next_packet, next_hop_address, delay) = match packet.process(secret_key) { - ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), - _ => return Err(MixProcessingError::ReceivedFinalHopError), - }; - - let next_mix = MixPeer::new(next_hop_address); - - let fwd_data = ForwardingData::new(next_packet, delay, next_mix); - Ok(fwd_data) - } - - async fn wait_and_forward(forwarding_data: ForwardingData<'_>) { - let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); - println!("client says to wait for {:?}", delay_duration); - tokio::time::delay_for(delay_duration).await; - println!("waited {:?} - time to forward the packet!", delay_duration); - - match forwarding_data.recipient.send(forwarding_data.packet.to_bytes()).await { - Ok(()) => (), - Err(e) => { - println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); - } - } - } -} - - -// the MixNode will live for whole duration of this program -struct MixNode { - network_address: &'static str, - secret_key: Scalar -} - -impl MixNode{ - pub fn new(network_address: &'static str, secret_key: Scalar) -> Self { - MixNode { - network_address, - secret_key - } - } - - pub fn start_listening(&self) -> Result<(), Box> { - // Create the runtime, probably later move it to MixNode itself? - let mut rt = Runtime::new()?; - - // Spawn the root task - rt.block_on(async { - let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; - - let processing_data = ProcessingData::new(self.secret_key); - loop { - let (mut socket, _) = listener.accept().await?; - - tokio::spawn(async move { - // NOTE: processing_data is copied here!! - let mut buf = [0u8; sphinx::PACKET_SIZE]; - - // In a loop, read data from the socket and write the data back. - loop { - match socket.read(&mut buf).await { - // socket closed - Ok(n) if n == 0 => { - println!("Remote connection closed."); - return; - } - Ok(_) => { - let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data.secret_key).unwrap(); - PacketProcessor::wait_and_forward(fwd_data).await; - } - Err(e) => { - println!("failed to read from socket; err = {:?}", e); - return; - } - }; - - // Write the some data back - if let Err(e) = socket.write_all(b"foomp").await { - println!("failed to write reply to socket; err = {:?}", e); - return; - } - } - }); - } - }) - } -} +mod node; fn main() { let mix = MixNode::new("127.0.0.1:8080", Default::default()); mix.start_listening().unwrap(); } - diff --git a/src/node/mod.rs b/src/node/mod.rs new file mode 100644 index 0000000000..f4b605f2cd --- /dev/null +++ b/src/node/mod.rs @@ -0,0 +1,150 @@ +use sphinx::{ProcessedPacket, SphinxPacket}; +use tokio::prelude::*; +use tokio::runtime::Runtime; +use curve25519_dalek::scalar::Scalar; +use std::time::{Duration}; +use crate::mix_peer::MixPeer; +use sphinx::header::delays::{Delay as SphinxDelay}; + + +// TODO: this will probably need to be moved elsewhere I imagine +#[derive(Debug)] +pub enum MixProcessingError { + SphinxRecoveryError, + ReceivedFinalHopError, +} + +impl From for MixProcessingError { + // for time being just have a single error instance for all possible results of sphinx::ProcessingError + fn from(_: sphinx::ProcessingError) -> Self { + use MixProcessingError::*; + + SphinxRecoveryError + } +} + +struct ForwardingData<'a> { + packet: SphinxPacket, + delay: SphinxDelay, + recipient: MixPeer<'a> +} + +// TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data +impl<'a> ForwardingData<'a> { + fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer<'a>) -> Self { + ForwardingData { + packet, + delay, + recipient + } + } +} + +// ProcessingData defines all data required to correctly unwrap sphinx packets +// Do note that we're copying this struct around and hence the secret_key. +// It might, or might not be, what we want +#[derive(Clone, Copy)] +struct ProcessingData { + secret_key: Scalar +} + +impl ProcessingData { + fn new(secret_key: Scalar) -> Self { + ProcessingData{ + secret_key: secret_key.clone() + } + } +} + +struct PacketProcessor { +} + +impl PacketProcessor { + pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], secret_key: Scalar) -> Result, MixProcessingError> { + let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; + let (next_packet, next_hop_address, delay) = match packet.process(secret_key) { + ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), + _ => return Err(MixProcessingError::ReceivedFinalHopError), + }; + + let next_mix = MixPeer::new(next_hop_address); + + let fwd_data = ForwardingData::new(next_packet, delay, next_mix); + Ok(fwd_data) + } + + async fn wait_and_forward(forwarding_data: ForwardingData<'_>) { + let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); + println!("client says to wait for {:?}", delay_duration); + tokio::time::delay_for(delay_duration).await; + println!("waited {:?} - time to forward the packet!", delay_duration); + + match forwarding_data.recipient.send(forwarding_data.packet.to_bytes()).await { + Ok(()) => (), + Err(e) => { + println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); + } + } + } +} + + +// the MixNode will live for whole duration of this program +pub struct MixNode { + network_address: &'static str, + secret_key: Scalar +} + +impl MixNode{ + pub fn new(network_address: &'static str, secret_key: Scalar) -> Self { + MixNode { + network_address, + secret_key + } + } + + pub fn start_listening(&self) -> Result<(), Box> { + // Create the runtime, probably later move it to MixNode itself? + let mut rt = Runtime::new()?; + + // Spawn the root task + rt.block_on(async { + let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; + + let processing_data = ProcessingData::new(self.secret_key); + loop { + let (mut socket, _) = listener.accept().await?; + + tokio::spawn(async move { + // NOTE: processing_data is copied here!! + let mut buf = [0u8; sphinx::PACKET_SIZE]; + + // In a loop, read data from the socket and write the data back. + loop { + match socket.read(&mut buf).await { + // socket closed + Ok(n) if n == 0 => { + println!("Remote connection closed."); + return; + } + Ok(_) => { + let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data.secret_key).unwrap(); + PacketProcessor::wait_and_forward(fwd_data).await; + } + Err(e) => { + println!("failed to read from socket; err = {:?}", e); + return; + } + }; + + // Write the some data back + if let Err(e) = socket.write_all(b"foomp").await { + println!("failed to write reply to socket; err = {:?}", e); + return; + } + } + }); + } + }) + } +} \ No newline at end of file From 9deaad8a2a003bcbe8cd275f624b055f68f435f2 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 16:14:29 +0000 Subject: [PATCH 11/66] Initial set of mixnode arguments --- src/main.rs | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 125 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index a193869c13..2544bb8afb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,131 @@ use crate::node::MixNode; +use clap::{App, Arg, ArgMatches, SubCommand}; +use std::net::{SocketAddr, ToSocketAddrs}; +use std::process; mod mix_peer; mod node; -fn main() { - let mix = MixNode::new("127.0.0.1:8080", Default::default()); - mix.start_listening().unwrap(); +// +//fn run(matches: ArgMatches) -> Result<(), String> { +// // ... +// match matches.subcommand() { +// ("analyse", Some(m)) => run_analyse(m, &logger), +// ("verify", Some(m)) => run_verify(m, &logger), +// _ => Ok(()), +// } +//} +// +//fn run_analyse(matches: &ArgMatches, parent_logger: &slog::Logger) -> Result<(), String> { +// let logger = parent_logger.new(o!("command" => "analyse")); +// let input = matches.value_of("input-file").unwrap(); +// debug!(logger, "analysis_started"; "input_file" => input); +// // ... +// Ok(()) +//} +// +//fn run_verify(matches: &ArgMatches, parent_logger: &slog::Logger) -> Result<(), String> { +// let logger = parent_logger.new(o!("command" => "verify")); +// let algorithm = value_t!(matches.value_of("algorithm"), Algorithm).unwrap(); +// debug!(logger, "verification_started"; "algorithm" => format!("{:?}", algorithm)); +// // ... +// Ok(()) +//} + +fn execute(matches: ArgMatches) -> Result<(), String> { + match matches.subcommand() { + ("run", Some(m)) => run(m), + _ => Err(String::from("Unknown command")), + } +} + +fn run(matches: &ArgMatches) -> Result<(), String> { + println!("Running the mixnode!"); + + let host = matches.value_of("host").unwrap_or("0.0.0.0"); + + let port = match matches.value_of("port").unwrap().parse::() { + Ok(n) => n, + Err(err) => panic!("Invalid port value provided - {:?}", err), + }; + + let layer = match matches.value_of("layer").unwrap().parse::() { + Ok(n) => n, + Err(err) => panic!("Invalid layer value provided - {:?}", err), + }; + + let key = match matches.value_of("keyfile") { + Some(keyfile) => { + println!("Todo: load keyfile from <{:?}>", keyfile); + "dummy key1" + } + None => { + println!("Todo: generate fresh sphinx keypair"); + "dummy key2" + } + }; + + println!("The value of host is: {}", host); + println!("The value of port is: {}", port); + println!("The value of layer is: {}", layer); + println!("The value of key is: {}", key); + + let socket_address = (host, port) + .to_socket_addrs() + .expect("Failed to combine host and port") + .next() + .expect("Failed to extract the socket address from the iterator"); + + println!("The full combined socket address is {}", socket_address); + Ok(()) +} + +fn main() { + let arg_matches = App::new("Nym Mixnode") + .version("0.1.0") + .author("Nymtech") + .about("Implementation of the Loopix-based Mixnode") + .subcommand( + SubCommand::with_name("run") + .about("Starts the mixnode") + .arg( + Arg::with_name("host") + .short("h") + .long("host") + .help("The custom host on which the mixnode will be running") + .takes_value(true), + ) + .arg( + Arg::with_name("port") + .short("p") + .long("port") + .help("The port on which the mixnode will be listening") + .takes_value(true) + .required(true), + ) + .arg( + Arg::with_name("layer") + .short("l") + .long("layer") + .help("The mixnet layer of this particular node") + .takes_value(true) + .required(true), + ) + .arg( + Arg::with_name("keyfile") + .short("k") + .long("keyfile") + .help("Optional path to the persistent keyfile of the node") + .takes_value(true), + ), + ) + .get_matches(); + + if let Err(e) = execute(arg_matches) { + println!("Application error: {}", e); + process::exit(1); + } + + // let mix = MixNode::new("127.0.0.1:8080", Default::default()); + // mix.start_listening().unwrap(); } From 777c40bd97a6e6b6d63aae7371f23882b3c70c3c Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 16:20:07 +0000 Subject: [PATCH 12/66] Starting mixnode with provided command line arguments --- src/main.rs | 31 +++++++++++++++++-------------- src/node/mod.rs | 5 +++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2544bb8afb..44e3bb743d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use crate::node::MixNode; use clap::{App, Arg, ArgMatches, SubCommand}; -use std::net::{SocketAddr, ToSocketAddrs}; +use curve25519_dalek::scalar::Scalar; +use std::net::ToSocketAddrs; use std::process; mod mix_peer; @@ -34,12 +35,12 @@ mod node; fn execute(matches: ArgMatches) -> Result<(), String> { match matches.subcommand() { - ("run", Some(m)) => run(m), + ("run", Some(m)) => Ok(run(m)), _ => Err(String::from("Unknown command")), } } -fn run(matches: &ArgMatches) -> Result<(), String> { +fn run(matches: &ArgMatches) { println!("Running the mixnode!"); let host = matches.value_of("host").unwrap_or("0.0.0.0"); @@ -54,21 +55,21 @@ fn run(matches: &ArgMatches) -> Result<(), String> { Err(err) => panic!("Invalid layer value provided - {:?}", err), }; - let key = match matches.value_of("keyfile") { + let secret_key: Scalar = match matches.value_of("keyfile") { Some(keyfile) => { println!("Todo: load keyfile from <{:?}>", keyfile); - "dummy key1" + Default::default() } None => { println!("Todo: generate fresh sphinx keypair"); - "dummy key2" + Default::default() } }; - println!("The value of host is: {}", host); - println!("The value of port is: {}", port); - println!("The value of layer is: {}", layer); - println!("The value of key is: {}", key); + println!("The value of host is: {:?}", host); + println!("The value of port is: {:?}", port); + println!("The value of layer is: {:?}", layer); + println!("The value of key is: {:?}", secret_key); let socket_address = (host, port) .to_socket_addrs() @@ -77,7 +78,12 @@ fn run(matches: &ArgMatches) -> Result<(), String> { .expect("Failed to extract the socket address from the iterator"); println!("The full combined socket address is {}", socket_address); - Ok(()) + + // make sure our socket_address is equal to our predefined-hardcoded value + assert_eq!("127.0.0.1:8080", socket_address.to_string()); + + let mix = MixNode::new(socket_address, secret_key); + mix.start_listening().unwrap(); } fn main() { @@ -125,7 +131,4 @@ fn main() { println!("Application error: {}", e); process::exit(1); } - - // let mix = MixNode::new("127.0.0.1:8080", Default::default()); - // mix.start_listening().unwrap(); } diff --git a/src/node/mod.rs b/src/node/mod.rs index f4b605f2cd..7f4f1103d2 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -5,6 +5,7 @@ use curve25519_dalek::scalar::Scalar; use std::time::{Duration}; use crate::mix_peer::MixPeer; use sphinx::header::delays::{Delay as SphinxDelay}; +use std::net::SocketAddr; // TODO: this will probably need to be moved elsewhere I imagine @@ -91,12 +92,12 @@ impl PacketProcessor { // the MixNode will live for whole duration of this program pub struct MixNode { - network_address: &'static str, + network_address: SocketAddr, secret_key: Scalar } impl MixNode{ - pub fn new(network_address: &'static str, secret_key: Scalar) -> Self { + pub fn new(network_address: SocketAddr, secret_key: Scalar) -> Self { MixNode { network_address, secret_key From 256afa3be9162b52ab93ef52996f35e7a07c8a0b Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 16:20:26 +0000 Subject: [PATCH 13/66] Removed example code --- src/main.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/main.rs b/src/main.rs index 44e3bb743d..7bc92328ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,32 +7,6 @@ use std::process; mod mix_peer; mod node; -// -//fn run(matches: ArgMatches) -> Result<(), String> { -// // ... -// match matches.subcommand() { -// ("analyse", Some(m)) => run_analyse(m, &logger), -// ("verify", Some(m)) => run_verify(m, &logger), -// _ => Ok(()), -// } -//} -// -//fn run_analyse(matches: &ArgMatches, parent_logger: &slog::Logger) -> Result<(), String> { -// let logger = parent_logger.new(o!("command" => "analyse")); -// let input = matches.value_of("input-file").unwrap(); -// debug!(logger, "analysis_started"; "input_file" => input); -// // ... -// Ok(()) -//} -// -//fn run_verify(matches: &ArgMatches, parent_logger: &slog::Logger) -> Result<(), String> { -// let logger = parent_logger.new(o!("command" => "verify")); -// let algorithm = value_t!(matches.value_of("algorithm"), Algorithm).unwrap(); -// debug!(logger, "verification_started"; "algorithm" => format!("{:?}", algorithm)); -// // ... -// Ok(()) -//} - fn execute(matches: ArgMatches) -> Result<(), String> { match matches.subcommand() { ("run", Some(m)) => Ok(run(m)), From 31d0aa7fe41771478ec5c21287f2b95a32605a13 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Fri, 6 Dec 2019 16:21:04 +0000 Subject: [PATCH 14/66] Added layer as mixnode attribute --- src/main.rs | 2 +- src/node/mod.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7bc92328ec..e3e2fb5e2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,7 +56,7 @@ fn run(matches: &ArgMatches) { // make sure our socket_address is equal to our predefined-hardcoded value assert_eq!("127.0.0.1:8080", socket_address.to_string()); - let mix = MixNode::new(socket_address, secret_key); + let mix = MixNode::new(socket_address, secret_key, layer); mix.start_listening().unwrap(); } diff --git a/src/node/mod.rs b/src/node/mod.rs index 7f4f1103d2..5e62658fe8 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -93,14 +93,16 @@ impl PacketProcessor { // the MixNode will live for whole duration of this program pub struct MixNode { network_address: SocketAddr, - secret_key: Scalar + secret_key: Scalar, + layer: usize } impl MixNode{ - pub fn new(network_address: SocketAddr, secret_key: Scalar) -> Self { + pub fn new(network_address: SocketAddr, secret_key: Scalar, layer: usize) -> Self { MixNode { network_address, - secret_key + secret_key, + layer } } From cd94ecde1963423bec7c29a5878c05403c253bc4 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 9 Dec 2019 13:59:22 +0000 Subject: [PATCH 15/66] Passing entire processing data struct for dealing with sphinx packets --- src/node/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node/mod.rs b/src/node/mod.rs index 5e62658fe8..796973ca03 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -61,9 +61,9 @@ struct PacketProcessor { } impl PacketProcessor { - pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], secret_key: Scalar) -> Result, MixProcessingError> { + pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], processing_data: ProcessingData) -> Result, MixProcessingError> { let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; - let (next_packet, next_hop_address, delay) = match packet.process(secret_key) { + let (next_packet, next_hop_address, delay) = match packet.process(processing_data.secret_key) { ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), _ => return Err(MixProcessingError::ReceivedFinalHopError), }; @@ -131,7 +131,7 @@ impl MixNode{ return; } Ok(_) => { - let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data.secret_key).unwrap(); + let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data).unwrap(); PacketProcessor::wait_and_forward(fwd_data).await; } Err(e) => { From 9b8b0bff1de7b98fe3ec8974d2076a3e8b1be021 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 9 Dec 2019 17:07:42 +0000 Subject: [PATCH 16/66] Moved socket processing to separate function --- src/node/mod.rs | 58 ++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/node/mod.rs b/src/node/mod.rs index 796973ca03..abda9cd3ea 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -106,6 +106,36 @@ impl MixNode{ } } + async fn process_socket_connection(mut socket: tokio::net::TcpStream, processing_data: ProcessingData) { + // NOTE: processing_data is copied here!! + let mut buf = [0u8; sphinx::PACKET_SIZE]; + + // In a loop, read data from the socket and write the data back. + loop { + match socket.read(&mut buf).await { + // socket closed + Ok(n) if n == 0 => { + println!("Remote connection closed."); + return; + } + Ok(_) => { + let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data).unwrap(); + PacketProcessor::wait_and_forward(fwd_data).await; + } + Err(e) => { + println!("failed to read from socket; err = {:?}", e); + return; + } + }; + + // Write the some data back + if let Err(e) = socket.write_all(b"foomp").await { + println!("failed to write reply to socket; err = {:?}", e); + return; + } + } + } + pub fn start_listening(&self) -> Result<(), Box> { // Create the runtime, probably later move it to MixNode itself? let mut rt = Runtime::new()?; @@ -119,33 +149,7 @@ impl MixNode{ let (mut socket, _) = listener.accept().await?; tokio::spawn(async move { - // NOTE: processing_data is copied here!! - let mut buf = [0u8; sphinx::PACKET_SIZE]; - - // In a loop, read data from the socket and write the data back. - loop { - match socket.read(&mut buf).await { - // socket closed - Ok(n) if n == 0 => { - println!("Remote connection closed."); - return; - } - Ok(_) => { - let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data).unwrap(); - PacketProcessor::wait_and_forward(fwd_data).await; - } - Err(e) => { - println!("failed to read from socket; err = {:?}", e); - return; - } - }; - - // Write the some data back - if let Err(e) = socket.write_all(b"foomp").await { - println!("failed to write reply to socket; err = {:?}", e); - return; - } - } + MixNode::process_socket_connection(socket, processing_data).await; }); } }) From 1371b9459963502ead801ff2bea72f2fa778dca9 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 10 Dec 2019 13:12:58 +0000 Subject: [PATCH 17/66] Removed processing data copy on every connection and instead use Arc with RwLock --- src/node/mod.rs | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/node/mod.rs b/src/node/mod.rs index abda9cd3ea..7ece90f488 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -1,12 +1,14 @@ +use std::net::SocketAddr; +use std::sync::{Arc, RwLock}; +use std::time::Duration; + +use curve25519_dalek::scalar::Scalar; use sphinx::{ProcessedPacket, SphinxPacket}; +use sphinx::header::delays::Delay as SphinxDelay; use tokio::prelude::*; use tokio::runtime::Runtime; -use curve25519_dalek::scalar::Scalar; -use std::time::{Duration}; -use crate::mix_peer::MixPeer; -use sphinx::header::delays::{Delay as SphinxDelay}; -use std::net::SocketAddr; +use crate::mix_peer::MixPeer; // TODO: this will probably need to be moved elsewhere I imagine #[derive(Debug)] @@ -27,7 +29,7 @@ impl From for MixProcessingError { struct ForwardingData<'a> { packet: SphinxPacket, delay: SphinxDelay, - recipient: MixPeer<'a> + recipient: MixPeer<'a>, } // TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data @@ -36,34 +38,34 @@ impl<'a> ForwardingData<'a> { ForwardingData { packet, delay, - recipient + recipient, } } } // ProcessingData defines all data required to correctly unwrap sphinx packets -// Do note that we're copying this struct around and hence the secret_key. -// It might, or might not be, what we want -#[derive(Clone, Copy)] struct ProcessingData { secret_key: Scalar } impl ProcessingData { fn new(secret_key: Scalar) -> Self { - ProcessingData{ - secret_key: secret_key.clone() + ProcessingData { + secret_key } } + + fn add_arc_rwlock(self) -> Arc> { + Arc::new(RwLock::new(self)) + } } -struct PacketProcessor { -} +struct PacketProcessor {} impl PacketProcessor { - pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], processing_data: ProcessingData) -> Result, MixProcessingError> { + pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], processing_data: Arc>) -> Result, MixProcessingError> { let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; - let (next_packet, next_hop_address, delay) = match packet.process(processing_data.secret_key) { + let (next_packet, next_hop_address, delay) = match packet.process(processing_data.read().unwrap().secret_key) { ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), _ => return Err(MixProcessingError::ReceivedFinalHopError), }; @@ -94,19 +96,19 @@ impl PacketProcessor { pub struct MixNode { network_address: SocketAddr, secret_key: Scalar, - layer: usize + layer: usize, } -impl MixNode{ +impl MixNode { pub fn new(network_address: SocketAddr, secret_key: Scalar, layer: usize) -> Self { MixNode { network_address, secret_key, - layer + layer, } } - async fn process_socket_connection(mut socket: tokio::net::TcpStream, processing_data: ProcessingData) { + async fn process_socket_connection(mut socket: tokio::net::TcpStream, processing_data: Arc>) { // NOTE: processing_data is copied here!! let mut buf = [0u8; sphinx::PACKET_SIZE]; @@ -119,7 +121,7 @@ impl MixNode{ return; } Ok(_) => { - let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data).unwrap(); + let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data.clone()).unwrap(); PacketProcessor::wait_and_forward(fwd_data).await; } Err(e) => { @@ -143,13 +145,14 @@ impl MixNode{ // Spawn the root task rt.block_on(async { let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; + let processing_data = ProcessingData::new(self.secret_key).add_arc_rwlock(); - let processing_data = ProcessingData::new(self.secret_key); loop { let (mut socket, _) = listener.accept().await?; + let thread_processing_data = processing_data.clone(); tokio::spawn(async move { - MixNode::process_socket_connection(socket, processing_data).await; + MixNode::process_socket_connection(socket, thread_processing_data).await; }); } }) From f095dd114e7d08be92714797060c90a726190eb3 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 12 Dec 2019 16:57:01 +0000 Subject: [PATCH 18/66] main: breaking the run command out so that it lives with the node code --- src/main.rs | 67 +++++----------------------------------------- src/node/mod.rs | 51 ++++++++++++++++++++++++----------- src/node/runner.rs | 50 ++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 76 deletions(-) create mode 100644 src/node/runner.rs diff --git a/src/main.rs b/src/main.rs index e3e2fb5e2f..b81d053643 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,65 +1,9 @@ -use crate::node::MixNode; use clap::{App, Arg, ArgMatches, SubCommand}; -use curve25519_dalek::scalar::Scalar; -use std::net::ToSocketAddrs; use std::process; mod mix_peer; mod node; -fn execute(matches: ArgMatches) -> Result<(), String> { - match matches.subcommand() { - ("run", Some(m)) => Ok(run(m)), - _ => Err(String::from("Unknown command")), - } -} - -fn run(matches: &ArgMatches) { - println!("Running the mixnode!"); - - let host = matches.value_of("host").unwrap_or("0.0.0.0"); - - let port = match matches.value_of("port").unwrap().parse::() { - Ok(n) => n, - Err(err) => panic!("Invalid port value provided - {:?}", err), - }; - - let layer = match matches.value_of("layer").unwrap().parse::() { - Ok(n) => n, - Err(err) => panic!("Invalid layer value provided - {:?}", err), - }; - - let secret_key: Scalar = match matches.value_of("keyfile") { - Some(keyfile) => { - println!("Todo: load keyfile from <{:?}>", keyfile); - Default::default() - } - None => { - println!("Todo: generate fresh sphinx keypair"); - Default::default() - } - }; - - println!("The value of host is: {:?}", host); - println!("The value of port is: {:?}", port); - println!("The value of layer is: {:?}", layer); - println!("The value of key is: {:?}", secret_key); - - let socket_address = (host, port) - .to_socket_addrs() - .expect("Failed to combine host and port") - .next() - .expect("Failed to extract the socket address from the iterator"); - - println!("The full combined socket address is {}", socket_address); - - // make sure our socket_address is equal to our predefined-hardcoded value - assert_eq!("127.0.0.1:8080", socket_address.to_string()); - - let mix = MixNode::new(socket_address, secret_key, layer); - mix.start_listening().unwrap(); -} - fn main() { let arg_matches = App::new("Nym Mixnode") .version("0.1.0") @@ -70,14 +14,12 @@ fn main() { .about("Starts the mixnode") .arg( Arg::with_name("host") - .short("h") .long("host") .help("The custom host on which the mixnode will be running") .takes_value(true), ) .arg( Arg::with_name("port") - .short("p") .long("port") .help("The port on which the mixnode will be listening") .takes_value(true) @@ -85,7 +27,6 @@ fn main() { ) .arg( Arg::with_name("layer") - .short("l") .long("layer") .help("The mixnet layer of this particular node") .takes_value(true) @@ -93,7 +34,6 @@ fn main() { ) .arg( Arg::with_name("keyfile") - .short("k") .long("keyfile") .help("Optional path to the persistent keyfile of the node") .takes_value(true), @@ -106,3 +46,10 @@ fn main() { process::exit(1); } } + +fn execute(matches: ArgMatches) -> Result<(), String> { + match matches.subcommand() { + ("run", Some(m)) => Ok(node::runner::start(m)), + _ => Err(String::from("Unknown command")), + } +} diff --git a/src/node/mod.rs b/src/node/mod.rs index 7ece90f488..20acba4e5e 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -3,13 +3,15 @@ use std::sync::{Arc, RwLock}; use std::time::Duration; use curve25519_dalek::scalar::Scalar; -use sphinx::{ProcessedPacket, SphinxPacket}; use sphinx::header::delays::Delay as SphinxDelay; +use sphinx::{ProcessedPacket, SphinxPacket}; use tokio::prelude::*; use tokio::runtime::Runtime; use crate::mix_peer::MixPeer; +pub mod runner; + // TODO: this will probably need to be moved elsewhere I imagine #[derive(Debug)] pub enum MixProcessingError { @@ -45,14 +47,12 @@ impl<'a> ForwardingData<'a> { // ProcessingData defines all data required to correctly unwrap sphinx packets struct ProcessingData { - secret_key: Scalar + secret_key: Scalar, } impl ProcessingData { fn new(secret_key: Scalar) -> Self { - ProcessingData { - secret_key - } + ProcessingData { secret_key } } fn add_arc_rwlock(self) -> Arc> { @@ -63,12 +63,18 @@ impl ProcessingData { struct PacketProcessor {} impl PacketProcessor { - pub fn process_sphinx_data_packet<'a>(packet_data: &[u8], processing_data: Arc>) -> Result, MixProcessingError> { + pub fn process_sphinx_data_packet<'a>( + packet_data: &[u8], + processing_data: Arc>, + ) -> Result, MixProcessingError> { let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; - let (next_packet, next_hop_address, delay) = match packet.process(processing_data.read().unwrap().secret_key) { - ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => (packet, address, delay), - _ => return Err(MixProcessingError::ReceivedFinalHopError), - }; + let (next_packet, next_hop_address, delay) = + match packet.process(processing_data.read().unwrap().secret_key) { + ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => { + (packet, address, delay) + } + _ => return Err(MixProcessingError::ReceivedFinalHopError), + }; let next_mix = MixPeer::new(next_hop_address); @@ -82,16 +88,22 @@ impl PacketProcessor { tokio::time::delay_for(delay_duration).await; println!("waited {:?} - time to forward the packet!", delay_duration); - match forwarding_data.recipient.send(forwarding_data.packet.to_bytes()).await { + match forwarding_data + .recipient + .send(forwarding_data.packet.to_bytes()) + .await + { Ok(()) => (), Err(e) => { - println!("failed to write bytes to next mix peer. err = {:?}", e.to_string()); + println!( + "failed to write bytes to next mix peer. err = {:?}", + e.to_string() + ); } } } } - // the MixNode will live for whole duration of this program pub struct MixNode { network_address: SocketAddr, @@ -108,7 +120,10 @@ impl MixNode { } } - async fn process_socket_connection(mut socket: tokio::net::TcpStream, processing_data: Arc>) { + async fn process_socket_connection( + mut socket: tokio::net::TcpStream, + processing_data: Arc>, + ) { // NOTE: processing_data is copied here!! let mut buf = [0u8; sphinx::PACKET_SIZE]; @@ -121,7 +136,11 @@ impl MixNode { return; } Ok(_) => { - let fwd_data = PacketProcessor::process_sphinx_data_packet(buf.as_ref(), processing_data.clone()).unwrap(); + let fwd_data = PacketProcessor::process_sphinx_data_packet( + buf.as_ref(), + processing_data.clone(), + ) + .unwrap(); PacketProcessor::wait_and_forward(fwd_data).await; } Err(e) => { @@ -157,4 +176,4 @@ impl MixNode { } }) } -} \ No newline at end of file +} diff --git a/src/node/runner.rs b/src/node/runner.rs new file mode 100644 index 0000000000..f6f81147a6 --- /dev/null +++ b/src/node/runner.rs @@ -0,0 +1,50 @@ +use crate::node::MixNode; +use clap::ArgMatches; +use curve25519_dalek::scalar::Scalar; +use std::net::ToSocketAddrs; + +pub fn start(matches: &ArgMatches) { + println!("Running the mixnode!"); + + let host = matches.value_of("host").unwrap_or("0.0.0.0"); + + let port = match matches.value_of("port").unwrap().parse::() { + Ok(n) => n, + Err(err) => panic!("Invalid port value provided - {:?}", err), + }; + + let layer = match matches.value_of("layer").unwrap().parse::() { + Ok(n) => n, + Err(err) => panic!("Invalid layer value provided - {:?}", err), + }; + + let secret_key: Scalar = match matches.value_of("keyfile") { + Some(keyfile) => { + println!("Todo: load keyfile from <{:?}>", keyfile); + Default::default() + } + None => { + println!("Todo: generate fresh sphinx keypair"); + Default::default() + } + }; + + println!("The value of host is: {:?}", host); + println!("The value of port is: {:?}", port); + println!("The value of layer is: {:?}", layer); + println!("The value of key is: {:?}", secret_key); + + let socket_address = (host, port) + .to_socket_addrs() + .expect("Failed to combine host and port") + .next() + .expect("Failed to extract the socket address from the iterator"); + + println!("The full combined socket address is {}", socket_address); + + // make sure our socket_address is equal to our predefined-hardcoded value + assert_eq!("127.0.0.1:8080", socket_address.to_string()); + + let mix = MixNode::new(socket_address, secret_key, layer); + mix.start_listening().unwrap(); +} From 76c2eac3bd5c744282f4d208311347256169df61 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 12 Dec 2019 16:59:01 +0000 Subject: [PATCH 19/66] main: adding usage banner --- src/main.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index b81d053643..e8c9dc0e0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,7 @@ fn main() { .get_matches(); if let Err(e) = execute(arg_matches) { - println!("Application error: {}", e); + println!("{}", e); process::exit(1); } } @@ -50,6 +50,25 @@ fn main() { fn execute(matches: ArgMatches) -> Result<(), String> { match matches.subcommand() { ("run", Some(m)) => Ok(node::runner::start(m)), - _ => Err(String::from("Unknown command")), + _ => Err(usage()), } } + +fn usage() -> String { + banner() + "usage: --help to see available options.\n\n" +} + +fn banner() -> String { + return r#" + + _ __ _ _ _ __ ___ + | '_ \| | | | '_ \ _ \ + | | | | |_| | | | | | | + |_| |_|\__, |_| |_| |_| + |___/ + + (mixnode) + + "# + .to_string(); +} From 17deec772068195aa7c0365f6f832a8fbe05229e Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 12 Dec 2019 17:10:08 +0000 Subject: [PATCH 20/66] runner: removing host assertion so default takes effect --- src/node/runner.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/runner.rs b/src/node/runner.rs index f6f81147a6..7bbff92e8d 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -43,7 +43,7 @@ pub fn start(matches: &ArgMatches) { println!("The full combined socket address is {}", socket_address); // make sure our socket_address is equal to our predefined-hardcoded value - assert_eq!("127.0.0.1:8080", socket_address.to_string()); + // assert_eq!("127.0.0.1:8080", socket_address.to_string()); let mix = MixNode::new(socket_address, secret_key, layer); mix.start_listening().unwrap(); From eb49ef10131e0cce8c7adae7bbb04142a6f560ed Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 12 Dec 2019 17:10:24 +0000 Subject: [PATCH 21/66] node: removing socket mutabilitiy --- src/node/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/mod.rs b/src/node/mod.rs index 20acba4e5e..3ec50426bf 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -167,7 +167,7 @@ impl MixNode { let processing_data = ProcessingData::new(self.secret_key).add_arc_rwlock(); loop { - let (mut socket, _) = listener.accept().await?; + let (socket, _) = listener.accept().await?; let thread_processing_data = processing_data.clone(); tokio::spawn(async move { From fdf49ff804262b08a8edc903078629d093bb072a Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 12 Dec 2019 17:47:13 +0000 Subject: [PATCH 22/66] runner: cleaning up text to prep for release --- src/node/runner.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/node/runner.rs b/src/node/runner.rs index 7bbff92e8d..09b5fafc77 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -1,10 +1,13 @@ +use crate::banner; use crate::node::MixNode; use clap::ArgMatches; + use curve25519_dalek::scalar::Scalar; use std::net::ToSocketAddrs; pub fn start(matches: &ArgMatches) { - println!("Running the mixnode!"); + println!("{}", banner()); + println!("Starting mixnode..."); let host = matches.value_of("host").unwrap_or("0.0.0.0"); @@ -20,27 +23,23 @@ pub fn start(matches: &ArgMatches) { let secret_key: Scalar = match matches.value_of("keyfile") { Some(keyfile) => { - println!("Todo: load keyfile from <{:?}>", keyfile); + println!("TODO: load keyfile from <{:?}>", keyfile); Default::default() } None => { - println!("Todo: generate fresh sphinx keypair"); + println!("TODO: generate fresh sphinx keypair"); Default::default() } }; - println!("The value of host is: {:?}", host); - println!("The value of port is: {:?}", port); - println!("The value of layer is: {:?}", layer); - println!("The value of key is: {:?}", secret_key); - let socket_address = (host, port) .to_socket_addrs() .expect("Failed to combine host and port") .next() .expect("Failed to extract the socket address from the iterator"); - println!("The full combined socket address is {}", socket_address); + println!("Startup complete on: {}", socket_address); + println!("Listening for incoming packets..."); // make sure our socket_address is equal to our predefined-hardcoded value // assert_eq!("127.0.0.1:8080", socket_address.to_string()); From 4feadb6352a436542971318d26deb10836cc64dd Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 12 Dec 2019 19:01:53 +0000 Subject: [PATCH 23/66] mix_peer: now using the real address from the packet --- src/mix_peer.rs | 22 ++++++++++++---------- src/node/mod.rs | 12 ++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/mix_peer.rs b/src/mix_peer.rs index eb2e71eaf6..c5bacfcf76 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -1,23 +1,25 @@ use std::error::Error; use tokio::prelude::*; -pub struct MixPeer<'a> { - connection: &'a str, +pub struct MixPeer { + connection: String, } -impl<'a> MixPeer<'a> { - // for now completely ignore data we're sending. - // also note that very soon next_hop_address will be changed to next_hop_metadata - pub fn new(_next_hop_address: [u8; 32]) -> MixPeer<'a> { - let next_hop_address_fixture: &'a str = "127.0.0.1:8081"; +impl<'a> 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 address = String::from_utf8_lossy(&next_hop_address) + .trim_end_matches(char::from(0)) + .to_string(); MixPeer { - connection: next_hop_address_fixture, + connection: address, } } pub async fn send(&self, bytes: Vec) -> Result<(), Box> { - let mut stream = tokio::net::TcpStream::connect(self.connection).await?; + let next_hop_address = self.connection.clone(); + let mut stream = tokio::net::TcpStream::connect(next_hop_address).await?; stream.write_all(&bytes).await?; Ok(()) } -} \ No newline at end of file +} diff --git a/src/node/mod.rs b/src/node/mod.rs index 3ec50426bf..522076389d 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -28,15 +28,15 @@ impl From for MixProcessingError { } } -struct ForwardingData<'a> { +struct ForwardingData { packet: SphinxPacket, delay: SphinxDelay, - recipient: MixPeer<'a>, + recipient: MixPeer, } // TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data -impl<'a> ForwardingData<'a> { - fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer<'a>) -> Self { +impl<'a> ForwardingData { + fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer) -> Self { ForwardingData { packet, delay, @@ -66,7 +66,7 @@ impl PacketProcessor { pub fn process_sphinx_data_packet<'a>( packet_data: &[u8], processing_data: Arc>, - ) -> Result, MixProcessingError> { + ) -> Result { let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; let (next_packet, next_hop_address, delay) = match packet.process(processing_data.read().unwrap().secret_key) { @@ -82,7 +82,7 @@ impl PacketProcessor { Ok(fwd_data) } - async fn wait_and_forward(forwarding_data: ForwardingData<'_>) { + async fn wait_and_forward(forwarding_data: ForwardingData) { let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); println!("client says to wait for {:?}", delay_duration); tokio::time::delay_for(delay_duration).await; From 06540f5ce1bd92e964a13929778897401fa6ec5f Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 12 Dec 2019 19:15:28 +0000 Subject: [PATCH 24/66] node: removing more lifetimes --- src/mix_peer.rs | 2 +- src/node/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mix_peer.rs b/src/mix_peer.rs index c5bacfcf76..6573c448f7 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -5,7 +5,7 @@ pub struct MixPeer { connection: String, } -impl<'a> MixPeer { +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 address = String::from_utf8_lossy(&next_hop_address) diff --git a/src/node/mod.rs b/src/node/mod.rs index 522076389d..1892b6a75a 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -35,7 +35,7 @@ struct ForwardingData { } // TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data -impl<'a> ForwardingData { +impl ForwardingData { fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer) -> Self { ForwardingData { packet, @@ -63,7 +63,7 @@ impl ProcessingData { struct PacketProcessor {} impl PacketProcessor { - pub fn process_sphinx_data_packet<'a>( + pub fn process_sphinx_data_packet( packet_data: &[u8], processing_data: Arc>, ) -> Result { From 07bb0a69fa888cda7ca03eecda0d5063ae419789 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 13 Dec 2019 13:19:26 +0000 Subject: [PATCH 25/66] cargo: newline action --- Cargo.lock | 1232 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 1233 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 5fa6a24b4d..fe3e8fc935 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,10 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "aes-ctr" version = "0.3.0" @@ -31,6 +36,14 @@ dependencies = [ "stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "aho-corasick" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ansi_term" version = "0.11.0" @@ -49,6 +62,11 @@ name = "arrayref" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "arrayvec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "atty" version = "0.2.13" @@ -58,6 +76,44 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "backtrace" +version = "0.3.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bitflags" version = "1.2.1" @@ -74,6 +130,16 @@ dependencies = [ "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "blake2b_simd" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "block-buffer" version = "0.7.3" @@ -111,6 +177,16 @@ name = "byteorder" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bytes" version = "0.5.2" @@ -173,6 +249,108 @@ dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "constant_time_eq" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cookie" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cookie_store" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "publicsuffix 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation-sys" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-queue" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crypto-mac" version = "0.7.0" @@ -211,16 +389,106 @@ dependencies = [ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "dirs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "dirs-sys" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "dtoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "either" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "encoding_rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "error-chain" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "failure" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "failure_derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "flate2" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -240,11 +508,25 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "futures-core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures-cpupool" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "generic-array" version = "0.12.3" @@ -263,6 +545,23 @@ dependencies = [ "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "h2" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hermit-abi" version = "0.1.3" @@ -289,6 +588,101 @@ dependencies = [ "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "http" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "http-body" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hyper" +version = "0.12.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hyper-tls" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "indexmap" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "iovec" version = "0.1.4" @@ -297,6 +691,11 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "itoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -332,6 +731,14 @@ dependencies = [ "keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.8" @@ -340,11 +747,51 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "memchr" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "memoffset" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mime" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "mime_guess" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mio" version = "0.6.21" @@ -404,6 +851,23 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "native-tls" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", + "schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "net2" version = "0.2.33" @@ -423,12 +887,29 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nym-client" +version = "0.1.0" +dependencies = [ + "base64 0.11.0 (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)", + "pem 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sfw-provider-requests 0.1.0", + "sphinx 0.1.0", + "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nym-mixnode" version = "0.1.0" dependencies = [ "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)", + "nym-client 0.1.0", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -438,11 +919,90 @@ name = "opaque-debug" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "openssl" +version = "0.10.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "openssl-sys" +version = "0.9.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pem" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "pin-project-lite" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "pkg-config" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ppv-lite86" version = "0.2.6" @@ -456,6 +1016,18 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "publicsuffix" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quote" version = "1.0.2" @@ -464,6 +1036,24 @@ dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand" version = "0.7.2" @@ -476,6 +1066,15 @@ dependencies = [ "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_chacha" version = "0.2.1" @@ -514,6 +1113,14 @@ dependencies = [ "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -522,6 +1129,24 @@ dependencies = [ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_os" version = "0.1.3" @@ -535,6 +1160,23 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rdrand" version = "0.4.0" @@ -548,6 +1190,194 @@ name = "redox_syscall" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "redox_users" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "remove_dir_all" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "reqwest" +version = "0.9.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rust-argon2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ryu" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "schannel" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "security-framework" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "security-framework-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_json" +version = "1.0.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_urlencoded" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sfw-provider-requests" +version = "0.1.0" +dependencies = [ + "sphinx 0.1.0", +] + [[package]] name = "sha2" version = "0.8.0" @@ -573,6 +1403,19 @@ name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "smallvec" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "socket2" version = "0.3.11" @@ -611,6 +1454,14 @@ dependencies = [ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "string" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "strsim" version = "0.8.0" @@ -636,6 +1487,30 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "synstructure" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -644,6 +1519,42 @@ dependencies = [ "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thread_local" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio" version = "0.2.1" @@ -666,6 +1577,44 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-buf" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-current-thread" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-executor" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-io" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-macros" version = "0.2.0" @@ -675,11 +1624,115 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-reactor" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-sync" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-tcp" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-threadpool" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-timer" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "try-lock" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "try_from" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "typenum" version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unicode-width" version = "0.1.7" @@ -690,11 +1743,64 @@ name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "url" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "vcpkg" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "version_check" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "want" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasi" version = "0.7.0" @@ -729,6 +1835,14 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winreg" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -739,20 +1853,30 @@ dependencies = [ ] [metadata] +"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" +"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" +"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" +"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +"checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +"checksum blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c85319f157e4e26c703678e68e26ab71a46c0199286fa670b21cc9fec13d895" "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" @@ -761,71 +1885,179 @@ dependencies = [ "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" +"checksum cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5" +"checksum cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c" +"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" +"checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" +"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +"checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +"checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" +"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" +"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" +"checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" +"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" +"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" "checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" +"checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" "checksum hkdf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +"checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" +"checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" +"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +"checksum hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +"checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" +"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum lioness 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" +"checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" +"checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" +"checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" +"checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" "checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" +"checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +"checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" +"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +"checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" +"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +"checksum pem 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a1581760c757a756a41f0ee3ff01256227bdf64cb752839779b95ffb01c59793" +"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f0af6cbca0e6e3ce8692ee19fb8d734b641899e07b68eb73e9bbbd32f1703991" +"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" "checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" +"checksum publicsuffix 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3bbaa49075179162b49acac1c6aa45fb4dafb5f13cf6794276d77bc7fd95757b" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" +"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96977acbdd3a6576fb1d27391900035bf3863d4a16422973a409b488cf29ffb2" +"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" +"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" +"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +"checksum reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab" +"checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" +"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" +"checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8ef2429d7cefe5fd28bd1d2ed41c944547d4ff84776f5935b456da44593a16df" +"checksum security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" +"checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" +"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" +"checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +"checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" "checksum stream-cipher 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" "checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" "checksum tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "beeef686ef92a222de07e089f455d9f8478bbba9651718f9e4b276babe829082" +"checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" +"checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" +"checksum tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ca6df436c42b0c3330a82d855d2ef017cd793090ad550a6bc2184f4b933532ab" +"checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-macros 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5795a71419535c6dcecc9b6ca95bdd3c2d6142f7e8343d7beb9923f129aa87e" +"checksum tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6732fe6b53c8d11178dcb77ac6d9682af27fc6d4cb87789449152e5377377146" +"checksum tokio-sync 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d06554cce1ae4a50f42fba8023918afa931413aded705b560e29600ccf7c6d76" +"checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" +"checksum tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c32ffea4827978e9aa392d2f743d973c1dfa3730a2ed3f22ce1e6984da848c" +"checksum tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1739638e364e558128461fc1ad84d997702c8e31c2e6b18fb99842268199e827" +"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +"checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +"checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +"checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" +"checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" +"checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +"checksum want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml index 9095ca85da..2e086e0d31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ edition = "2018" [dependencies] sphinx = { path = "../sphinx" } +nym-client = { path = "../nym-client" } tokio = { version = "0.2", features = ["full"] } curve25519-dalek = "1.2.3" clap = "2.33.0" \ No newline at end of file From 86d27b06df9dd8beee4eaef5c3f9e922753fafc3 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 13 Dec 2019 13:19:40 +0000 Subject: [PATCH 26/66] cargo: depending on the nym-client library --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2e086e0d31..57cb0b3f11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,4 @@ sphinx = { path = "../sphinx" } nym-client = { path = "../nym-client" } tokio = { version = "0.2", features = ["full"] } curve25519-dalek = "1.2.3" -clap = "2.33.0" \ No newline at end of file +clap = "2.33.0" From 1633f54f4f6e4cb71ed38cd87df6e59d13f91dcf Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 13 Dec 2019 13:19:58 +0000 Subject: [PATCH 27/66] node: adding presence notifications (note: doesn't work yet) --- src/node/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/node/mod.rs b/src/node/mod.rs index 1892b6a75a..a024211d6e 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -2,6 +2,13 @@ use std::net::SocketAddr; use std::sync::{Arc, RwLock}; use std::time::Duration; +use nym_client::clients::directory; +use nym_client::clients::directory::presence::MixNodePresence; +use nym_client::clients::directory::requests::presence_mixnodes_post::PresenceMixNodesPoster; +use nym_client::clients::directory::DirectoryClient; + +use tokio::time::{interval_at, Instant, Interval}; + use curve25519_dalek::scalar::Scalar; use sphinx::header::delays::Delay as SphinxDelay; use sphinx::{ProcessedPacket, SphinxPacket}; @@ -165,8 +172,12 @@ impl MixNode { rt.block_on(async { let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; let processing_data = ProcessingData::new(self.secret_key).add_arc_rwlock(); + let (directory, presence, mut presence_timer) = self.setup_presence_timer(); loop { + presence_timer.tick().await; + let response = directory.presence_mix_nodes_post.post(&presence); + println!("response: {:?}", response.unwrap().text()); let (socket, _) = listener.accept().await?; let thread_processing_data = processing_data.clone(); @@ -176,4 +187,21 @@ impl MixNode { } }) } + + fn setup_presence_timer(&self) -> (directory::Client, MixNodePresence, Interval) { + let presence_notifications_start = Instant::now() + Duration::from_nanos(5000); + let presence_notifications_interval = + interval_at(presence_notifications_start, Duration::from_millis(5000)); + let config = directory::Config { + base_url: "https://directory.nymtech.net/".to_string(), + }; + let directory = directory::Client::new(config); + let presence = MixNodePresence { + host: "halpin.org:6666".to_string(), + pub_key: "superkey".to_string(), + layer: 666, + last_seen: 666, + }; + (directory, presence, presence_notifications_interval) + } } From 0b41badab0e8feeb6c14f21216003bc43855f128 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 13 Dec 2019 13:28:31 +0000 Subject: [PATCH 28/66] cargo: alphabetizing --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 57cb0b3f11..21146b0595 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sphinx = { path = "../sphinx" } nym-client = { path = "../nym-client" } +sphinx = { path = "../sphinx" } tokio = { version = "0.2", features = ["full"] } curve25519-dalek = "1.2.3" clap = "2.33.0" From f10a40304580c3e6f5c5fecf673cee46f9185493 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Sat, 14 Dec 2019 14:43:49 +0000 Subject: [PATCH 29/66] cargo: re-ordering --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 21146b0595..737f97603a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = "2.33.0" +curve25519-dalek = "1.2.3" nym-client = { path = "../nym-client" } sphinx = { path = "../sphinx" } tokio = { version = "0.2", features = ["full"] } -curve25519-dalek = "1.2.3" -clap = "2.33.0" From 842c0b10b907e160dfa6b882208320dc83bec007 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Sat, 14 Dec 2019 14:44:07 +0000 Subject: [PATCH 30/66] node: moving presence notification into a thread. --- src/node/mod.rs | 29 +---------------------- src/node/presence_notifier.rs | 44 +++++++++++++++++++++++++++++++++++ src/node/runner.rs | 13 +++++++---- 3 files changed, 54 insertions(+), 32 deletions(-) create mode 100644 src/node/presence_notifier.rs diff --git a/src/node/mod.rs b/src/node/mod.rs index a024211d6e..a6982bc7a9 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -2,13 +2,6 @@ use std::net::SocketAddr; use std::sync::{Arc, RwLock}; use std::time::Duration; -use nym_client::clients::directory; -use nym_client::clients::directory::presence::MixNodePresence; -use nym_client::clients::directory::requests::presence_mixnodes_post::PresenceMixNodesPoster; -use nym_client::clients::directory::DirectoryClient; - -use tokio::time::{interval_at, Instant, Interval}; - use curve25519_dalek::scalar::Scalar; use sphinx::header::delays::Delay as SphinxDelay; use sphinx::{ProcessedPacket, SphinxPacket}; @@ -17,6 +10,7 @@ use tokio::runtime::Runtime; use crate::mix_peer::MixPeer; +mod presence_notifier; pub mod runner; // TODO: this will probably need to be moved elsewhere I imagine @@ -172,12 +166,8 @@ impl MixNode { rt.block_on(async { let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; let processing_data = ProcessingData::new(self.secret_key).add_arc_rwlock(); - let (directory, presence, mut presence_timer) = self.setup_presence_timer(); loop { - presence_timer.tick().await; - let response = directory.presence_mix_nodes_post.post(&presence); - println!("response: {:?}", response.unwrap().text()); let (socket, _) = listener.accept().await?; let thread_processing_data = processing_data.clone(); @@ -187,21 +177,4 @@ impl MixNode { } }) } - - fn setup_presence_timer(&self) -> (directory::Client, MixNodePresence, Interval) { - let presence_notifications_start = Instant::now() + Duration::from_nanos(5000); - let presence_notifications_interval = - interval_at(presence_notifications_start, Duration::from_millis(5000)); - let config = directory::Config { - base_url: "https://directory.nymtech.net/".to_string(), - }; - let directory = directory::Client::new(config); - let presence = MixNodePresence { - host: "halpin.org:6666".to_string(), - pub_key: "superkey".to_string(), - layer: 666, - last_seen: 666, - }; - (directory, presence, presence_notifications_interval) - } } diff --git a/src/node/presence_notifier.rs b/src/node/presence_notifier.rs new file mode 100644 index 0000000000..e89a18a86b --- /dev/null +++ b/src/node/presence_notifier.rs @@ -0,0 +1,44 @@ +use nym_client::clients::directory; +use nym_client::clients::directory::presence::MixNodePresence; +use nym_client::clients::directory::requests::presence_mixnodes_post::PresenceMixNodesPoster; +use nym_client::clients::directory::DirectoryClient; +use std::thread; +use std::time::Duration; + +pub struct PresenceNotifier { + pub net_client: directory::Client, + presence: MixNodePresence, +} + +impl PresenceNotifier { + pub fn new() -> PresenceNotifier { + let config = directory::Config { + base_url: "https://directory.nymtech.net/".to_string(), + }; + let net_client = directory::Client::new(config); + let presence = MixNodePresence { + host: "halpin.org:6666".to_string(), + pub_key: "superkey".to_string(), + layer: 666, + last_seen: 666, + }; + PresenceNotifier { + net_client, + presence, + } + } + + pub fn notify(&self) { + self.net_client + .presence_mix_nodes_post + .post(&self.presence) + .unwrap(); + } + + pub fn run(&self) { + loop { + self.notify(); + thread::sleep(Duration::from_secs(5)); + } + } +} diff --git a/src/node/runner.rs b/src/node/runner.rs index 09b5fafc77..dc0983a9ba 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -1,9 +1,11 @@ use crate::banner; +use crate::node::presence_notifier::PresenceNotifier; use crate::node::MixNode; use clap::ArgMatches; use curve25519_dalek::scalar::Scalar; use std::net::ToSocketAddrs; +use std::thread; pub fn start(matches: &ArgMatches) { println!("{}", banner()); @@ -23,11 +25,11 @@ pub fn start(matches: &ArgMatches) { let secret_key: Scalar = match matches.value_of("keyfile") { Some(keyfile) => { - println!("TODO: load keyfile from <{:?}>", keyfile); + // println!("TODO: load keyfile from <{:?}>", keyfile); Default::default() } None => { - println!("TODO: generate fresh sphinx keypair"); + // println!("TODO: generate fresh sphinx keypair"); Default::default() } }; @@ -38,12 +40,15 @@ pub fn start(matches: &ArgMatches) { .next() .expect("Failed to extract the socket address from the iterator"); + thread::spawn(|| { + let presence_notifier = PresenceNotifier::new(); + presence_notifier.run(); + }); + println!("Startup complete on: {}", socket_address); println!("Listening for incoming packets..."); - // make sure our socket_address is equal to our predefined-hardcoded value // assert_eq!("127.0.0.1:8080", socket_address.to_string()); - let mix = MixNode::new(socket_address, secret_key, layer); mix.start_listening().unwrap(); } From e4cfab537eaf87e26c455f893280e94f982687b8 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Sat, 14 Dec 2019 15:46:53 +0000 Subject: [PATCH 31/66] presence: renamed to non-stutter names --- src/node/mod.rs | 2 +- src/node/{presence_notifier.rs => presence.rs} | 8 ++++---- src/node/runner.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename src/node/{presence_notifier.rs => presence.rs} (90%) diff --git a/src/node/mod.rs b/src/node/mod.rs index a6982bc7a9..2e0ff0ed38 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -10,7 +10,7 @@ use tokio::runtime::Runtime; use crate::mix_peer::MixPeer; -mod presence_notifier; +mod presence; pub mod runner; // TODO: this will probably need to be moved elsewhere I imagine diff --git a/src/node/presence_notifier.rs b/src/node/presence.rs similarity index 90% rename from src/node/presence_notifier.rs rename to src/node/presence.rs index e89a18a86b..3b957ae3da 100644 --- a/src/node/presence_notifier.rs +++ b/src/node/presence.rs @@ -5,13 +5,13 @@ use nym_client::clients::directory::DirectoryClient; use std::thread; use std::time::Duration; -pub struct PresenceNotifier { +pub struct Notifier { pub net_client: directory::Client, presence: MixNodePresence, } -impl PresenceNotifier { - pub fn new() -> PresenceNotifier { +impl Notifier { + pub fn new() -> Notifier { let config = directory::Config { base_url: "https://directory.nymtech.net/".to_string(), }; @@ -22,7 +22,7 @@ impl PresenceNotifier { layer: 666, last_seen: 666, }; - PresenceNotifier { + Notifier { net_client, presence, } diff --git a/src/node/runner.rs b/src/node/runner.rs index dc0983a9ba..4aa98618d3 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -1,5 +1,5 @@ use crate::banner; -use crate::node::presence_notifier::PresenceNotifier; +use crate::node::presence; use crate::node::MixNode; use clap::ArgMatches; @@ -41,8 +41,8 @@ pub fn start(matches: &ArgMatches) { .expect("Failed to extract the socket address from the iterator"); thread::spawn(|| { - let presence_notifier = PresenceNotifier::new(); - presence_notifier.run(); + let notifier = presence::Notifier::new(); + notifier.run(); }); println!("Startup complete on: {}", socket_address); From 233dc5ce9d19d1c7e0732da02ba40e2b501bc480 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 10:28:51 +0000 Subject: [PATCH 32/66] cargo: lockfile including new nym-client dependencies --- Cargo.lock | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index fe3e8fc935..6a1dee22fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,6 +715,11 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lazycell" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.65" @@ -810,6 +815,17 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mio-named-pipes" version = "0.1.6" @@ -901,6 +917,7 @@ dependencies = [ "sfw-provider-requests 0.1.0", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1378,6 +1395,17 @@ dependencies = [ "sphinx 0.1.0", ] +[[package]] +name = "sha-1" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sha2" version = "0.8.0" @@ -1843,6 +1871,23 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ws" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -1938,6 +1983,7 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum lioness 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" @@ -1950,6 +1996,7 @@ dependencies = [ "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +"checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" "checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -2008,6 +2055,7 @@ dependencies = [ "checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" "checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" +"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" @@ -2060,4 +2108,5 @@ dependencies = [ "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +"checksum ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" From f0cf92b542b8be6f7a9c59e637816bd5513e368d Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 11:46:12 +0000 Subject: [PATCH 33/66] cargo: removed ws deps --- Cargo.lock | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a1dee22fe..fe3e8fc935 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,11 +715,6 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.65" @@ -815,17 +810,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mio-extras" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mio-named-pipes" version = "0.1.6" @@ -917,7 +901,6 @@ dependencies = [ "sfw-provider-requests 0.1.0", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1395,17 +1378,6 @@ dependencies = [ "sphinx 0.1.0", ] -[[package]] -name = "sha-1" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "sha2" version = "0.8.0" @@ -1871,23 +1843,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ws" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -1983,7 +1938,6 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum lioness 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" @@ -1996,7 +1950,6 @@ dependencies = [ "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" -"checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" "checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -2055,7 +2008,6 @@ dependencies = [ "checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" "checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" -"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" @@ -2108,5 +2060,4 @@ dependencies = [ "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" -"checksum ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" From 265ef228383a21a0dec1b836ac12cadddae83dc8 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 12:20:48 +0000 Subject: [PATCH 34/66] main: can now be started with a local directory server for testing purposes --- src/main.rs | 6 ++++++ src/node/presence.rs | 9 ++++++--- src/node/runner.rs | 6 ++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index e8c9dc0e0a..86882ebce0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,6 +37,12 @@ fn main() { .long("keyfile") .help("Optional path to the persistent keyfile of the node") .takes_value(true), + ) + .arg( + Arg::with_name("local") + .long("local") + .help("Flag to indicate whether the client is expected to run on a local deployment.") + .takes_value(false), ), ) .get_matches(); diff --git a/src/node/presence.rs b/src/node/presence.rs index 3b957ae3da..dac82d66cc 100644 --- a/src/node/presence.rs +++ b/src/node/presence.rs @@ -11,10 +11,13 @@ pub struct Notifier { } impl Notifier { - pub fn new() -> Notifier { - let config = directory::Config { - base_url: "https://directory.nymtech.net/".to_string(), + pub fn new(is_local: bool) -> Notifier { + let url = if is_local { + "http://localhost:8080".to_string() + } else { + "https://directory.nymtech.net".to_string() }; + let config = directory::Config { base_url: url }; let net_client = directory::Client::new(config); let presence = MixNodePresence { host: "halpin.org:6666".to_string(), diff --git a/src/node/runner.rs b/src/node/runner.rs index 4aa98618d3..e91f0c53cd 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -34,14 +34,16 @@ pub fn start(matches: &ArgMatches) { } }; + let is_local = matches.is_present("local"); + let socket_address = (host, port) .to_socket_addrs() .expect("Failed to combine host and port") .next() .expect("Failed to extract the socket address from the iterator"); - thread::spawn(|| { - let notifier = presence::Notifier::new(); + thread::spawn(move || { + let notifier = presence::Notifier::new(is_local.clone()); notifier.run(); }); From 287d2b31a56a30f492fd20045720b048583ef86e Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 12:54:00 +0000 Subject: [PATCH 35/66] main: deleting unused key_file argument --- src/main.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 86882ebce0..a7f299ab5f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,12 +32,6 @@ fn main() { .takes_value(true) .required(true), ) - .arg( - Arg::with_name("keyfile") - .long("keyfile") - .help("Optional path to the persistent keyfile of the node") - .takes_value(true), - ) .arg( Arg::with_name("local") .long("local") From 2b5b61ea26d929fb425870d54315042aa77a81e1 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 12:54:16 +0000 Subject: [PATCH 36/66] node: adding a config struct --- src/node/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node/mod.rs b/src/node/mod.rs index 2e0ff0ed38..9bb7e6677c 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -13,6 +13,12 @@ use crate::mix_peer::MixPeer; mod presence; pub mod runner; +pub struct Config { + socket_address: SocketAddr, + secret_key: Scalar, + layer: usize, +} + // TODO: this will probably need to be moved elsewhere I imagine #[derive(Debug)] pub enum MixProcessingError { From 9d969904f2f9a58bcd18b92f5d815d96f6393f80 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 13:29:48 +0000 Subject: [PATCH 37/66] cargo: adding base64 crate --- Cargo.lock | 1 + Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index fe3e8fc935..b0bc07bb6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -907,6 +907,7 @@ dependencies = [ name = "nym-mixnode" version = "0.1.0" dependencies = [ + "base64 0.11.0 (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)", "nym-client 0.1.0", diff --git a/Cargo.toml b/Cargo.toml index 737f97603a..47f4f140e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +base64 = "0.11.0" clap = "2.33.0" curve25519-dalek = "1.2.3" nym-client = { path = "../nym-client" } From efb900a538bda36f55fad0cca862ee42c5a4e995 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 13:30:18 +0000 Subject: [PATCH 38/66] node: adding a config struct and using it to pass args around --- src/node/mod.rs | 23 ++++++++++++++------ src/node/presence.rs | 14 ++++++------ src/node/runner.rs | 51 +++++++++++++++++++++++++------------------- 3 files changed, 52 insertions(+), 36 deletions(-) diff --git a/src/node/mod.rs b/src/node/mod.rs index 9bb7e6677c..d79c617291 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -2,6 +2,7 @@ use std::net::SocketAddr; use std::sync::{Arc, RwLock}; use std::time::Duration; +use curve25519_dalek::montgomery::MontgomeryPoint; use curve25519_dalek::scalar::Scalar; use sphinx::header::delays::Delay as SphinxDelay; use sphinx::{ProcessedPacket, SphinxPacket}; @@ -14,9 +15,19 @@ mod presence; pub mod runner; pub struct Config { - socket_address: SocketAddr, - secret_key: Scalar, + directory_server: String, layer: usize, + public_key: MontgomeryPoint, + secret_key: Scalar, + socket_address: SocketAddr, +} + +impl Config { + pub fn public_key_string(&self) -> String { + let key_bytes = self.public_key.to_bytes().to_vec(); + let b64 = base64::encode(&key_bytes); + b64.to_string() + } } // TODO: this will probably need to be moved elsewhere I imagine @@ -119,11 +130,11 @@ pub struct MixNode { } impl MixNode { - pub fn new(network_address: SocketAddr, secret_key: Scalar, layer: usize) -> Self { + pub fn new(config: &Config) -> Self { MixNode { - network_address, - secret_key, - layer, + network_address: config.socket_address, + secret_key: config.secret_key, + layer: config.layer, } } diff --git a/src/node/presence.rs b/src/node/presence.rs index dac82d66cc..3e837c33b9 100644 --- a/src/node/presence.rs +++ b/src/node/presence.rs @@ -1,3 +1,4 @@ +use crate::node; use nym_client::clients::directory; use nym_client::clients::directory::presence::MixNodePresence; use nym_client::clients::directory::requests::presence_mixnodes_post::PresenceMixNodesPoster; @@ -11,17 +12,14 @@ pub struct Notifier { } impl Notifier { - pub fn new(is_local: bool) -> Notifier { - let url = if is_local { - "http://localhost:8080".to_string() - } else { - "https://directory.nymtech.net".to_string() + pub fn new(node_config: &node::Config) -> Notifier { + let config = directory::Config { + base_url: node_config.directory_server.clone(), }; - let config = directory::Config { base_url: url }; let net_client = directory::Client::new(config); let presence = MixNodePresence { - host: "halpin.org:6666".to_string(), - pub_key: "superkey".to_string(), + host: "localhost:6666".to_string(), // send dummy address as the directory server formats the real incoming IP. + pub_key: node_config.public_key_string(), layer: 666, last_seen: 666, }; diff --git a/src/node/runner.rs b/src/node/runner.rs index e91f0c53cd..c841069dd9 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -1,9 +1,9 @@ use crate::banner; +use crate::node; use crate::node::presence; use crate::node::MixNode; use clap::ArgMatches; -use curve25519_dalek::scalar::Scalar; use std::net::ToSocketAddrs; use std::thread; @@ -11,6 +11,20 @@ pub fn start(matches: &ArgMatches) { println!("{}", banner()); println!("Starting mixnode..."); + let config = new_config(matches); + + // println!("Startup on: {}", config.socket_address); + println!("Listening for incoming packets..."); + + let mix = MixNode::new(&config); + thread::spawn(move || { + let notifier = presence::Notifier::new(&config); + notifier.run(); + }); + mix.start_listening().unwrap(); +} + +fn new_config(matches: &ArgMatches) -> node::Config { let host = matches.value_of("host").unwrap_or("0.0.0.0"); let port = match matches.value_of("port").unwrap().parse::() { @@ -23,17 +37,6 @@ pub fn start(matches: &ArgMatches) { Err(err) => panic!("Invalid layer value provided - {:?}", err), }; - let secret_key: Scalar = match matches.value_of("keyfile") { - Some(keyfile) => { - // println!("TODO: load keyfile from <{:?}>", keyfile); - Default::default() - } - None => { - // println!("TODO: generate fresh sphinx keypair"); - Default::default() - } - }; - let is_local = matches.is_present("local"); let socket_address = (host, port) @@ -42,15 +45,19 @@ pub fn start(matches: &ArgMatches) { .next() .expect("Failed to extract the socket address from the iterator"); - thread::spawn(move || { - let notifier = presence::Notifier::new(is_local.clone()); - notifier.run(); - }); + let (secret_key, public_key) = sphinx::crypto::keygen(); - println!("Startup complete on: {}", socket_address); - println!("Listening for incoming packets..."); - // make sure our socket_address is equal to our predefined-hardcoded value - // assert_eq!("127.0.0.1:8080", socket_address.to_string()); - let mix = MixNode::new(socket_address, secret_key, layer); - mix.start_listening().unwrap(); + let directory_server = if is_local { + "http://localhost:8080".to_string() + } else { + "https://directory.nymtech.net".to_string() + }; + + node::Config { + directory_server, + layer, + public_key, + socket_address, + secret_key, + } } From ab02eec82424d42def186944aafab0bb2c26016d Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 13:54:20 +0000 Subject: [PATCH 39/66] Using the node socket address to send to the directory server --- src/node/presence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/presence.rs b/src/node/presence.rs index 3e837c33b9..c2acff1fc2 100644 --- a/src/node/presence.rs +++ b/src/node/presence.rs @@ -18,7 +18,7 @@ impl Notifier { }; let net_client = directory::Client::new(config); let presence = MixNodePresence { - host: "localhost:6666".to_string(), // send dummy address as the directory server formats the real incoming IP. + host: node_config.socket_address.to_string(), // note: the directory server formats the real incoming IP itself pub_key: node_config.public_key_string(), layer: 666, last_seen: 666, From 37a493439d767437a09adf0959ea10ae5d706e3e Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 13:54:38 +0000 Subject: [PATCH 40/66] presence: sending URL-safe public key --- src/node/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/mod.rs b/src/node/mod.rs index d79c617291..36b1674b44 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -25,7 +25,7 @@ pub struct Config { impl Config { pub fn public_key_string(&self) -> String { let key_bytes = self.public_key.to_bytes().to_vec(); - let b64 = base64::encode(&key_bytes); + let b64 = base64::encode_config(&key_bytes, base64::URL_SAFE); b64.to_string() } } From c192afe9ebfaa20afb928e7f353b3abf02cc0ee6 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 16:25:29 +0000 Subject: [PATCH 41/66] mix_peer: converting address to strongly typed socket address --- src/mix_peer.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 6573c448f7..8aab5dda73 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -1,8 +1,9 @@ use std::error::Error; +use std::net::{Ipv4Addr, SocketAddrV4}; use tokio::prelude::*; pub struct MixPeer { - connection: String, + connection: SocketAddrV4, } impl MixPeer { From aa207e2c138b1bf44d47cc77b2b4c15cad3a8fb4 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 16:25:49 +0000 Subject: [PATCH 42/66] mix_peer: using constant sized byte array for addressing --- src/mix_peer.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 8aab5dda73..053961718d 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -9,11 +9,12 @@ pub struct MixPeer { 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 address = String::from_utf8_lossy(&next_hop_address) - .trim_end_matches(char::from(0)) - .to_string(); + 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); MixPeer { - connection: address, + connection: socket_address, } } From ddf0d762d7da440fe6a66a1f7a1a7e6a3bb4c31d Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 16:26:30 +0000 Subject: [PATCH 43/66] mix_peer: adding a to_string() definition --- src/mix_peer.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 053961718d..c2fbde8477 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -24,4 +24,8 @@ impl MixPeer { stream.write_all(&bytes).await?; Ok(()) } + + pub fn to_string(&self) -> String { + self.connection.to_string() + } } From 8cd2be7edc7380859764ba49d2e956781dd0c962 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 16 Dec 2019 16:29:39 +0000 Subject: [PATCH 44/66] cargo: mysterious lock action --- Cargo.lock | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index fe3e8fc935..6a1dee22fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,6 +715,11 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lazycell" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.65" @@ -810,6 +815,17 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mio-named-pipes" version = "0.1.6" @@ -901,6 +917,7 @@ dependencies = [ "sfw-provider-requests 0.1.0", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1378,6 +1395,17 @@ dependencies = [ "sphinx 0.1.0", ] +[[package]] +name = "sha-1" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sha2" version = "0.8.0" @@ -1843,6 +1871,23 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ws" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -1938,6 +1983,7 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum lioness 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" @@ -1950,6 +1996,7 @@ dependencies = [ "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +"checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" "checksum mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" @@ -2008,6 +2055,7 @@ dependencies = [ "checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" "checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" +"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" @@ -2060,4 +2108,5 @@ dependencies = [ "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +"checksum ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a2c47b5798ccc774ffb93ff536aec7c4275d722fd9c740c83cdd1af1f2d94" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" From 3a59f3cef9cabc93eab0d430f9dbaa49fe6899f7 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 16 Dec 2019 17:42:55 +0000 Subject: [PATCH 45/66] Metrics reporting --- Cargo.lock | 132 +++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 1 + src/mix_peer.rs | 2 + src/node/metrics.rs | 86 ++++++++++++++++++++++++++++ src/node/mod.rs | 97 ++++++++++++++++++++++--------- src/node/presence.rs | 2 +- src/node/runner.rs | 2 +- 7 files changed, 283 insertions(+), 39 deletions(-) create mode 100644 src/node/metrics.rs diff --git a/Cargo.lock b/Cargo.lock index 49e150649a..e938994bf7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -273,7 +273,7 @@ dependencies = [ "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "publicsuffix 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -513,6 +513,29 @@ name = "futures" version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "futures-core" version = "0.3.1" @@ -527,6 +550,60 @@ dependencies = [ "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "futures-executor" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "generic-array" version = "0.12.3" @@ -911,9 +988,12 @@ dependencies = [ "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)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "pem 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_distr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "sfw-provider-requests 0.1.0", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -927,6 +1007,7 @@ dependencies = [ "base64 0.11.0 (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)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "nym-client 0.1.0", "sphinx 0.1.0", "tokio 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1016,6 +1097,11 @@ name = "pin-project-lite" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "pkg-config" version = "0.3.17" @@ -1026,6 +1112,21 @@ name = "ppv-lite86" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "1.0.6" @@ -1262,7 +1363,7 @@ dependencies = [ "mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1352,15 +1453,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1375,7 +1476,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1385,7 +1486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1963,8 +2064,16 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" +"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" "checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" +"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" +"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" +"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" +"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" +"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" @@ -2015,8 +2124,11 @@ dependencies = [ "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" "checksum pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f0af6cbca0e6e3ce8692ee19fb8d734b641899e07b68eb73e9bbbd32f1703991" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" "checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum publicsuffix 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3bbaa49075179162b49acac1c6aa45fb4dafb5f13cf6794276d77bc7fd95757b" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" @@ -2052,8 +2164,8 @@ dependencies = [ "checksum security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" -"checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" diff --git a/Cargo.toml b/Cargo.toml index 47f4f140e2..0adfb88178 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" base64 = "0.11.0" clap = "2.33.0" curve25519-dalek = "1.2.3" +futures = "0.3.1" nym-client = { path = "../nym-client" } sphinx = { path = "../sphinx" } tokio = { version = "0.2", features = ["full"] } diff --git a/src/mix_peer.rs b/src/mix_peer.rs index c2fbde8477..0e5b235c29 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -9,6 +9,7 @@ pub struct MixPeer { 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 { + println!("constructing next hop from: {:?}", next_hop_address); 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]]); @@ -26,6 +27,7 @@ impl MixPeer { } pub fn to_string(&self) -> String { + println!("going to report metrics for: {:?}. original: {:?}", self.connection.to_string(), self.connection); self.connection.to_string() } } diff --git a/src/node/metrics.rs b/src/node/metrics.rs new file mode 100644 index 0000000000..afacc9ad08 --- /dev/null +++ b/src/node/metrics.rs @@ -0,0 +1,86 @@ +use std::sync::{RwLock, Arc}; +use futures::lock::Mutex; +use futures::channel::mpsc; +use futures::{StreamExt, SinkExt}; +use std::time::Duration; +use nym_client::clients::directory; +use nym_client::clients::directory::DirectoryClient; +use nym_client::clients::directory::requests::metrics_mixes_post::MetricsMixPoster; +use nym_client::clients::directory::metrics::MixMetric; +use curve25519_dalek::montgomery::MontgomeryPoint; +use std::collections::HashMap; + +const METRICS_INTERVAL: u64 = 3; + +#[derive(Debug)] +pub struct MetricsReporter { + received: u64, + sent: HashMap +} + +impl MetricsReporter { + pub(crate) fn new() -> Self { + MetricsReporter{ + received: 0, + sent: HashMap::new(), + } + } + + pub(crate) fn add_arc_mutex(self) -> Arc> { + Arc::new(Mutex::new(self)) + } + + async fn increment_received_metrics(mut metrics: Arc>) { + let mut unlocked = metrics.lock().await; + unlocked.received += 1; + println!("new metrics: {:?}", unlocked); + } + + pub(crate) async fn run_received_metrics_control(metrics: Arc>, mut rx: mpsc::Receiver<()>) { + while let Some(received_metric) = rx.next().await { + println!("[METRIC] - received new packet!"); + MetricsReporter::increment_received_metrics(metrics.clone()).await; + } + } + + async fn increment_sent_metrics(mut metrics: Arc>, sent_to: String) { + let mut unlocked = metrics.lock().await; + let receiver_count = unlocked.sent.entry(sent_to).or_insert(0); + *receiver_count += 1; + +// unlocked.sent += 1; + println!("new metrics: {:?}", unlocked); + } + + pub(crate) async fn run_sent_metrics_control(metrics: Arc>, mut rx: mpsc::Receiver) { + while let Some(sent_metric) = rx.next().await { + println!("[METRIC] - sent new packet!"); + MetricsReporter::increment_sent_metrics(metrics.clone(), sent_metric).await; + } + } + + async fn acquire_and_reset_metrics(mut metrics: Arc>) -> (u64, HashMap) { + let mut unlocked = metrics.lock().await; + let received = unlocked.received; + + println!("RESETTING METRICS!"); + let sent = std::mem::replace(&mut unlocked.sent, HashMap::new()); + unlocked.received = 0; + + (received, sent) + } + + pub(crate) async fn run_metrics_sender(metrics: Arc>, cfg: directory::Config, pub_key_str: String) { + let delay_duration = Duration::from_secs(METRICS_INTERVAL); + let directory_client= directory::Client::new(cfg); + loop { + tokio::time::delay_for(delay_duration).await; + let (received, sent) = MetricsReporter::acquire_and_reset_metrics(metrics.clone()).await; + directory_client.metrics_post.post(&MixMetric{ + pub_key: pub_key_str.clone(), + received, + sent, + }); + } + } +} diff --git a/src/node/mod.rs b/src/node/mod.rs index 36b1674b44..776259248c 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -1,18 +1,23 @@ use std::net::SocketAddr; use std::sync::{Arc, RwLock}; use std::time::Duration; - +use futures::channel::mpsc; use curve25519_dalek::montgomery::MontgomeryPoint; use curve25519_dalek::scalar::Scalar; use sphinx::header::delays::Delay as SphinxDelay; use sphinx::{ProcessedPacket, SphinxPacket}; use tokio::prelude::*; use tokio::runtime::Runtime; +use futures::lock::Mutex; use crate::mix_peer::MixPeer; +use crate::node::metrics::MetricsReporter; +use futures::SinkExt; +use nym_client::clients::directory; mod presence; pub mod runner; +mod metrics; pub struct Config { directory_server: String, @@ -25,8 +30,7 @@ pub struct Config { impl Config { pub fn public_key_string(&self) -> String { let key_bytes = self.public_key.to_bytes().to_vec(); - let b64 = base64::encode_config(&key_bytes, base64::URL_SAFE); - b64.to_string() + base64::encode_config(&key_bytes, base64::URL_SAFE) } } @@ -50,15 +54,18 @@ struct ForwardingData { packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer, + sent_metrics_tx: mpsc::Sender, } // TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data impl ForwardingData { - fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer) -> Self { + fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer, sent_metrics_tx: mpsc::Sender, + ) -> Self { ForwardingData { packet, delay, recipient, + sent_metrics_tx, } } } @@ -66,28 +73,36 @@ impl ForwardingData { // ProcessingData defines all data required to correctly unwrap sphinx packets struct ProcessingData { secret_key: Scalar, + received_metrics_tx: mpsc::Sender<()>, + sent_metrics_tx: mpsc::Sender, } impl ProcessingData { - fn new(secret_key: Scalar) -> Self { - ProcessingData { secret_key } + fn new(secret_key: Scalar, received_metrics_tx: mpsc::Sender<()>, sent_metrics_tx: mpsc::Sender) -> Self { + ProcessingData { secret_key, received_metrics_tx, sent_metrics_tx } } - fn add_arc_rwlock(self) -> Arc> { - Arc::new(RwLock::new(self)) + fn add_arc_mutex(self) -> Arc> { + Arc::new(Mutex::new(self)) } } struct PacketProcessor {} impl PacketProcessor { - pub fn process_sphinx_data_packet( + pub async fn process_sphinx_data_packet( packet_data: &[u8], - processing_data: Arc>, + processing_data: Arc>, ) -> Result { + // we received something resembling a sphinx packet, report it! + let processing_data = processing_data.lock().await; + let mut received_sender = processing_data.received_metrics_tx.clone(); + + received_sender.send(()).await; + let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; let (next_packet, next_hop_address, delay) = - match packet.process(processing_data.read().unwrap().secret_key) { + match packet.process(processing_data.secret_key) { ProcessedPacket::ProcessedPacketForwardHop(packet, address, delay) => { (packet, address, delay) } @@ -96,35 +111,38 @@ impl PacketProcessor { let next_mix = MixPeer::new(next_hop_address); - let fwd_data = ForwardingData::new(next_packet, delay, next_mix); + let fwd_data = ForwardingData::new(next_packet, delay, next_mix, processing_data.sent_metrics_tx.clone()); Ok(fwd_data) } - async fn wait_and_forward(forwarding_data: ForwardingData) { + async fn wait_and_forward(mut forwarding_data: ForwardingData) { let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); println!("client says to wait for {:?}", delay_duration); tokio::time::delay_for(delay_duration).await; - println!("waited {:?} - time to forward the packet!", delay_duration); + println!("waited {:?} - time to forward the packet! (and update metrics!)", delay_duration); + forwarding_data.sent_metrics_tx.send(forwarding_data.recipient.to_string()).await; match forwarding_data .recipient .send(forwarding_data.packet.to_bytes()) .await - { - Ok(()) => (), - Err(e) => { - println!( - "failed to write bytes to next mix peer. err = {:?}", - e.to_string() - ); + { + Ok(()) => (), + Err(e) => { + println!( + "failed to write bytes to next mix peer. err = {:?}", + e.to_string() + ); + } } - } } } // the MixNode will live for whole duration of this program pub struct MixNode { + directory_server: String, network_address: SocketAddr, + public_key: MontgomeryPoint, secret_key: Scalar, layer: usize, } @@ -132,15 +150,17 @@ pub struct MixNode { impl MixNode { pub fn new(config: &Config) -> Self { MixNode { + directory_server: config.directory_server.clone(), network_address: config.socket_address, secret_key: config.secret_key, + public_key: config.public_key, layer: config.layer, } } async fn process_socket_connection( mut socket: tokio::net::TcpStream, - processing_data: Arc>, + processing_data: Arc>, ) { // NOTE: processing_data is copied here!! let mut buf = [0u8; sphinx::PACKET_SIZE]; @@ -157,8 +177,8 @@ impl MixNode { let fwd_data = PacketProcessor::process_sphinx_data_packet( buf.as_ref(), processing_data.clone(), - ) - .unwrap(); + ).await + .unwrap(); PacketProcessor::wait_and_forward(fwd_data).await; } Err(e) => { @@ -175,14 +195,37 @@ impl MixNode { } } - pub fn start_listening(&self) -> Result<(), Box> { + pub fn start(&self) -> Result<(), Box> { // Create the runtime, probably later move it to MixNode itself? let mut rt = Runtime::new()?; + let (received_tx, received_rx) = mpsc::channel(1024); + let (sent_tx, sent_rx) = mpsc::channel(1024); + + let directory_cfg = directory::Config { base_url: self.directory_server.clone() }; + let pub_key_str = base64::encode_config(&self.public_key.to_bytes().to_vec(), base64::URL_SAFE); + + let metrics = MetricsReporter::new().add_arc_mutex(); + rt.spawn(MetricsReporter::run_received_metrics_control(metrics.clone(), received_rx)); + rt.spawn(MetricsReporter::run_sent_metrics_control(metrics.clone(), sent_rx)); + rt.spawn(MetricsReporter::run_metrics_sender(metrics, directory_cfg, pub_key_str)); +// let mut foo = received_tx.clone(); +// let mut bar = sent_tx.clone(); + // let's increase some metrics! +// rt.spawn(async move { +// loop { +// tokio::time::delay_for(Duration::from_secs(2)).await; +// foo.send(()).await; +// bar.send("bar".to_string()).await; +// foo.send(()).await; +// } +// }); +// let (sent_tx, sent_rx) = mpsc::channel(1024); + // Spawn the root task rt.block_on(async { let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; - let processing_data = ProcessingData::new(self.secret_key).add_arc_rwlock(); + let processing_data = ProcessingData::new(self.secret_key, received_tx, sent_tx).add_arc_mutex(); loop { let (socket, _) = listener.accept().await?; diff --git a/src/node/presence.rs b/src/node/presence.rs index c2acff1fc2..848cb70e06 100644 --- a/src/node/presence.rs +++ b/src/node/presence.rs @@ -20,7 +20,7 @@ impl Notifier { let presence = MixNodePresence { host: node_config.socket_address.to_string(), // note: the directory server formats the real incoming IP itself pub_key: node_config.public_key_string(), - layer: 666, + layer: node_config.layer as u64, last_seen: 666, }; Notifier { diff --git a/src/node/runner.rs b/src/node/runner.rs index c841069dd9..3823592084 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -21,7 +21,7 @@ pub fn start(matches: &ArgMatches) { let notifier = presence::Notifier::new(&config); notifier.run(); }); - mix.start_listening().unwrap(); + mix.start().unwrap(); } fn new_config(matches: &ArgMatches) -> node::Config { From 724af12e0304b4a67e3c147272b0a9c5c97ae532 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 16 Dec 2019 17:45:06 +0000 Subject: [PATCH 46/66] Removed debug prints --- src/mix_peer.rs | 2 -- src/node/metrics.rs | 7 ------- src/node/mod.rs | 2 -- 3 files changed, 11 deletions(-) diff --git a/src/mix_peer.rs b/src/mix_peer.rs index 0e5b235c29..c2fbde8477 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -9,7 +9,6 @@ pub struct MixPeer { 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 { - println!("constructing next hop from: {:?}", next_hop_address); 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]]); @@ -27,7 +26,6 @@ impl MixPeer { } pub fn to_string(&self) -> String { - println!("going to report metrics for: {:?}. original: {:?}", self.connection.to_string(), self.connection); self.connection.to_string() } } diff --git a/src/node/metrics.rs b/src/node/metrics.rs index afacc9ad08..dd8399a236 100644 --- a/src/node/metrics.rs +++ b/src/node/metrics.rs @@ -33,12 +33,10 @@ impl MetricsReporter { async fn increment_received_metrics(mut metrics: Arc>) { let mut unlocked = metrics.lock().await; unlocked.received += 1; - println!("new metrics: {:?}", unlocked); } pub(crate) async fn run_received_metrics_control(metrics: Arc>, mut rx: mpsc::Receiver<()>) { while let Some(received_metric) = rx.next().await { - println!("[METRIC] - received new packet!"); MetricsReporter::increment_received_metrics(metrics.clone()).await; } } @@ -47,14 +45,10 @@ impl MetricsReporter { let mut unlocked = metrics.lock().await; let receiver_count = unlocked.sent.entry(sent_to).or_insert(0); *receiver_count += 1; - -// unlocked.sent += 1; - println!("new metrics: {:?}", unlocked); } pub(crate) async fn run_sent_metrics_control(metrics: Arc>, mut rx: mpsc::Receiver) { while let Some(sent_metric) = rx.next().await { - println!("[METRIC] - sent new packet!"); MetricsReporter::increment_sent_metrics(metrics.clone(), sent_metric).await; } } @@ -63,7 +57,6 @@ impl MetricsReporter { let mut unlocked = metrics.lock().await; let received = unlocked.received; - println!("RESETTING METRICS!"); let sent = std::mem::replace(&mut unlocked.sent, HashMap::new()); unlocked.received = 0; diff --git a/src/node/mod.rs b/src/node/mod.rs index 776259248c..44d70308bf 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -117,9 +117,7 @@ impl PacketProcessor { async fn wait_and_forward(mut forwarding_data: ForwardingData) { let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); - println!("client says to wait for {:?}", delay_duration); tokio::time::delay_for(delay_duration).await; - println!("waited {:?} - time to forward the packet! (and update metrics!)", delay_duration); forwarding_data.sent_metrics_tx.send(forwarding_data.recipient.to_string()).await; match forwarding_data From f262b2924b03770302b25eb239ad10e779e218e8 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 16 Dec 2019 17:59:09 +0000 Subject: [PATCH 47/66] Fixed some compiler warnings --- src/node/metrics.rs | 15 +++++++-------- src/node/mod.rs | 25 ++++++++----------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/node/metrics.rs b/src/node/metrics.rs index dd8399a236..06ad69e327 100644 --- a/src/node/metrics.rs +++ b/src/node/metrics.rs @@ -1,13 +1,12 @@ -use std::sync::{RwLock, Arc}; +use std::sync::Arc; use futures::lock::Mutex; use futures::channel::mpsc; -use futures::{StreamExt, SinkExt}; +use futures::StreamExt; use std::time::Duration; use nym_client::clients::directory; use nym_client::clients::directory::DirectoryClient; use nym_client::clients::directory::requests::metrics_mixes_post::MetricsMixPoster; use nym_client::clients::directory::metrics::MixMetric; -use curve25519_dalek::montgomery::MontgomeryPoint; use std::collections::HashMap; const METRICS_INTERVAL: u64 = 3; @@ -30,18 +29,18 @@ impl MetricsReporter { Arc::new(Mutex::new(self)) } - async fn increment_received_metrics(mut metrics: Arc>) { + async fn increment_received_metrics(metrics: Arc>) { let mut unlocked = metrics.lock().await; unlocked.received += 1; } pub(crate) async fn run_received_metrics_control(metrics: Arc>, mut rx: mpsc::Receiver<()>) { - while let Some(received_metric) = rx.next().await { + while let Some(_) = rx.next().await { MetricsReporter::increment_received_metrics(metrics.clone()).await; } } - async fn increment_sent_metrics(mut metrics: Arc>, sent_to: String) { + async fn increment_sent_metrics(metrics: Arc>, sent_to: String) { let mut unlocked = metrics.lock().await; let receiver_count = unlocked.sent.entry(sent_to).or_insert(0); *receiver_count += 1; @@ -53,7 +52,7 @@ impl MetricsReporter { } } - async fn acquire_and_reset_metrics(mut metrics: Arc>) -> (u64, HashMap) { + async fn acquire_and_reset_metrics(metrics: Arc>) -> (u64, HashMap) { let mut unlocked = metrics.lock().await; let received = unlocked.received; @@ -73,7 +72,7 @@ impl MetricsReporter { pub_key: pub_key_str.clone(), received, sent, - }); + }).unwrap(); } } } diff --git a/src/node/mod.rs b/src/node/mod.rs index 44d70308bf..5c018d5dbf 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -1,5 +1,5 @@ use std::net::SocketAddr; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; use std::time::Duration; use futures::channel::mpsc; use curve25519_dalek::montgomery::MontgomeryPoint; @@ -98,7 +98,7 @@ impl PacketProcessor { let processing_data = processing_data.lock().await; let mut received_sender = processing_data.received_metrics_tx.clone(); - received_sender.send(()).await; + received_sender.send(()).await.unwrap(); let packet = SphinxPacket::from_bytes(packet_data.to_vec())?; let (next_packet, next_hop_address, delay) = @@ -118,7 +118,7 @@ impl PacketProcessor { async fn wait_and_forward(mut forwarding_data: ForwardingData) { let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); tokio::time::delay_for(delay_duration).await; - forwarding_data.sent_metrics_tx.send(forwarding_data.recipient.to_string()).await; + forwarding_data.sent_metrics_tx.send(forwarding_data.recipient.to_string()).await.unwrap(); match forwarding_data .recipient @@ -142,7 +142,9 @@ pub struct MixNode { network_address: SocketAddr, public_key: MontgomeryPoint, secret_key: Scalar, - layer: usize, + +// TODO: use it later to enforce forward travel +// layer: usize, } impl MixNode { @@ -152,7 +154,7 @@ impl MixNode { network_address: config.socket_address, secret_key: config.secret_key, public_key: config.public_key, - layer: config.layer, +// layer: config.layer, } } @@ -207,18 +209,7 @@ impl MixNode { rt.spawn(MetricsReporter::run_received_metrics_control(metrics.clone(), received_rx)); rt.spawn(MetricsReporter::run_sent_metrics_control(metrics.clone(), sent_rx)); rt.spawn(MetricsReporter::run_metrics_sender(metrics, directory_cfg, pub_key_str)); -// let mut foo = received_tx.clone(); -// let mut bar = sent_tx.clone(); - // let's increase some metrics! -// rt.spawn(async move { -// loop { -// tokio::time::delay_for(Duration::from_secs(2)).await; -// foo.send(()).await; -// bar.send("bar".to_string()).await; -// foo.send(()).await; -// } -// }); -// let (sent_tx, sent_rx) = mpsc::channel(1024); + // Spawn the root task rt.block_on(async { From b6db1bf1af15e82504611a98da300468a8d1e181 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 17 Dec 2019 10:11:14 +0000 Subject: [PATCH 48/66] presence: removing last-seen from MixNodePresence, it's set by server --- src/node/presence.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node/presence.rs b/src/node/presence.rs index c2acff1fc2..4842547f13 100644 --- a/src/node/presence.rs +++ b/src/node/presence.rs @@ -20,8 +20,7 @@ impl Notifier { let presence = MixNodePresence { host: node_config.socket_address.to_string(), // note: the directory server formats the real incoming IP itself pub_key: node_config.public_key_string(), - layer: 666, - last_seen: 666, + layer: node_config.layer as u64, }; Notifier { net_client, From ae25f335f4608935b43e76cf5d6ac68e13fea162 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 17 Dec 2019 13:29:29 +0000 Subject: [PATCH 49/66] mix_peer: adding Debug so we can print --- src/mix_peer.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mix_peer.rs b/src/mix_peer.rs index c2fbde8477..64cbe02ed7 100644 --- a/src/mix_peer.rs +++ b/src/mix_peer.rs @@ -2,6 +2,7 @@ use std::error::Error; use std::net::{Ipv4Addr, SocketAddrV4}; use tokio::prelude::*; +#[derive(Debug)] pub struct MixPeer { connection: SocketAddrV4, } From c71f49497484391fbe4a951812978230ff0f2ae8 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 17 Dec 2019 13:29:59 +0000 Subject: [PATCH 50/66] presence: comment re directory server --- src/node/presence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/presence.rs b/src/node/presence.rs index 848cb70e06..49fc0be047 100644 --- a/src/node/presence.rs +++ b/src/node/presence.rs @@ -18,7 +18,7 @@ impl Notifier { }; let net_client = directory::Client::new(config); let presence = MixNodePresence { - host: node_config.socket_address.to_string(), // note: the directory server formats the real incoming IP itself + host: node_config.socket_address.to_string(), // note: the directory server determines the real incoming IP itself, but uses the socket. Host here is just a placeholder. pub_key: node_config.public_key_string(), layer: node_config.layer as u64, last_seen: 666, From 65aa1ba29d441edc41dd3f27e1afe63c29e88d88 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Tue, 17 Dec 2019 13:32:29 +0000 Subject: [PATCH 51/66] rustfmt --- src/node/mod.rs | 102 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 34 deletions(-) diff --git a/src/node/mod.rs b/src/node/mod.rs index 5c018d5dbf..9284d346e6 100644 --- a/src/node/mod.rs +++ b/src/node/mod.rs @@ -1,23 +1,23 @@ +use curve25519_dalek::montgomery::MontgomeryPoint; +use curve25519_dalek::scalar::Scalar; +use futures::channel::mpsc; +use futures::lock::Mutex; +use sphinx::header::delays::Delay as SphinxDelay; +use sphinx::{ProcessedPacket, SphinxPacket}; use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; -use futures::channel::mpsc; -use curve25519_dalek::montgomery::MontgomeryPoint; -use curve25519_dalek::scalar::Scalar; -use sphinx::header::delays::Delay as SphinxDelay; -use sphinx::{ProcessedPacket, SphinxPacket}; use tokio::prelude::*; use tokio::runtime::Runtime; -use futures::lock::Mutex; use crate::mix_peer::MixPeer; use crate::node::metrics::MetricsReporter; use futures::SinkExt; use nym_client::clients::directory; +mod metrics; mod presence; pub mod runner; -mod metrics; pub struct Config { directory_server: String, @@ -34,7 +34,6 @@ impl Config { } } -// TODO: this will probably need to be moved elsewhere I imagine #[derive(Debug)] pub enum MixProcessingError { SphinxRecoveryError, @@ -59,7 +58,11 @@ struct ForwardingData { // TODO: this will need to be changed if MixPeer will live longer than our Forwarding Data impl ForwardingData { - fn new(packet: SphinxPacket, delay: SphinxDelay, recipient: MixPeer, sent_metrics_tx: mpsc::Sender, + fn new( + packet: SphinxPacket, + delay: SphinxDelay, + recipient: MixPeer, + sent_metrics_tx: mpsc::Sender, ) -> Self { ForwardingData { packet, @@ -78,8 +81,16 @@ struct ProcessingData { } impl ProcessingData { - fn new(secret_key: Scalar, received_metrics_tx: mpsc::Sender<()>, sent_metrics_tx: mpsc::Sender) -> Self { - ProcessingData { secret_key, received_metrics_tx, sent_metrics_tx } + fn new( + secret_key: Scalar, + received_metrics_tx: mpsc::Sender<()>, + sent_metrics_tx: mpsc::Sender, + ) -> Self { + ProcessingData { + secret_key, + received_metrics_tx, + sent_metrics_tx, + } } fn add_arc_mutex(self) -> Arc> { @@ -111,28 +122,38 @@ impl PacketProcessor { let next_mix = MixPeer::new(next_hop_address); - let fwd_data = ForwardingData::new(next_packet, delay, next_mix, processing_data.sent_metrics_tx.clone()); + let fwd_data = ForwardingData::new( + next_packet, + delay, + next_mix, + processing_data.sent_metrics_tx.clone(), + ); Ok(fwd_data) } async fn wait_and_forward(mut forwarding_data: ForwardingData) { let delay_duration = Duration::from_nanos(forwarding_data.delay.get_value()); tokio::time::delay_for(delay_duration).await; - forwarding_data.sent_metrics_tx.send(forwarding_data.recipient.to_string()).await.unwrap(); + forwarding_data + .sent_metrics_tx + .send(forwarding_data.recipient.to_string()) + .await + .unwrap(); + println!("RECIPIENT: {:?}", forwarding_data.recipient); match forwarding_data .recipient .send(forwarding_data.packet.to_bytes()) .await - { - Ok(()) => (), - Err(e) => { - println!( - "failed to write bytes to next mix peer. err = {:?}", - e.to_string() - ); - } + { + Ok(()) => (), + Err(e) => { + println!( + "failed to write bytes to next mix peer. err = {:?}", + e.to_string() + ); } + } } } @@ -142,9 +163,8 @@ pub struct MixNode { network_address: SocketAddr, public_key: MontgomeryPoint, secret_key: Scalar, - -// TODO: use it later to enforce forward travel -// layer: usize, + // TODO: use it later to enforce forward travel + // layer: usize, } impl MixNode { @@ -154,7 +174,7 @@ impl MixNode { network_address: config.socket_address, secret_key: config.secret_key, public_key: config.public_key, -// layer: config.layer, + // layer: config.layer, } } @@ -177,8 +197,9 @@ impl MixNode { let fwd_data = PacketProcessor::process_sphinx_data_packet( buf.as_ref(), processing_data.clone(), - ).await - .unwrap(); + ) + .await + .unwrap(); PacketProcessor::wait_and_forward(fwd_data).await; } Err(e) => { @@ -202,19 +223,32 @@ impl MixNode { let (received_tx, received_rx) = mpsc::channel(1024); let (sent_tx, sent_rx) = mpsc::channel(1024); - let directory_cfg = directory::Config { base_url: self.directory_server.clone() }; - let pub_key_str = base64::encode_config(&self.public_key.to_bytes().to_vec(), base64::URL_SAFE); + let directory_cfg = directory::Config { + base_url: self.directory_server.clone(), + }; + let pub_key_str = + base64::encode_config(&self.public_key.to_bytes().to_vec(), base64::URL_SAFE); let metrics = MetricsReporter::new().add_arc_mutex(); - rt.spawn(MetricsReporter::run_received_metrics_control(metrics.clone(), received_rx)); - rt.spawn(MetricsReporter::run_sent_metrics_control(metrics.clone(), sent_rx)); - rt.spawn(MetricsReporter::run_metrics_sender(metrics, directory_cfg, pub_key_str)); - + rt.spawn(MetricsReporter::run_received_metrics_control( + metrics.clone(), + received_rx, + )); + rt.spawn(MetricsReporter::run_sent_metrics_control( + metrics.clone(), + sent_rx, + )); + rt.spawn(MetricsReporter::run_metrics_sender( + metrics, + directory_cfg, + pub_key_str, + )); // Spawn the root task rt.block_on(async { let mut listener = tokio::net::TcpListener::bind(self.network_address).await?; - let processing_data = ProcessingData::new(self.secret_key, received_tx, sent_tx).add_arc_mutex(); + let processing_data = + ProcessingData::new(self.secret_key, received_tx, sent_tx).add_arc_mutex(); loop { let (socket, _) = listener.accept().await?; From 234bf7d0a0ea4e5e40ed71726a342014d7c965da Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 19 Dec 2019 11:50:47 +0000 Subject: [PATCH 52/66] cargo fmt run --- src/node/metrics.rs | 52 +++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/node/metrics.rs b/src/node/metrics.rs index 06ad69e327..8b60c08569 100644 --- a/src/node/metrics.rs +++ b/src/node/metrics.rs @@ -1,25 +1,25 @@ -use std::sync::Arc; -use futures::lock::Mutex; use futures::channel::mpsc; +use futures::lock::Mutex; use futures::StreamExt; -use std::time::Duration; use nym_client::clients::directory; -use nym_client::clients::directory::DirectoryClient; -use nym_client::clients::directory::requests::metrics_mixes_post::MetricsMixPoster; use nym_client::clients::directory::metrics::MixMetric; +use nym_client::clients::directory::requests::metrics_mixes_post::MetricsMixPoster; +use nym_client::clients::directory::DirectoryClient; use std::collections::HashMap; +use std::sync::Arc; +use std::time::Duration; const METRICS_INTERVAL: u64 = 3; #[derive(Debug)] pub struct MetricsReporter { received: u64, - sent: HashMap + sent: HashMap, } impl MetricsReporter { pub(crate) fn new() -> Self { - MetricsReporter{ + MetricsReporter { received: 0, sent: HashMap::new(), } @@ -34,7 +34,10 @@ impl MetricsReporter { unlocked.received += 1; } - pub(crate) async fn run_received_metrics_control(metrics: Arc>, mut rx: mpsc::Receiver<()>) { + pub(crate) async fn run_received_metrics_control( + metrics: Arc>, + mut rx: mpsc::Receiver<()>, + ) { while let Some(_) = rx.next().await { MetricsReporter::increment_received_metrics(metrics.clone()).await; } @@ -46,13 +49,18 @@ impl MetricsReporter { *receiver_count += 1; } - pub(crate) async fn run_sent_metrics_control(metrics: Arc>, mut rx: mpsc::Receiver) { + pub(crate) async fn run_sent_metrics_control( + metrics: Arc>, + mut rx: mpsc::Receiver, + ) { while let Some(sent_metric) = rx.next().await { MetricsReporter::increment_sent_metrics(metrics.clone(), sent_metric).await; } } - async fn acquire_and_reset_metrics(metrics: Arc>) -> (u64, HashMap) { + async fn acquire_and_reset_metrics( + metrics: Arc>, + ) -> (u64, HashMap) { let mut unlocked = metrics.lock().await; let received = unlocked.received; @@ -62,17 +70,25 @@ impl MetricsReporter { (received, sent) } - pub(crate) async fn run_metrics_sender(metrics: Arc>, cfg: directory::Config, pub_key_str: String) { + pub(crate) async fn run_metrics_sender( + metrics: Arc>, + cfg: directory::Config, + pub_key_str: String, + ) { let delay_duration = Duration::from_secs(METRICS_INTERVAL); - let directory_client= directory::Client::new(cfg); + let directory_client = directory::Client::new(cfg); loop { tokio::time::delay_for(delay_duration).await; - let (received, sent) = MetricsReporter::acquire_and_reset_metrics(metrics.clone()).await; - directory_client.metrics_post.post(&MixMetric{ - pub_key: pub_key_str.clone(), - received, - sent, - }).unwrap(); + let (received, sent) = + MetricsReporter::acquire_and_reset_metrics(metrics.clone()).await; + directory_client + .metrics_post + .post(&MixMetric { + pub_key: pub_key_str.clone(), + received, + sent, + }) + .unwrap(); } } } From 1954895e16bd93e5793178c3db76dfb22ca07627 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 20 Dec 2019 14:53:57 +0000 Subject: [PATCH 53/66] Building out the README a bit. --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0329495058..140aa9b552 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ -# nym-mixnode -A Rust mixnode implementation +# Nym Mixnode + +A Rust mixnode implementation. + +## Building + +* check out the code +* install rust (stable) +* `cargo build --release` (for a production build) + +The built binary can be found at `target/release/nym-mixnode` + +## Usage + +* `nym-mixnode` prints a help message showing usage options +* `nym-mixnode run --help` prints a help message showing usage options for the run command +* `nym-mixnode run --layer 1` will start the mixnode in layer 1 (coordinate with other people to find out which layer you need to start yours in) + +By default, the Nym Mixnode will start on port 1789. If desired, you can change the port using the `--port` option. From a39eed123e957880598907af05ba90f94a70d9e5 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 20 Dec 2019 14:54:48 +0000 Subject: [PATCH 54/66] main: setting a default port (1789) --- src/main.rs | 1 - src/node/runner.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index a7f299ab5f..e3b9d32ee4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,6 @@ fn main() { .long("port") .help("The port on which the mixnode will be listening") .takes_value(true) - .required(true), ) .arg( Arg::with_name("layer") diff --git a/src/node/runner.rs b/src/node/runner.rs index 3823592084..c33dfa453c 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -27,7 +27,7 @@ pub fn start(matches: &ArgMatches) { fn new_config(matches: &ArgMatches) -> node::Config { let host = matches.value_of("host").unwrap_or("0.0.0.0"); - let port = match matches.value_of("port").unwrap().parse::() { + let port = match matches.value_of("port").unwrap_or("1789").parse::() { Ok(n) => n, Err(err) => panic!("Invalid port value provided - {:?}", err), }; From 42ab21c1337e65183a0c57173c103051a26a3cd6 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 20 Dec 2019 14:57:07 +0000 Subject: [PATCH 55/66] whitespace --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 140aa9b552..916786e865 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,4 @@ The built binary can be found at `target/release/nym-mixnode` * `nym-mixnode run --help` prints a help message showing usage options for the run command * `nym-mixnode run --layer 1` will start the mixnode in layer 1 (coordinate with other people to find out which layer you need to start yours in) -By default, the Nym Mixnode will start on port 1789. If desired, you can change the port using the `--port` option. +By default, the Nym Mixnode will start on port 1789. If desired, you can change the port using the `--port` option. From 21f0c3e2ac973b2fb6ff1340e626cdc1275290c9 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Fri, 20 Dec 2019 14:57:18 +0000 Subject: [PATCH 56/66] Including a pointer to the Rust install docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 916786e865..633c7cda48 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A Rust mixnode implementation. ## Building * check out the code -* install rust (stable) +* [install rust](https://www.rust-lang.org/tools/install) (stable) * `cargo build --release` (for a production build) The built binary can be found at `target/release/nym-mixnode` From b59b9fa4a5b3620814cd25fc2800bd59684c692b Mon Sep 17 00:00:00 2001 From: 0xjac Date: Sun, 29 Dec 2019 16:13:32 +0100 Subject: [PATCH 57/66] runner: print public key on startup Closes #19 --- src/node/runner.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node/runner.rs b/src/node/runner.rs index c33dfa453c..372dcccd74 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -12,6 +12,7 @@ pub fn start(matches: &ArgMatches) { println!("Starting mixnode..."); let config = new_config(matches); + println!("Public key: {}", config.public_key_string()); // println!("Startup on: {}", config.socket_address); println!("Listening for incoming packets..."); From cddc61fe578356c223217424ae6a825c1d663b7d Mon Sep 17 00:00:00 2001 From: mileschet Date: Sun, 29 Dec 2019 17:07:41 +0100 Subject: [PATCH 58/66] updated readme with dependencies instructions added some information about the dependencies until we fix cargo dependencies. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 633c7cda48..bcb89473ea 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,11 @@ The built binary can be found at `target/release/nym-mixnode` * `nym-mixnode run --layer 1` will start the mixnode in layer 1 (coordinate with other people to find out which layer you need to start yours in) By default, the Nym Mixnode will start on port 1789. If desired, you can change the port using the `--port` option. + +### Dependencies + +It's important to download the following repositories before building the mixnode: + +* https://github.com/nymtech/nym-client +* https://github.com/nymtech/nym-sfw-provider +* https://github.com/nymtech/sphinx From 27c61cb194de28fe0fba426944847d0f2573f935 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 6 Jan 2020 12:04:45 +0000 Subject: [PATCH 59/66] Printing node version number on startup --- Cargo.lock | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 5 +++ build.rs | 5 +++ src/main.rs | 26 ++++++++----- 4 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index ebff5ed59e..5b16669dec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,6 +167,17 @@ dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "built" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "byte-tools" version = "0.3.1" @@ -204,6 +215,10 @@ dependencies = [ name = "cc" version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cfg-if" @@ -219,6 +234,16 @@ dependencies = [ "keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "chrono" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" version = "2.33.0" @@ -622,6 +647,18 @@ dependencies = [ "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "git2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "h2" version = "0.1.26" @@ -786,6 +823,16 @@ name = "itoa" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "jobserver" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -810,6 +857,28 @@ name = "libc" version = "0.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libgit2-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libz-sys" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lioness" version = "0.1.2" @@ -968,6 +1037,23 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "num-integer" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num_cpus" version = "1.11.1" @@ -1005,6 +1091,7 @@ name = "nym-mixnode" 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)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1851,6 +1938,14 @@ dependencies = [ "tungstenite 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "toml" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "try-lock" version = "0.2.2" @@ -2058,6 +2153,7 @@ dependencies = [ "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +"checksum built 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2315cfb416f86e05360edc950b1d7d25ecfb00f7f8eba60dbd7882a0f2e944" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" @@ -2066,6 +2162,7 @@ dependencies = [ "checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +"checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -2113,6 +2210,7 @@ dependencies = [ "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" +"checksum git2 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c1af51ea8a906616af45a4ce78eacf25860f7a13ae7bf8a814693f0f4037a26" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" "checksum hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" @@ -2129,10 +2227,13 @@ dependencies = [ "checksum input_buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e1b822cc844905551931d6f81608ed5f50a79c1078a4e2b4d42dbc7c1eedfbf" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum keystream 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum libgit2-sys 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4870c781f6063efb83150cd22c1ddf6ecf58531419e7570cdcced46970f64a16" +"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" "checksum lioness 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" @@ -2150,6 +2251,8 @@ dependencies = [ "checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" @@ -2238,6 +2341,7 @@ dependencies = [ "checksum tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c32ffea4827978e9aa392d2f743d973c1dfa3730a2ed3f22ce1e6984da848c" "checksum tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1739638e364e558128461fc1ad84d997702c8e31c2e6b18fb99842268199e827" "checksum tokio-tungstenite 0.10.0 (git+https://github.com/dbcfd/tokio-tungstenite?rev=6dc2018cbfe8fe7ddd75ff977343086503135b38)" = "" +"checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" "checksum tungstenite 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a0c2bd5aeb7dcd2bb32e472c8872759308495e5eccc942e929a513cd8d36110" diff --git a/Cargo.toml b/Cargo.toml index 0adfb88178..4eef4205d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [package] +build = "build.rs" name = "nym-mixnode" version = "0.1.0" authors = ["Dave Hrycyszyn "] @@ -14,3 +15,7 @@ futures = "0.3.1" nym-client = { path = "../nym-client" } sphinx = { path = "../sphinx" } tokio = { version = "0.2", features = ["full"] } + + +[build-dependencies] +built = "0.3.2" \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000000..71d5c82762 --- /dev/null +++ b/build.rs @@ -0,0 +1,5 @@ +use built; + +fn main() { + built::write_built_file().expect("Failed to acquire build-time information"); +} diff --git a/src/main.rs b/src/main.rs index e3b9d32ee4..e652fc9ae4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,13 +16,14 @@ fn main() { Arg::with_name("host") .long("host") .help("The custom host on which the mixnode will be running") - .takes_value(true), + .takes_value(true) + .required(true), ) .arg( Arg::with_name("port") .long("port") .help("The port on which the mixnode will be listening") - .takes_value(true) + .takes_value(true), ) .arg( Arg::with_name("layer") @@ -32,9 +33,9 @@ fn main() { .required(true), ) .arg( - Arg::with_name("local") - .long("local") - .help("Flag to indicate whether the client is expected to run on a local deployment.") + Arg::with_name("directory") + .long("directory") + .help("Address of the directory server the node is sending presence and metrics to") .takes_value(false), ), ) @@ -46,6 +47,11 @@ fn main() { } } +pub mod built_info { + // The file has been placed there by the build script. + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + fn execute(matches: ArgMatches) -> Result<(), String> { match matches.subcommand() { ("run", Some(m)) => Ok(node::runner::start(m)), @@ -58,7 +64,8 @@ fn usage() -> String { } fn banner() -> String { - return r#" + format!( + r#" _ __ _ _ _ __ ___ | '_ \| | | | '_ \ _ \ @@ -66,8 +73,9 @@ fn banner() -> String { |_| |_|\__, |_| |_| |_| |___/ - (mixnode) + (mixnode - version {:}) - "# - .to_string(); + "#, + built_info::PKG_VERSION + ) } From efb4660fe7e4998354130973c5da10fd26009a9b Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 6 Jan 2020 12:12:40 +0000 Subject: [PATCH 60/66] Requiring explicit host + printing bound address on startup --- src/node/runner.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/node/runner.rs b/src/node/runner.rs index 372dcccd74..00bc6d805f 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -14,8 +14,10 @@ pub fn start(matches: &ArgMatches) { let config = new_config(matches); println!("Public key: {}", config.public_key_string()); - // println!("Startup on: {}", config.socket_address); - println!("Listening for incoming packets..."); + println!( + "Listening for incoming packets on {}", + config.socket_address + ); let mix = MixNode::new(&config); thread::spawn(move || { @@ -26,7 +28,7 @@ pub fn start(matches: &ArgMatches) { } fn new_config(matches: &ArgMatches) -> node::Config { - let host = matches.value_of("host").unwrap_or("0.0.0.0"); + let host = matches.value_of("host").unwrap(); let port = match matches.value_of("port").unwrap_or("1789").parse::() { Ok(n) => n, @@ -38,8 +40,6 @@ fn new_config(matches: &ArgMatches) -> node::Config { Err(err) => panic!("Invalid layer value provided - {:?}", err), }; - let is_local = matches.is_present("local"); - let socket_address = (host, port) .to_socket_addrs() .expect("Failed to combine host and port") @@ -48,11 +48,10 @@ fn new_config(matches: &ArgMatches) -> node::Config { let (secret_key, public_key) = sphinx::crypto::keygen(); - let directory_server = if is_local { - "http://localhost:8080".to_string() - } else { - "https://directory.nymtech.net".to_string() - }; + let directory_server = matches + .value_of("directory") + .unwrap_or("https://directory.nymtech.net") + .to_string(); node::Config { directory_server, From 0bb69597554ce485480240618136c4c30d8f7cb9 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 6 Jan 2020 12:20:08 +0000 Subject: [PATCH 61/66] Printing directory server on start --- src/main.rs | 2 +- src/node/runner.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e652fc9ae4..d3ac898c9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ fn main() { Arg::with_name("directory") .long("directory") .help("Address of the directory server the node is sending presence and metrics to") - .takes_value(false), + .takes_value(true), ), ) .get_matches(); diff --git a/src/node/runner.rs b/src/node/runner.rs index 00bc6d805f..4e55bc7e86 100644 --- a/src/node/runner.rs +++ b/src/node/runner.rs @@ -13,7 +13,7 @@ pub fn start(matches: &ArgMatches) { let config = new_config(matches); println!("Public key: {}", config.public_key_string()); - + println!("Directory server: {}", config.directory_server); println!( "Listening for incoming packets on {}", config.socket_address From d5a0e7d3553a76917edb69beef5f019f40dc308c Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 6 Jan 2020 14:43:19 +0000 Subject: [PATCH 62/66] ipv6_addressing --- Cargo.lock | 1 + src/mix_peer.rs | 15 ++++++++------- src/node/mod.rs | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) 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( From 7f3ea6af1a832f5c52f355e97ea581473ffdd4da Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Mon, 6 Jan 2020 15:26:43 +0000 Subject: [PATCH 63/66] Changelog file --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..9e3a675207 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# nym-mixnode Changelog + +## 0.1.0 - Initial Release + +* The bare minimum set of features required by a Nym Mixnode \ No newline at end of file From 4fc2e3bc0d60ceb594c515849a3deeeb17bada25 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 6 Jan 2020 17:42:04 +0000 Subject: [PATCH 64/66] Changelog for 0.2.0 release --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e3a675207..bd38641c87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # nym-mixnode Changelog +## 0.2.0 + +* removed the `--local` flag +* introduced `--directory` argument to support arbitrary directory servers. Leaving it out will point the node at the "https://directory.nymtech.net" alpha testnet server +* the `host` argument is now required +* IPv6 support +* mixnode version number is now shown at node start +* directory server location is now shown at node start + ## 0.1.0 - Initial Release -* The bare minimum set of features required by a Nym Mixnode \ No newline at end of file +* The bare minimum set of features required by a Nym Mixnode From 38e747104eae39ef894556ae592cadc1c3d8ce3b Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 6 Jan 2020 17:42:44 +0000 Subject: [PATCH 65/66] =?UTF-8?q?Added=20the=20glorious=20and=20talented?= =?UTF-8?q?=20J=C4=99drzej=20Stuczy=C5=84ski=20to=20authors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4eef4205d4..22ca58fad2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ build = "build.rs" name = "nym-mixnode" version = "0.1.0" -authors = ["Dave Hrycyszyn "] +authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 220ef1b0ef2552523328178c879a5be97041f904 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 6 Jan 2020 17:43:12 +0000 Subject: [PATCH 66/66] Version number bump --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 22ca58fad2..43573e6572 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] build = "build.rs" name = "nym-mixnode" -version = "0.1.0" +version = "0.2.0" authors = ["Dave Hrycyszyn ", "Jędrzej Stuczyński "] edition = "2018" @@ -18,4 +18,4 @@ tokio = { version = "0.2", features = ["full"] } [build-dependencies] -built = "0.3.2" \ No newline at end of file +built = "0.3.2"