diff --git a/Cargo.lock b/Cargo.lock index 3353bc488a..b71d62a3c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -88,7 +88,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -97,8 +97,8 @@ 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)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -189,7 +189,7 @@ dependencies = [ [[package]] name = "bytes" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -238,7 +238,7 @@ 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)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -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)", @@ -286,7 +286,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -404,7 +404,7 @@ 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)", + "libc 0.2.66 (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)", ] @@ -421,7 +421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "encoding_rs" -version = "0.8.20" +version = "0.8.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)", @@ -467,7 +467,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -618,7 +618,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -641,10 +641,10 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -765,12 +765,20 @@ dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "input_buffer" +version = "0.2.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)", +] + [[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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -797,14 +805,9 @@ 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" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -889,7 +892,7 @@ dependencies = [ "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)", + "libc 0.2.66 (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)", @@ -897,17 +900,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" @@ -925,7 +917,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -955,7 +947,7 @@ 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)", + "libc 0.2.66 (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)", @@ -972,7 +964,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -981,8 +973,8 @@ 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)", + "hermit-abi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -994,15 +986,18 @@ dependencies = [ "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)", + "hex 0.4.0 (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)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sfw-provider-requests 0.1.0", "sphinx 0.1.0", "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tungstenite 0.10.0 (git+https://github.com/dbcfd/tokio-tungstenite?rev=6dc2018cbfe8fe7ddd75ff977343086503135b38)", + "tungstenite 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1014,9 +1009,13 @@ dependencies = [ "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)", "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "nym-client 0.1.0", "rand 0.7.2 (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)", "sfw-provider-requests 0.1.0", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sphinx 0.1.0", "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1035,7 +1034,7 @@ dependencies = [ "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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1050,8 +1049,8 @@ 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)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (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)", ] @@ -1073,7 +1072,7 @@ 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)", + "libc 0.2.66 (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)", @@ -1100,6 +1099,24 @@ name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "pin-project" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "pin-project-internal 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.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.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pin-project-lite" version = "0.1.1" @@ -1169,7 +1186,7 @@ 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)", + "libc 0.2.66 (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)", @@ -1187,7 +1204,7 @@ 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)", + "libc 0.2.66 (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)", @@ -1269,7 +1286,7 @@ 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)", + "libc 0.2.66 (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)", ] @@ -1281,7 +1298,7 @@ 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)", + "libc 0.2.66 (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)", @@ -1361,7 +1378,7 @@ dependencies = [ "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)", + "encoding_rs 0.8.21 (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)", @@ -1371,7 +1388,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)", @@ -1434,7 +1451,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1461,15 +1478,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)", @@ -1484,7 +1501,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]] @@ -1494,7 +1511,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)", ] @@ -1533,7 +1550,7 @@ 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)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1560,7 +1577,7 @@ 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)", + "libc 0.2.66 (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)", ] @@ -1642,7 +1659,7 @@ 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)", + "libc 0.2.66 (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)", @@ -1670,7 +1687,7 @@ 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)", + "libc 0.2.66 (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)", ] @@ -1698,11 +1715,11 @@ name = "tokio" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.3 (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)", + "libc 0.2.66 (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)", @@ -1829,6 +1846,18 @@ dependencies = [ "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-tungstenite" +version = "0.10.0" +source = "git+https://github.com/dbcfd/tokio-tungstenite?rev=6dc2018cbfe8fe7ddd75ff977343086503135b38#6dc2018cbfe8fe7ddd75ff977343086503135b38" +dependencies = [ + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tungstenite 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "try-lock" version = "0.2.2" @@ -1842,6 +1871,25 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tungstenite" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "input_buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (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)", + "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "utf-8 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "typenum" version = "1.11.2" @@ -1901,6 +1949,11 @@ dependencies = [ "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "utf-8" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "uuid" version = "0.7.4" @@ -1981,23 +2034,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" @@ -2032,9 +2068,9 @@ dependencies = [ "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 bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10004c15deb332055f7a4a208190aed362cf9a7c2f6ab70a305fba50e1105f38" "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 cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "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" @@ -2059,7 +2095,7 @@ dependencies = [ "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 encoding_rs 0.8.21 (registry+https://github.com/rust-lang/crates.io-index)" = "f730a5068736d360795b76e8c53ef51d052a4090d281412da851f5fd6204f36d" "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" @@ -2085,7 +2121,7 @@ dependencies = [ "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 hermit-abi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f629dc602392d3ec14bfc8a09b5e644d7ffd725102b48b81e59f90f2633621d7" "checksum hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" "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" @@ -2097,13 +2133,13 @@ dependencies = [ "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 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 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 libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "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" @@ -2115,7 +2151,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" @@ -2132,6 +2167,8 @@ dependencies = [ "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 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "94b90146c7216e4cb534069fb91366de4ea0ea353105ee45ed297e2d1619e469" +"checksum pin-project-internal 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "44ca92f893f0656d3cba8158dd0f2b99b94de256a4a54e870bd6922fcc6c8355" "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" @@ -2173,8 +2210,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" @@ -2207,8 +2244,10 @@ dependencies = [ "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 tokio-tungstenite 0.10.0 (git+https://github.com/dbcfd/tokio-tungstenite?rev=6dc2018cbfe8fe7ddd75ff977343086503135b38)" = "" "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" "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" @@ -2217,6 +2256,7 @@ dependencies = [ "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 utf-8 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" "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" @@ -2230,5 +2270,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" diff --git a/Cargo.toml b/Cargo.toml index 37e504aad1..d4424fd789 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,7 @@ rand = "0.7.2" sfw-provider-requests = { path = "./sfw-provider-requests" } sphinx = { path = "../sphinx" } tokio = { version = "0.2.4", features = ["full"] } +sha2 = "0.8.0" +serde = { version = "1.0.104", features = ["derive"] } +serde_json = "1.0.44" +hmac = "0.7.1" diff --git a/sfw-provider-requests/src/lib.rs b/sfw-provider-requests/src/lib.rs index efc7bf8ef9..70e06feaad 100644 --- a/sfw-provider-requests/src/lib.rs +++ b/sfw-provider-requests/src/lib.rs @@ -3,3 +3,5 @@ pub mod responses; pub const DUMMY_MESSAGE_CONTENT: &[u8] = b"[DUMMY MESSAGE] Wanting something does not give you the right to have it."; + +pub type AuthToken = [u8; 32]; diff --git a/sfw-provider-requests/src/requests.rs b/sfw-provider-requests/src/requests.rs index cd185ec6a6..3dba30c038 100644 --- a/sfw-provider-requests/src/requests.rs +++ b/sfw-provider-requests/src/requests.rs @@ -1,3 +1,6 @@ +use crate::AuthToken; +use sphinx::route::DestinationAddressBytes; + const PULL_REQUEST_MESSAGE_PREFIX: [u8; 2] = [1, 0]; const REGISTER_MESSAGE_PREFIX: [u8; 2] = [0, 1]; @@ -51,12 +54,17 @@ where #[derive(Debug)] pub struct PullRequest { // TODO: public keys, signatures, tokens, etc. basically some kind of authentication bs + pub auth_token: AuthToken, pub destination_address: sphinx::route::DestinationAddressBytes, } impl PullRequest { - pub fn new(destination_address: sphinx::route::DestinationAddressBytes) -> Self { + pub fn new( + destination_address: sphinx::route::DestinationAddressBytes, + auth_token: AuthToken, + ) -> Self { PullRequest { + auth_token, destination_address, } } @@ -67,6 +75,57 @@ impl ProviderRequest for PullRequest { PULL_REQUEST_MESSAGE_PREFIX } + fn to_bytes(&self) -> Vec { + Self::get_prefix() + .to_vec() + .into_iter() + .chain(self.destination_address.iter().cloned()) + .chain(self.auth_token.iter().cloned()) + .collect() + } + + fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() != 2 + 32 + 32 { + return Err(ProviderRequestError::UnmarshalError); + } + + let mut received_prefix = [0u8; 2]; + received_prefix.copy_from_slice(&bytes[..2]); + if received_prefix != Self::get_prefix() { + return Err(ProviderRequestError::UnmarshalErrorIncorrectPrefix); + } + + let mut destination_address = [0u8; 32]; + destination_address.copy_from_slice(&bytes[2..34]); + + let mut auth_token = [0u8; 32]; + auth_token.copy_from_slice(&bytes[34..]); + + Ok(PullRequest { + auth_token, + destination_address, + }) + } +} + +#[derive(Debug)] +pub struct RegisterRequest { + pub destination_address: DestinationAddressBytes, +} + +impl RegisterRequest { + pub fn new(destination_address: DestinationAddressBytes) -> Self { + RegisterRequest { + destination_address, + } + } +} + +impl ProviderRequest for RegisterRequest { + fn get_prefix() -> [u8; 2] { + REGISTER_MESSAGE_PREFIX + } + fn to_bytes(&self) -> Vec { Self::get_prefix() .to_vec() @@ -89,29 +148,12 @@ impl ProviderRequest for PullRequest { let mut destination_address = [0u8; 32]; destination_address.copy_from_slice(&bytes[2..]); - Ok(PullRequest { + Ok(RegisterRequest { destination_address, }) } } -#[derive(Debug)] -pub struct RegisterRequest {} - -impl ProviderRequest for RegisterRequest { - fn get_prefix() -> [u8; 2] { - unimplemented!() - } - - fn to_bytes(&self) -> Vec { - unimplemented!() - } - - fn from_bytes(bytes: &[u8]) -> Result { - unimplemented!() - } -} - #[cfg(test)] mod creating_pull_request { use super::*; @@ -122,11 +164,51 @@ mod creating_pull_request { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, ]; - let pull_request = PullRequest::new(address); + let auth_token = [1u8; 32]; + let pull_request = PullRequest::new(address, auth_token); let bytes = pull_request.to_bytes(); let recovered = PullRequest::from_bytes(&bytes).unwrap(); assert_eq!(address, recovered.destination_address); + assert_eq!(auth_token, recovered.auth_token); + } + + #[test] + fn it_is_possible_to_recover_it_from_bytes_with_enum_wrapper() { + let address = [ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 0, 1, 2, + ]; + let auth_token = [1u8; 32]; + let pull_request = PullRequest::new(address, auth_token); + let bytes = pull_request.to_bytes(); + + let recovered = ProviderRequests::from_bytes(&bytes).unwrap(); + match recovered { + ProviderRequests::PullMessages(req) => { + assert_eq!(address, req.destination_address); + assert_eq!(auth_token, req.auth_token); + } + _ => panic!("expected to recover pull request!"), + } + } +} + +#[cfg(test)] +mod creating_register_request { + use super::*; + + #[test] + fn it_is_possible_to_recover_it_from_bytes() { + let address = [ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 0, 1, 2, + ]; + let register_request = RegisterRequest::new(address); + let bytes = register_request.to_bytes(); + + let recovered = RegisterRequest::from_bytes(&bytes).unwrap(); + assert_eq!(address, recovered.destination_address); } #[test] @@ -135,12 +217,14 @@ mod creating_pull_request { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, ]; - let pull_request = PullRequest::new(address); - let bytes = pull_request.to_bytes(); + let register_request = RegisterRequest::new(address); + let bytes = register_request.to_bytes(); let recovered = ProviderRequests::from_bytes(&bytes).unwrap(); match recovered { - ProviderRequests::PullMessages(req) => assert_eq!(address, req.destination_address), + ProviderRequests::Register(req) => { + assert_eq!(address, req.destination_address); + } _ => panic!("expected to recover pull request!"), } } diff --git a/sfw-provider-requests/src/responses.rs b/sfw-provider-requests/src/responses.rs index 86b622fa5e..870f527334 100644 --- a/sfw-provider-requests/src/responses.rs +++ b/sfw-provider-requests/src/responses.rs @@ -1,3 +1,4 @@ +use crate::AuthToken; use std::convert::TryInto; #[derive(Debug)] @@ -20,12 +21,23 @@ pub struct PullResponse { pub messages: Vec>, } +#[derive(Debug)] +pub struct RegisterResponse { + pub auth_token: AuthToken, +} + impl PullResponse { pub fn new(messages: Vec>) -> Self { PullResponse { messages } } } +impl RegisterResponse { + pub fn new(auth_token: AuthToken) -> Self { + RegisterResponse { auth_token } + } +} + // TODO: This should go into some kind of utils module/crate fn read_be_u16(input: &mut &[u8]) -> u16 { let (int_bytes, rest) = input.split_at(std::mem::size_of::()); @@ -95,6 +107,23 @@ impl ProviderResponse for PullResponse { } } +impl ProviderResponse for RegisterResponse { + fn to_bytes(&self) -> Vec { + self.auth_token.to_vec() + } + + fn from_bytes(bytes: &[u8]) -> Result { + match bytes.len() { + 32 => { + let mut auth_token = [0u8; 32]; + auth_token.copy_from_slice(&bytes[..32]); + Ok(RegisterResponse { auth_token }) + } + _ => Err(ProviderResponseError::UnmarshalErrorInvalidLength), + } + } +} + #[cfg(test)] mod creating_pull_response { use super::*; diff --git a/src/main.rs b/src/main.rs index 87972eca8e..d32b6c592d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ use crate::provider::presence; use crate::provider::ServiceProvider; use clap::{App, Arg, ArgMatches, SubCommand}; -use curve25519_dalek::scalar::Scalar; use std::net::ToSocketAddrs; use std::path::PathBuf; use std::process; @@ -54,6 +53,15 @@ fn main() { .long("storeDir") .help("Directory storing all packets for the clients") .takes_value(true) + .required(true), + ) + .arg( + Arg::with_name("registeredLedger") + .short("r") + .long("registeredLedger") + .help("Directory of the ledger of registered clients") + .takes_value(true) + .required(true), ).arg(Arg::with_name("local") .long("local") .help("Flag to indicate whether the provider should run on a local deployment.") @@ -78,7 +86,7 @@ fn run(matches: &ArgMatches) { notifier.run(); }); - provider.start_listening().unwrap() + provider.start().unwrap() } fn execute(matches: ArgMatches) -> Result<(), String> { @@ -115,6 +123,7 @@ fn new_config(matches: &ArgMatches) -> provider::Config { }; let store_dir = PathBuf::from(matches.value_of("storeDir").unwrap_or("/tmp/nym-provider")); + let registered_client_ledger_dir = PathBuf::from(matches.value_of("registeredLedger").unwrap()); let (secret_key, public_key) = sphinx::crypto::keygen(); println!("The value of mix_host is: {:?}", mix_host); @@ -123,6 +132,10 @@ fn new_config(matches: &ArgMatches) -> provider::Config { println!("The value of client_port is: {:?}", client_port); println!("The value of key is: {:?}", secret_key); println!("The value of store_dir is: {:?}", store_dir); + println!( + "The value of registered_client_ledger_dir is: {:?}", + registered_client_ledger_dir + ); let mix_socket_address = (mix_host, mix_port) .to_socket_addrs() diff --git a/src/provider/client_handling/mod.rs b/src/provider/client_handling/mod.rs index 7618c7f1dc..06a2421f23 100644 --- a/src/provider/client_handling/mod.rs +++ b/src/provider/client_handling/mod.rs @@ -1,14 +1,28 @@ use crate::provider::storage::{ClientStorage, StoreError}; -use sfw_provider_requests::requests::{ProviderRequestError, ProviderRequests, PullRequest}; -use sfw_provider_requests::responses::{ProviderResponse, PullResponse}; +use crate::provider::ClientLedger; +use curve25519_dalek::scalar::Scalar; +use futures::lock::Mutex as FMutex; +use hmac::{Hmac, Mac}; +use sfw_provider_requests::requests::{ + ProviderRequestError, ProviderRequests, PullRequest, + RegisterRequest, +}; +use sfw_provider_requests::responses::{ProviderResponse, PullResponse, RegisterResponse}; +use sha2::Sha256; +use std::io; use std::path::{Path, PathBuf}; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; +use sfw_provider_requests::AuthToken; + +type HmacSha256 = Hmac; #[derive(Debug)] pub enum ClientProcessingError { ClientDoesntExistError, StoreError, InvalidRequest, + WrongToken, + IOError, } impl From for ClientProcessingError { @@ -28,49 +42,223 @@ impl From for ClientProcessingError { } } -#[derive(Debug, Clone)] +impl From for ClientProcessingError { + fn from(_: io::Error) -> Self { + use ClientProcessingError::*; + + IOError + } +} + +#[derive(Debug)] pub(crate) struct ClientProcessingData { store_dir: PathBuf, + registered_clients_ledger: ClientLedger, + secret_key: Scalar, } impl ClientProcessingData { - pub(crate) fn new(store_dir: PathBuf) -> Self { - ClientProcessingData { store_dir } + pub(crate) fn new( + store_dir: PathBuf, + registered_clients_ledger: ClientLedger, + secret_key: Scalar, + ) -> Self { + ClientProcessingData { + store_dir, + registered_clients_ledger, + secret_key, + } } - pub(crate) fn add_arc_rwlock(self) -> Arc> { - Arc::new(RwLock::new(self)) + pub(crate) fn add_arc_futures_mutex(self) -> Arc> { + Arc::new(FMutex::new(self)) } } pub(crate) struct ClientRequestProcessor(()); impl ClientRequestProcessor { - pub(crate) fn process_client_request( + pub(crate) async fn process_client_request( data: &[u8], - processing_data: &RwLock, + processing_data: Arc>, ) -> Result, ClientProcessingError> { let client_request = ProviderRequests::from_bytes(&data)?; - println!("received the following request: {:?}", client_request); + println!("Received the following request: {:?}", client_request); match client_request { - ProviderRequests::Register(req) => unimplemented!(), - ProviderRequests::PullMessages(req) => { - Ok(ClientRequestProcessor::process_pull_messages_request( - req, - processing_data.read().unwrap().store_dir.as_path(), - )? - .to_bytes()) - } + ProviderRequests::Register(req) => Ok(ClientRequestProcessor::register_new_client( + req, + processing_data, + ).await?.to_bytes()), + ProviderRequests::PullMessages(req) => Ok(ClientRequestProcessor::process_pull_messages_request( + req, + processing_data, + ).await?.to_bytes()) } } - fn process_pull_messages_request( + async fn process_pull_messages_request( req: PullRequest, - store_dir: &Path, + processing_data: Arc>, ) -> Result { - println!("processing pull!"); - let retrieved_messages = - ClientStorage::retrieve_client_files(req.destination_address, store_dir)?; - Ok(PullResponse::new(retrieved_messages)) + // TODO: this lock is completely unnecessary as we're only reading the data. + // Wait for https://github.com/nymtech/nym-sfw-provider/issues/19 to resolve. + let unlocked = processing_data.lock().await; + + println!("Processing pull!"); + if unlocked.registered_clients_ledger.has_token(req.auth_token) { + let store_dir_clone = unlocked.store_dir.clone(); + // drop the mutex so that we could do IO without blocking others wanting to get the lock + drop(unlocked); + let retrieved_messages = + ClientStorage::retrieve_client_files(req.destination_address, store_dir_clone.as_path())?; + Ok(PullResponse::new(retrieved_messages)) + } else { + Err(ClientProcessingError::WrongToken) + } + } + + async fn register_new_client( + req: RegisterRequest, + processing_data: Arc>, + ) -> Result { + println!("Processing register new client request!"); + let mut unlocked = processing_data.lock().await; + + let auth_token = ClientRequestProcessor::generate_new_auth_token( + req.destination_address.to_vec(), + unlocked.secret_key, + ); + if !unlocked.registered_clients_ledger.has_token(auth_token) { + unlocked.registered_clients_ledger.insert_token(auth_token, req.destination_address); + ClientRequestProcessor::create_storage_dir(req.destination_address, unlocked.store_dir.as_path())?; + } + Ok(RegisterResponse::new(auth_token)) + } + + fn create_storage_dir( + client_address: sphinx::route::DestinationAddressBytes, + store_dir: &Path, + ) -> io::Result<()> { + let client_dir_name = hex::encode(client_address); + let full_store_dir = store_dir.join(client_dir_name); + std::fs::create_dir_all(full_store_dir) + } + + fn generate_new_auth_token(data: Vec, key: Scalar) -> AuthToken { + let mut auth_token_raw = + HmacSha256::new_varkey(&key.to_bytes()).expect("HMAC can take key of any size"); + auth_token_raw.input(&data); + let mut auth_token = [0u8; 32]; + auth_token.copy_from_slice(&auth_token_raw.result().code().to_vec()); + auth_token + } +} + +#[cfg(test)] +mod register_new_client { + use super::*; + + // TODO: those tests require being called in async context. we need to research how to test this stuff... +// #[test] +// fn registers_new_auth_token_for_each_new_client() { +// let req1 = RegisterRequest { +// destination_address: [1u8; 32], +// }; +// let registered_client_ledger = ClientLedger::new(); +// let store_dir = PathBuf::from("./foo/"); +// let key = Scalar::from_bytes_mod_order([1u8; 32]); +// let client_processing_data = ClientProcessingData::new(store_dir, registered_client_ledger, key).add_arc_futures_mutex(); +// +// +// // need to do async.... +// client_processing_data.lock().await; +// assert_eq!(0, registered_client_ledger.0.len()); +// ClientRequestProcessor::register_new_client( +// req1, +// client_processing_data.clone(), +// ); +// +// assert_eq!(1, registered_client_ledger.0.len()); +// +// let req2 = RegisterRequest { +// destination_address: [2u8; 32], +// }; +// ClientRequestProcessor::register_new_client( +// req2, +// client_processing_data, +// ); +// assert_eq!(2, registered_client_ledger.0.len()); +// } +// +// #[test] +// fn registers_given_token_only_once() { +// let req1 = RegisterRequest { +// destination_address: [1u8; 32], +// }; +// let registered_client_ledger = ClientLedger::new(); +// let store_dir = PathBuf::from("./foo/"); +// let key = Scalar::from_bytes_mod_order([1u8; 32]); +// let client_processing_data = ClientProcessingData::new(store_dir, registered_client_ledger, key).add_arc_futures_mutex(); +// +// ClientRequestProcessor::register_new_client( +// req1, +// client_processing_data.clone(), +// ); +// let req2 = RegisterRequest { +// destination_address: [1u8; 32], +// }; +// ClientRequestProcessor::register_new_client( +// req2, +// client_processing_data.clone(), +// ); +// +// client_processing_data.lock().await; +// +// assert_eq!(1, registered_client_ledger.0.len()) +// } +} + +#[cfg(test)] +mod create_storage_dir { + use super::*; + use sphinx::route::DestinationAddressBytes; + + #[test] + fn it_creates_a_correct_storage_directory() { + let client_address: DestinationAddressBytes = [1u8; 32]; + let store_dir = Path::new("./foo/"); + ClientRequestProcessor::create_storage_dir(client_address, store_dir); + } +} + +#[cfg(test)] +mod generating_new_auth_token { + use super::*; + + #[test] + fn for_the_same_input_generates_the_same_auth_token() { + let data1 = vec![1u8; 55]; + let data2 = vec![1u8; 55]; + let key = Scalar::from_bytes_mod_order([1u8; 32]); + let token1 = ClientRequestProcessor::generate_new_auth_token(data1, key); + let token2 = ClientRequestProcessor::generate_new_auth_token(data2, key); + assert_eq!(token1, token2); + } + + #[test] + fn for_different_inputs_generates_different_auth_tokens() { + let data1 = vec![1u8; 55]; + let data2 = vec![2u8; 55]; + let key = Scalar::from_bytes_mod_order([1u8; 32]); + let token1 = ClientRequestProcessor::generate_new_auth_token(data1, key); + let token2 = ClientRequestProcessor::generate_new_auth_token(data2, key); + assert_ne!(token1, token2); + + let data1 = vec![1u8; 50]; + let data2 = vec![2u8; 55]; + let key = Scalar::from_bytes_mod_order([1u8; 32]); + let token1 = ClientRequestProcessor::generate_new_auth_token(data1, key); + let token2 = ClientRequestProcessor::generate_new_auth_token(data2, key); + assert_ne!(token1, token2); } } diff --git a/src/provider/mod.rs b/src/provider/mod.rs index 934e70333c..1541cb771a 100644 --- a/src/provider/mod.rs +++ b/src/provider/mod.rs @@ -2,16 +2,18 @@ use std::net::{Shutdown, SocketAddr}; use std::path::PathBuf; use std::sync::Arc; use std::sync::RwLock; - use curve25519_dalek::montgomery::MontgomeryPoint; use curve25519_dalek::scalar::Scalar; use tokio::prelude::*; use tokio::runtime::Runtime; - use crate::provider::client_handling::{ClientProcessingData, ClientRequestProcessor}; use crate::provider::mix_handling::{MixPacketProcessor, MixProcessingData}; use crate::provider::storage::ClientStorage; use futures::io::Error; +use sfw_provider_requests::AuthToken; +use sphinx::route::DestinationAddressBytes; +use std::collections::HashMap; +use futures::lock::Mutex as FMutex; mod client_handling; mod mix_handling; @@ -64,11 +66,34 @@ impl From for ProviderError { } } +#[derive(Debug)] +pub struct ClientLedger(HashMap); + +impl ClientLedger { + fn new() -> Self { + ClientLedger(HashMap::new()) + } + + fn has_token(&self, auth_token: AuthToken) -> bool { + return self.0.contains_key(&auth_token) + } + + fn insert_token(&mut self, auth_token: AuthToken, client_address: DestinationAddressBytes) -> Option{ + self.0.insert(auth_token, client_address) + } + + #[allow(dead_code)] + fn load(_file: PathBuf) -> Self { + unimplemented!() + } +} + pub struct ServiceProvider { mix_network_address: SocketAddr, client_network_address: SocketAddr, secret_key: Scalar, store_dir: PathBuf, + registered_clients_ledger: ClientLedger, } impl ServiceProvider { @@ -78,6 +103,8 @@ impl ServiceProvider { client_network_address: config.client_socket_address, secret_key: config.secret_key, store_dir: PathBuf::from(config.store_dir.clone()), + // TODO: load initial ledger from file + registered_clients_ledger: ClientLedger::new(), } } @@ -110,10 +137,10 @@ impl ServiceProvider { store_data, processing_data.read().unwrap().store_dir.as_path(), ) - .unwrap_or_else(|e| { - eprintln!("failed to store processed sphinx message; err = {:?}", e); - return; - }); + .unwrap_or_else(|e| { + eprintln!("failed to store processed sphinx message; err = {:?}", e); + return; + }); } Err(e) => { eprintln!("failed to read from socket; err = {:?}", e); @@ -141,7 +168,7 @@ impl ServiceProvider { // TODO: FIGURE OUT HOW TO SET READ_DEADLINES IN TOKIO async fn process_client_socket_connection( mut socket: tokio::net::TcpStream, - processing_data: Arc>, + processing_data: Arc>, ) { let mut buf = [0; 1024]; @@ -155,8 +182,8 @@ impl ServiceProvider { Ok(n) => { match ClientRequestProcessor::process_client_request( buf[..n].as_ref(), - processing_data.as_ref(), - ) { + processing_data, + ).await { Err(e) => { eprintln!("failed to process client request; err = {:?}", e); Err(()) @@ -209,9 +236,12 @@ impl ServiceProvider { async fn start_client_listening( address: SocketAddr, store_dir: PathBuf, + client_ledger: ClientLedger, + secret_key: Scalar, ) -> Result<(), ProviderError> { let mut listener = tokio::net::TcpListener::bind(address).await?; - let processing_data = ClientProcessingData::new(store_dir).add_arc_rwlock(); + let processing_data = + ClientProcessingData::new(store_dir, client_ledger, secret_key).add_arc_futures_mutex(); loop { let (socket, _) = listener.accept().await?; @@ -225,7 +255,8 @@ impl ServiceProvider { } } - pub fn start_listening(&self) -> Result<(), Box> { + // Note: this now consumes the provider + pub fn start(self) -> Result<(), Box> { // Create the runtime, probably later move it to Provider struct itself? // TODO: figure out the difference between Runtime and Handle let mut rt = Runtime::new()?; @@ -239,6 +270,8 @@ impl ServiceProvider { let client_future = rt.spawn(ServiceProvider::start_client_listening( self.client_network_address, self.store_dir.clone(), + self.registered_clients_ledger, // we're just cloning the initial ledger state + self.secret_key, )); // Spawn the root task rt.block_on(async { diff --git a/src/provider/storage/mod.rs b/src/provider/storage/mod.rs index 8cb7b3d077..a44f76a8e7 100644 --- a/src/provider/storage/mod.rs +++ b/src/provider/storage/mod.rs @@ -22,6 +22,7 @@ impl From for StoreError { pub struct StoreData { client_address: DestinationAddressBytes, + #[allow(dead_code)] client_surb_id: SURBIdentifier, message: Vec, } @@ -45,7 +46,7 @@ pub struct ClientStorage(()); // TODO: change it to some generic implementation to inject fs impl ClientStorage { - fn generate_random_file_name() -> String { + pub(crate) fn generate_random_file_name() -> String { rand::thread_rng() .sample_iter(&rand::distributions::Alphanumeric) .take(STORED_MESSAGE_FILENAME_LENGTH) @@ -73,9 +74,6 @@ impl ClientStorage { // TODO: what to do with surbIDs?? - // TODO: this should be called when client sends 'register' request! - std::fs::create_dir_all(full_store_dir)?; - // we can use normal io here, no need for tokio as it's all happening in one thread per connection let mut file = File::create(full_store_path)?; file.write_all(store_data.message.as_ref())?; @@ -109,9 +107,9 @@ impl ClientStorage { }) .map(|entry| { let content = std::fs::read(entry.path()).unwrap(); - ClientStorage::delete_file(entry.path()); + ClientStorage::delete_file(entry.path()).unwrap(); content - }) // TODO: THIS MAP IS UNSAFE (BOTH READING AND DELETING)!! + }) // TODO: THIS MAP IS UNSAFE (BOTH FOR READING AND DELETING)!! - in the case where there are multiple requests from the same client being processed in parallel .chain(std::iter::repeat(ClientStorage::dummy_message())) .take(MESSAGE_RETRIEVAL_LIMIT) .collect(); @@ -124,8 +122,8 @@ impl ClientStorage { // TODO: THIS NEEDS A LOCKING MECHANISM!!! (or a db layer on top - basically 'ClientStorage' on steroids) // TODO 2: This should only be called AFTER we sent the reply. Because if client's connection failed after sending request // the messages would be deleted but he wouldn't have received them - fn delete_file(path: PathBuf) { + fn delete_file(path: PathBuf) -> io::Result<()> { println!("Here {:?} will be deleted!", path); - std::fs::remove_file(path); // another argument for db layer -> remove_file is NOT guaranteed to immediately get rid of the file + std::fs::remove_file(path) // another argument for db layer -> remove_file is NOT guaranteed to immediately get rid of the file } }