From a4317d2ff4a02eea40e158e8b2f9a341a9ee8b1d Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 17 Aug 2020 10:14:46 +0100 Subject: [PATCH 01/28] Fix friends opt bug by writing to config file Passing the `--friends` flag pushed the ID(s) to the `config.friends` vector but did not write them to file. This fix ensures the updated config is written to file. The fix also avoids duplication in `config.friends` by checking for a matching ID before pushing to the vector. --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4dd67b9..9ebacce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,11 +100,11 @@ async fn main() -> Result<()> { let mut config = if !key_file.is_file() { println!("Private key not found, generated new one in {:?}", key_file); let config = Config::create(); - let mut file = File::create(key_file).await?; + let mut file = File::create(&key_file).await?; file.write_all(&config.to_toml()?).await?; config } else { - let mut file = File::open(key_file).await?; + let mut file = File::open(&key_file).await?; let mut raw: Vec = Vec::new(); file.read_to_end(&mut raw).await?; Config::from_toml(&raw)? @@ -133,13 +133,19 @@ async fn main() -> Result<()> { for friend in friends.split(',') { if friend == "connect" { for conn in &connects { - config.friends.push(format!("@{}", conn.2.to_ssb_id())); + let conn_id = format!("@{}", conn.2.to_ssb_id()); + if !config.friends.contains(&conn_id) { + config.friends.push(conn_id); + } } - } else { + } else if !config.friends.contains(&friend.to_string()) { config.friends.push(friend.to_string()) } } + let mut file = File::create(key_file).await?; + file.write_all(&config.to_toml()?).await?; } + debug!(target:"solar", "friends are {:?}",config.friends); let owned_id = config.owned_identity()?; let _err = CONFIG.set(config); From 40048c0ae77fb47a1d5346588901ce54baf38a9a Mon Sep 17 00:00:00 2001 From: mycognosist Date: Tue, 29 Nov 2022 18:56:17 +0200 Subject: [PATCH 02/28] remove sensor dep and code --- Cargo.lock | 509 +------------------------------------------ Cargo.toml | 1 - src/actors/mod.rs | 1 - src/actors/sensor.rs | 112 ---------- src/main.rs | 10 - 5 files changed, 6 insertions(+), 627 deletions(-) delete mode 100644 src/actors/sensor.rs diff --git a/Cargo.lock b/Cargo.lock index ce56af8..cb27502 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "adler32" version = "1.0.4" @@ -30,15 +32,6 @@ version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" -[[package]] -name = "approx" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" -dependencies = [ - "num-traits", -] - [[package]] name = "arc-swap" version = "0.4.4" @@ -51,15 +44,6 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - [[package]] name = "arrayvec" version = "0.5.1" @@ -227,7 +211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" dependencies = [ "arrayref", - "arrayvec 0.5.1", + "arrayvec", "constant_time_eq", ] @@ -266,12 +250,6 @@ dependencies = [ "slab", ] -[[package]] -name = "bumpalo" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" - [[package]] name = "byte-tools" version = "0.3.1" @@ -352,67 +330,12 @@ dependencies = [ "bitflags", ] -[[package]] -name = "cmake" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" -dependencies = [ - "cc", -] - -[[package]] -name = "color_quant" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd" - [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -[[package]] -name = "core-foundation" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" - -[[package]] -name = "core-graphics" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" -dependencies = [ - "bitflags", - "core-foundation", - "foreign-types", - "libc", -] - -[[package]] -name = "core-text" -version = "13.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db84654ad95211c082cf9795f6f83dc17d0ae6c985ac1b906369dc7384ed346d" -dependencies = [ - "core-foundation", - "core-graphics", - "foreign-types", - "libc", -] - [[package]] name = "crc32fast" version = "1.2.0" @@ -510,16 +433,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "deflate" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" -dependencies = [ - "adler32", - "byteorder", -] - [[package]] name = "digest" version = "0.8.1" @@ -529,17 +442,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "dirs" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" -dependencies = [ - "libc", - "redox_users", - "winapi 0.3.8", -] - [[package]] name = "dirs" version = "2.0.2" @@ -562,17 +464,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "dwrote" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd1369e02db5e9b842a9b67bce8a2fcc043beafb2ae8a799dd482d46ea1ff0d" -dependencies = [ - "lazy_static", - "libc", - "winapi 0.3.8", -] - [[package]] name = "env_logger" version = "0.7.1" @@ -586,25 +477,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "euclid" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6a5b0c779cd0b744c73a1d2083faf181080d696903cdad99a3b03d015d7030" -dependencies = [ - "num-traits", -] - -[[package]] -name = "expat-sys" -version = "2.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" -dependencies = [ - "cmake", - "pkg-config", -] - [[package]] name = "failure" version = "0.1.6" @@ -645,68 +517,12 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "float-ord" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" - [[package]] name = "fnv" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -[[package]] -name = "font-kit" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b7ff8d2a0a660875d01689807925a45c5843bf90a1ef97ec52ef86ab0cafba" -dependencies = [ - "byteorder", - "core-foundation", - "core-graphics", - "core-text", - "dirs 1.0.5", - "dwrote", - "euclid", - "float-ord", - "freetype", - "lazy_static", - "libc", - "log", - "lyon_path", - "memmap", - "servo-fontconfig", - "walkdir", - "winapi 0.3.8", -] - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "freetype" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11926b2b410b469d0e9399eca4cbbe237a9ef02176c485803b29216307e8e028" -dependencies = [ - "libc", - "servo-freetype-sys", -] - [[package]] name = "fs2" version = "0.4.3" @@ -893,16 +709,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gif" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "471d90201b3b223f3451cd4ad53e34295f16a1df17b1edf3736d47761c3981af" -dependencies = [ - "color_quant", - "lzw", -] - [[package]] name = "half" version = "1.4.1" @@ -942,20 +748,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "image" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08ed2ada878397b045454ac7cfb011d73132c59f31a955d230bd1f1c2e68eb4a" -dependencies = [ - "byteorder", - "jpeg-decoder", - "num-iter", - "num-rational", - "num-traits", - "png", -] - [[package]] name = "indexmap" version = "1.3.0" @@ -965,15 +757,6 @@ dependencies = [ "autocfg 0.1.7", ] -[[package]] -name = "inflate" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff" -dependencies = [ - "adler32", -] - [[package]] name = "iovec" version = "0.1.4" @@ -989,24 +772,6 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -[[package]] -name = "jpeg-decoder" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0256f0aec7352539102a9efbcb75543227b7ab1117e0f95450023af730128451" -dependencies = [ - "byteorder", -] - -[[package]] -name = "js-sys" -version = "0.3.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1020,7 +785,7 @@ dependencies = [ [[package]] name = "kuska-handshake" version = "0.1.0" -source = "git+https://github.com/Kuska-ssb/handshake#d421021bee2b579912a7455eb4dc7892065ac27d" +source = "git+https://github.com/Kuska-ssb/handshake?branch=master#d421021bee2b579912a7455eb4dc7892065ac27d" dependencies = [ "async-std", "futures", @@ -1032,13 +797,13 @@ dependencies = [ [[package]] name = "kuska-ssb" version = "0.2.0" -source = "git+https://github.com/Kuska-ssb/ssb#97129c77caef09154a5acdd5e4597b4167bddd8f" +source = "git+https://github.com/Kuska-ssb/ssb?branch=master#97129c77caef09154a5acdd5e4597b4167bddd8f" dependencies = [ "async-std", "async-stream", "base64 0.11.0", "crossbeam", - "dirs 2.0.2", + "dirs", "env_logger", "futures", "get_if_addrs", @@ -1118,32 +883,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "lyon_geom" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca04310c9807612a311506106000b6eccb2e27bca9bfb594ce80fb8a31231f9d" -dependencies = [ - "arrayvec 0.4.12", - "euclid", - "num-traits", -] - -[[package]] -name = "lyon_path" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bcb57ac24a5428539e2c7c0592766d5933c937d703f430990c669c00de96862" -dependencies = [ - "lyon_geom", -] - -[[package]] -name = "lzw" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084" - [[package]] name = "mach" version = "0.3.2" @@ -1159,16 +898,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi 0.3.8", -] - [[package]] name = "memoffset" version = "0.5.3" @@ -1266,12 +995,6 @@ dependencies = [ "void", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - [[package]] name = "num-integer" version = "0.1.42" @@ -1282,28 +1005,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00" -dependencies = [ - "autocfg 1.0.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg 1.0.0", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.11" @@ -1335,37 +1036,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -[[package]] -name = "ordered-float" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" -dependencies = [ - "num-traits", -] - -[[package]] -name = "palette" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05c0334468e62a4dfbda34b29110aa7d70d58c7fdb2c9857b5874dd9827cc59" -dependencies = [ - "approx", - "num-traits", - "palette_derive", -] - -[[package]] -name = "palette_derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b4b5f600e60dd3a147fb57b4547033d382d1979eb087af310e91cb45a63b1f4" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "parking_lot" version = "0.10.0" @@ -1408,37 +1078,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" -[[package]] -name = "plotters" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb" -dependencies = [ - "chrono", - "font-kit", - "gif", - "image", - "js-sys", - "lazy_static", - "num-traits", - "palette", - "rusttype", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "png" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef859a23054bbfee7811284275ae522f0434a3c8e7f4b74bd4a35ae7e1c4a283" -dependencies = [ - "bitflags", - "crc32fast", - "deflate", - "inflate", -] - [[package]] name = "ppv-lite86" version = "0.2.6" @@ -1696,32 +1335,12 @@ dependencies = [ "semver", ] -[[package]] -name = "rusttype" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" -dependencies = [ - "approx", - "ordered-float", - "stb_truetype", -] - [[package]] name = "ryu" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "scopeguard" version = "1.0.0" @@ -1785,37 +1404,6 @@ dependencies = [ "serde", ] -[[package]] -name = "servo-fontconfig" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a088f8d775a5c5314aae09bd77340bc9c67d72b9a45258be34c83548b4814cd9" -dependencies = [ - "libc", - "servo-fontconfig-sys", -] - -[[package]] -name = "servo-fontconfig-sys" -version = "4.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b3e166450f523f4db06c14f02a2d39e76d49b5d8cbd224338d93e3595c156c" -dependencies = [ - "expat-sys", - "pkg-config", - "servo-freetype-sys", -] - -[[package]] -name = "servo-freetype-sys" -version = "4.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4ccb6d0d32d277d3ef7dea86203d8210945eb7a45fba89dd445b3595dd0dfc" -dependencies = [ - "cmake", - "pkg-config", -] - [[package]] name = "sha2" version = "0.8.1" @@ -1919,7 +1507,6 @@ dependencies = [ "kuska-ssb", "log", "once_cell", - "plotters", "procfs", "rand 0.7.3", "regex", @@ -1937,15 +1524,6 @@ dependencies = [ "xdg", ] -[[package]] -name = "stb_truetype" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51" -dependencies = [ - "byteorder", -] - [[package]] name = "strsim" version = "0.8.0" @@ -2187,87 +1765,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -[[package]] -name = "walkdir" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -dependencies = [ - "same-file", - "winapi 0.3.8", - "winapi-util", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasm-bindgen" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" - -[[package]] -name = "web-sys" -version = "0.3.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6f51648d8c56c366144378a33290049eafdd784071077f6fe37dae64c1c4cb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "winapi" version = "0.2.8" diff --git a/Cargo.toml b/Cargo.toml index be62293..5dbba2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,6 @@ base64 = "0.11.0" once_cell = "1.3.1" async-trait = "0.1.29" sha2 = "0.8.1" -plotters = "0.2.12" procfs = "0.7.8" slice-deque = "0.3.0" toml = "0.5.6" diff --git a/src/actors/mod.rs b/src/actors/mod.rs index 393d209..ae008bb 100644 --- a/src/actors/mod.rs +++ b/src/actors/mod.rs @@ -2,5 +2,4 @@ pub mod ctrlc; pub mod lan_discovery; pub mod peer; pub mod rpc; -pub mod sensor; pub mod tcp_server; diff --git a/src/actors/sensor.rs b/src/actors/sensor.rs deleted file mode 100644 index 0aad556..0000000 --- a/src/actors/sensor.rs +++ /dev/null @@ -1,112 +0,0 @@ -use std::{fs::File, io::Read, time::Duration}; - -use async_std::task; -use futures::FutureExt; -use plotters::prelude::*; -use slice_deque::SliceDeque; - -use kuska_ssb::{api::dto::content::Post, feed::Message, keystore::OwnedIdentity}; - -use crate::{broker::*, BLOB_STORAGE, KV_STORAGE}; -use anyhow::Result; - -pub async fn actor(server_id: OwnedIdentity) -> Result<()> { - let broker = BROKER.lock().await.register("sensor", false).await?; - let mut ch_terminate = broker.ch_terminate.fuse(); - let mut data: SliceDeque = SliceDeque::with_capacity(20); - loop { - select_biased! { - _ = ch_terminate => break, - _ = task::sleep(Duration::from_secs(5)).fuse() => { - if let Err(err) = sensor_proc(&server_id,&mut data).await { - warn!("sensor proc finished with error {:?}",err); - } - } - } - } - let _ = broker.ch_terminated.send(Void {}); - Ok(()) -} - -async fn sensor_proc(server_id: &OwnedIdentity, data: &mut SliceDeque) -> Result<()> { - let feed_storage = KV_STORAGE.write().await; - - let last_msg = if let Some(last_id) = feed_storage.get_last_feed_no(&server_id.id)? { - Some( - feed_storage - .get_feed(&server_id.id, last_id)? - .unwrap() - .into_message()?, - ) - } else { - None - }; - - let mem_available = procfs::Meminfo::new()?.mem_available.unwrap(); - if data.len() == 20 { - data.pop_front(); - } - data.push_back(mem_available % 20); - - let png = create_graphics(data.as_slice())?; - let blob_id = BLOB_STORAGE.write().await.insert(&png).await?; - - let markdown = format!( - "Sensor recording at {:?} ... current temperature is {:?} - ![graphics.png]({})", - std::time::SystemTime::now(), - mem_available, - blob_id - ); - let post = Post::new(markdown, None).to_msg()?; - let msg = Message::sign(last_msg.as_ref(), &server_id, post)?; - let next_id = feed_storage.append_feed(msg).await?; - - info!("Recoding sensor data {} ...", next_id); - - Ok(()) -} - -fn create_graphics(data: &[u64]) -> Result> { - let mut image_path = std::env::temp_dir(); - image_path.push("sonarsewarnnsor"); - image_path.set_extension("png"); - - let root = BitMapBackend::new(&image_path, (300, 200)).into_drawing_area(); - - root.fill(&WHITE)?; - - let mut chart = ChartBuilder::on(&root) - .x_label_area_size(10) - .y_label_area_size(10) - .margin(5) - .caption( - format!("{:?}", std::time::SystemTime::now()), - ("sans-serif", 10.0).into_font(), - ) - .build_ranged(0u32..10u32, 0u32..10u32)?; - - chart - .configure_mesh() - .disable_x_mesh() - .line_style_1(&WHITE.mix(0.3)) - .x_label_offset(30) - .y_desc("Count") - .x_desc("Bucket") - .axis_desc_style(("sans-serif", 15).into_font()) - .draw()?; - - chart.draw_series( - Histogram::vertical(&chart) - .style(RED.mix(0.5).filled()) - .data(data.iter().map(|x: &u64| (*x as u32, 1))), - )?; - drop(chart); - - let mut file = File::open(&image_path)?; - let len = file.metadata()?.len() as usize; - let mut content = Vec::with_capacity(len); - file.read_to_end(&mut content)?; - - Ok(content) -} diff --git a/src/main.rs b/src/main.rs index 4dd67b9..6834b32 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,6 @@ extern crate futures; #[macro_use] extern crate log; -extern crate plotters; extern crate procfs; extern crate sha2; extern crate slice_deque; @@ -42,10 +41,6 @@ struct Opt { /// Run lan discovery #[structopt(short, long)] lan: Option, - - /// Run sensor - #[structopt(short, long)] - sensor: Option, } mod actors; @@ -80,7 +75,6 @@ async fn main() -> Result<()> { let rpc_port = opt.port.unwrap_or(RPC_PORT); let lan_discovery = opt.lan.unwrap_or(false); let listen = format!("0.0.0.0:{}", rpc_port); - let sensor = opt.sensor.unwrap_or(false); env_logger::init(); log::set_max_level(log::LevelFilter::max()); @@ -162,10 +156,6 @@ async fn main() -> Result<()> { Broker::spawn(actors::ctrlc::actor()); - if sensor { - Broker::spawn(actors::sensor::actor(owned_id.clone())); - } - Broker::spawn(actors::tcp_server::actor(owned_id.clone(), listen)); if lan_discovery { Broker::spawn(actors::lan_discovery::actor(owned_id.clone(), RPC_PORT)); From 7094cbf001f446378928fec756511d02b922bd62 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Tue, 29 Nov 2022 19:00:22 +0200 Subject: [PATCH 03/28] bump dependencies --- Cargo.lock | 1531 +++++++++++++++++++++++++++------------------------- Cargo.toml | 48 +- 2 files changed, 824 insertions(+), 755 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb27502..dc4a7c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,96 +4,176 @@ version = 3 [[package]] name = "adler32" -version = "1.0.4" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "aho-corasick" -version = "0.7.6" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "anyhow" -version = "1.0.32" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] -name = "arc-swap" -version = "0.4.4" +name = "async-attributes" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn", +] [[package]] -name = "arrayref" -version = "0.3.5" +name = "async-channel" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] [[package]] -name = "arrayvec" -version = "0.5.1" +name = "async-ctrlc" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +checksum = "907279f6e91a51c8ec7cac24711e8308f21da7c10c7700ca2f7e125694ed2df1" +dependencies = [ + "ctrlc", +] [[package]] -name = "async-attributes" -version = "1.1.1" +name = "async-executor" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" dependencies = [ - "quote", - "syn", + "async-lock", + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", ] [[package]] -name = "async-ctrlc" -version = "1.0.0" +name = "async-global-executor" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59a172dcc98d67707ccd5bd60428ae2912a12295098dc0d35cdcae165314a2d" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" dependencies = [ - "ctrlc", + "async-channel", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +dependencies = [ + "async-lock", + "autocfg", + "concurrent-queue", + "futures-lite", + "libc", + "log", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "windows-sys", +] + +[[package]] +name = "async-lock" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +dependencies = [ + "event-listener", + "futures-lite", +] + +[[package]] +name = "async-process" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6381ead98388605d0d9ff86371043b5aa922a3905824244de40dc263a14fcba4" +dependencies = [ + "async-io", + "async-lock", + "autocfg", + "blocking", + "cfg-if 1.0.0", + "event-listener", + "futures-lite", + "libc", + "signal-hook", + "windows-sys", ] [[package]] name = "async-std" -version = "1.5.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ "async-attributes", - "async-task", - "broadcaster", - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils 0.7.0", + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "async-process", + "crossbeam-utils 0.8.14", + "futures-channel", "futures-core", "futures-io", - "futures-timer", + "futures-lite", + "gloo-timers", "kv-log-macro", "log", "memchr", - "mio", - "mio-uds", - "num_cpus", "once_cell", "pin-project-lite", "pin-utils", "slab", + "wasm-bindgen-futures", ] [[package]] @@ -119,25 +199,27 @@ dependencies = [ [[package]] name = "async-task" -version = "1.2.1" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9f534e76ca33eaa82bc8da5adb1b9e94a16f6fa217b78e9b400094dbbf844f9" -dependencies = [ - "libc", - "winapi 0.3.8", -] +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.29" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab5c215748dc1ad11a145359b1067107ae0f8ca5e99844fa64067ed5bf198e3" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + [[package]] name = "atty" version = "0.2.14" @@ -146,51 +228,14 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" - -[[package]] -name = "backtrace" -version = "0.3.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4ed64ae6d9ebfd9893193c4b2532b1292ec97bd8271c9d7d0fa90cd78a34cba" -dependencies = [ - "backtrace-sys", - "cfg-if", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "base64" -version = "0.10.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" @@ -200,20 +245,9 @@ checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" [[package]] name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "blake2b_simd" -version = "0.5.10" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" @@ -237,19 +271,25 @@ dependencies = [ ] [[package]] -name = "broadcaster" -version = "1.0.0" +name = "blocking" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87" +checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8" dependencies = [ - "futures-channel", - "futures-core", - "futures-sink", - "futures-util", - "parking_lot", - "slab", + "async-channel", + "async-lock", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", ] +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + [[package]] name = "byte-tools" version = "0.3.1" @@ -258,24 +298,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" - -[[package]] -name = "bytes" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10004c15deb332055f7a4a208190aed362cf9a7c2f6ab70a305fba50e1105f38" - -[[package]] -name = "c2-chacha" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" -dependencies = [ - "ppv-lite86", -] +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "c_linked_list" @@ -285,9 +310,9 @@ checksum = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" [[package]] name = "cc" -version = "1.0.50" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cfg-if" @@ -295,22 +320,32 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "chrono" -version = "0.4.11" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ + "iana-time-zone", + "js-sys", "num-integer", "num-traits", "time", + "wasm-bindgen", + "winapi 0.3.9", ] [[package]] name = "clap" -version = "2.33.0" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -331,106 +366,136 @@ dependencies = [ ] [[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crc32fast" -version = "1.2.0" +name = "codespan-reporting" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "cfg-if", + "termcolor", + "unicode-width", ] [[package]] -name = "crossbeam" -version = "0.7.3" +name = "concurrent-queue" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" +checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" dependencies = [ - "cfg-if", - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils 0.7.0", + "crossbeam-utils 0.8.14", ] [[package]] -name = "crossbeam-channel" -version = "0.4.0" +name = "core-foundation-sys" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c" -dependencies = [ - "crossbeam-utils 0.7.0", -] +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] -name = "crossbeam-deque" -version = "0.7.2" +name = "crc32fast" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "crossbeam-epoch", - "crossbeam-utils 0.7.0", + "cfg-if 1.0.0", ] [[package]] name = "crossbeam-epoch" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 0.1.7", - "cfg-if", - "crossbeam-utils 0.7.0", + "autocfg", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", "lazy_static", + "maybe-uninit", "memoffset", "scopeguard", ] [[package]] -name = "crossbeam-queue" -version = "0.2.1" +name = "crossbeam-utils" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "cfg-if", - "crossbeam-utils 0.7.0", + "autocfg", + "cfg-if 0.1.10", + "lazy_static", ] [[package]] name = "crossbeam-utils" -version = "0.6.6" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" dependencies = [ - "cfg-if", - "lazy_static", + "cfg-if 1.0.0", ] [[package]] -name = "crossbeam-utils" -version = "0.7.0" +name = "ctor" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ - "autocfg 0.1.7", - "cfg-if", - "lazy_static", + "quote", + "syn", ] [[package]] name = "ctrlc" -version = "3.1.3" +version = "3.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" +checksum = "1d91974fbbe88ec1df0c24a4f00f99583667a7e2e6272b2b92d294d81e462173" dependencies = [ "nix", - "winapi 0.3.8", + "winapi 0.3.9", +] + +[[package]] +name = "cxx" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -448,20 +513,28 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", + "dirs-sys", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.3.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ - "cfg-if", "libc", "redox_users", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -478,26 +551,10 @@ dependencies = [ ] [[package]] -name = "failure" -version = "0.1.6" +name = "event-listener" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fake-simd" @@ -506,23 +563,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] -name = "filetime" -version = "0.2.8" +name = "fastrand" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.8", + "instant", ] -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" - [[package]] name = "fs2" version = "0.4.3" @@ -530,7 +578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" dependencies = [ "libc", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -539,27 +587,11 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - [[package]] name = "futures" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -572,9 +604,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -582,15 +614,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -599,17 +631,31 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] [[package]] name = "futures-macro" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -617,27 +663,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" - -[[package]] -name = "futures-timer" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.4" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -646,9 +686,8 @@ dependencies = [ "futures-sink", "futures-task", "memchr", + "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] @@ -669,9 +708,9 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] @@ -700,44 +739,73 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gloo-timers" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", ] [[package]] name = "half" -version = "1.4.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20d6a47d6e4b8559729f58287efa8e6f767e603c068fea7a5e4d9f1cebe2bebb" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.6" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] [[package]] name = "hex" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "humantime" @@ -748,82 +816,115 @@ dependencies = [ "quick-error", ] +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi 0.3.9", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "indexmap" -version = "1.3.0" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ - "autocfg 0.1.7", + "autocfg", + "hashbrown", ] [[package]] -name = "iovec" -version = "0.1.4" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "libc", + "cfg-if 1.0.0", ] [[package]] name = "itoa" -version = "0.4.4" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "js-sys" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "wasm-bindgen", ] [[package]] name = "kuska-handshake" -version = "0.1.0" -source = "git+https://github.com/Kuska-ssb/handshake?branch=master#d421021bee2b579912a7455eb4dc7892065ac27d" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33da4b69f23c2ece0b3e729d079cebdc2c0206e493e42f510f500ad81c631d5" dependencies = [ - "async-std", "futures", + "hex", + "kuska-sodiumoxide", "log", - "sodiumoxide", - "tokio", + "thiserror", +] + +[[package]] +name = "kuska-sodiumoxide" +version = "0.2.5-0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0f8eafdd240b722243787b51fdaf8df6693fb8621d0f7061cdba574214cf88" +dependencies = [ + "libc", + "libsodium-sys", + "serde", ] [[package]] name = "kuska-ssb" -version = "0.2.0" -source = "git+https://github.com/Kuska-ssb/ssb?branch=master#97129c77caef09154a5acdd5e4597b4167bddd8f" +version = "0.4.1" +source = "git+https://github.com/Kuska-ssb/ssb?branch=master#0ba96450567f597a5642a23b85a0e08df4c7cab0" dependencies = [ "async-std", "async-stream", - "base64 0.11.0", - "crossbeam", - "dirs", - "env_logger", + "base64", + "dirs 2.0.2", "futures", "get_if_addrs", "hex", "kuska-handshake", - "lazy_static", + "kuska-sodiumoxide", "log", "once_cell", - "rand 0.7.3", "regex", "serde", "serde_json", - "sodiumoxide", + "thiserror", ] [[package]] name = "kv-log-macro" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" dependencies = [ "log", ] @@ -836,199 +937,136 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.66" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libflate" -version = "0.1.27" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9135df43b1f5d0e333385cb6e7897ecd1a43d7d11b91ac003f4d2c2d2401fdd" +checksum = "05605ab2bce11bcfc0e9c635ff29ef8b2ea83f29be257ee7d730cac3ee373093" dependencies = [ "adler32", "crc32fast", - "rle-decode-fast", - "take_mut", + "libflate_lz77", ] [[package]] -name = "libsodium-sys" -version = "0.2.4" -source = "git+https://github.com/Dhole/sodiumoxidez?branch=extra#53c0fb16069309c35010eb568d9ed05f5bd52ce8" -dependencies = [ - "cc", - "libc", - "libflate", - "pkg-config", - "tar", - "vcpkg", -] - -[[package]] -name = "lock_api" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.8" +name = "libflate_lz77" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "39a734c0493409afcd49deee13c006a04e3586b9761a03543c6272c9c51f2f5a" dependencies = [ - "cfg-if", + "rle-decode-fast", ] [[package]] -name = "mach" -version = "0.3.2" +name = "libsodium-sys" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +checksum = "6b779387cd56adfbc02ea4a668e704f729be8d6a6abd2c27ca5ee537849a92fd" dependencies = [ + "cc", "libc", + "pkg-config", + "walkdir", ] [[package]] -name = "memchr" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" - -[[package]] -name = "memoffset" -version = "0.5.3" +name = "link-cplusplus" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" dependencies = [ - "rustc_version", + "cc", ] [[package]] -name = "mio" -version = "0.6.21" +name = "lock_api" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" dependencies = [ - "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.1", - "net2", - "slab", - "winapi 0.2.8", + "scopeguard", ] [[package]] -name = "mio-named-pipes" -version = "0.1.6" +name = "log" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5e374eff525ce1c5b7687c4cef63943e7686524a387933ad27ca7ec43779cb3" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "log", - "mio", - "miow 0.3.3", - "winapi 0.3.8", + "cfg-if 1.0.0", + "value-bag", ] [[package]] -name = "mio-uds" -version = "0.6.7" +name = "mach" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" dependencies = [ - "iovec", "libc", - "mio", ] [[package]] -name = "miow" -version = "0.2.1" +name = "maybe-uninit" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] -name = "miow" -version = "0.3.3" +name = "memchr" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" -dependencies = [ - "socket2", - "winapi 0.3.8", -] +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] -name = "net2" -version = "0.2.33" +name = "memoffset" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.8", + "autocfg", ] [[package]] name = "nix" -version = "0.14.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" +checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" dependencies = [ + "autocfg", "bitflags", - "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", - "void", ] [[package]] name = "num-integer" -version = "0.1.42" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "autocfg 1.0.0", + "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ - "autocfg 1.0.0", -] - -[[package]] -name = "num_cpus" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" -dependencies = [ - "hermit-abi", - "libc", + "autocfg", ] [[package]] name = "once_cell" -version = "1.3.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "opaque-debug" @@ -1036,11 +1074,17 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + [[package]] name = "parking_lot" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ "lock_api", "parking_lot_core", @@ -1048,99 +1092,94 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "cloudabi", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "smallvec", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "pin-project-lite" -version = "0.1.2" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8822eb8bb72452f038ebf6048efa02c3fe22bf83f76519c9583e47fc194a422" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" -version = "0.1.0-alpha.4" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" - -[[package]] -name = "ppv-lite86" -version = "0.2.6" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] -name = "proc-macro-error" -version = "1.0.2" +name = "polling" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678" +checksum = "166ca89eb77fd403230b9c156612965a81e094ec6ec3aa13663d4c8b113fa748" dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", + "autocfg", + "cfg-if 1.0.0", + "libc", + "log", + "wepoll-ffi", + "windows-sys", ] [[package]] -name = "proc-macro-error-attr" -version = "1.0.2" +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ + "proc-macro-error-attr", "proc-macro2", "quote", "syn", - "syn-mid", "version_check", ] [[package]] -name = "proc-macro-hack" -version = "0.5.11" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2", "quote", - "syn", + "version_check", ] -[[package]] -name = "proc-macro-nested" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" - [[package]] name = "proc-macro2" -version = "1.0.7" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "procfs" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe50036aa1b71e553a4a0c48ab7baabf8aa8c7a5a61aae06bf38c2eab7430475" +checksum = "c434e93ef69c216e68e4f417c927b4f31502c3560b72cfdb6827e2321c5c6b3e" dependencies = [ "bitflags", "byteorder", @@ -1159,9 +1198,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.2" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -1176,7 +1215,7 @@ dependencies = [ "libc", "rand_core 0.3.1", "rdrand", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -1185,7 +1224,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", "rand_chacha", "rand_core 0.5.1", @@ -1194,11 +1233,11 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ - "c2-chacha", + "ppv-lite86", "rand_core 0.5.1", ] @@ -1223,7 +1262,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", ] [[package]] @@ -1235,20 +1274,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.8", -] - [[package]] name = "rdrand" version = "0.4.0" @@ -1260,122 +1285,103 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] [[package]] name = "redox_users" -version = "0.3.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "failure", - "rand_os", - "redox_syscall", - "rust-argon2", + "getrandom 0.2.8", + "redox_syscall 0.2.16", + "thiserror", ] [[package]] name = "regex" -version = "1.3.7" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] name = "regex-syntax" -version = "0.6.17" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "remove_dir_all" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "rle-decode-fast" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" - -[[package]] -name = "rust-argon2" -version = "0.5.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" -dependencies = [ - "base64 0.10.1", - "blake2b_simd", - "crossbeam-utils 0.6.6", -] +checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" [[package]] -name = "rustc-demangle" -version = "0.1.16" +name = "ryu" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "semver", + "winapi-util", ] -[[package]] -name = "ryu" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" - [[package]] name = "scopeguard" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" - -[[package]] -name = "semver" -version = "0.9.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "semver-parser" -version = "0.7.0" +name = "scratch" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" [[package]] name = "serde" -version = "1.0.104" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] [[package]] name = "serde_cbor" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ "half", "serde", @@ -1383,9 +1389,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.104" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -1394,9 +1400,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.48" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ "indexmap", "itoa", @@ -1406,9 +1412,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" dependencies = [ "block-buffer", "digest", @@ -1416,21 +1422,33 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "signal-hook" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" dependencies = [ - "arc-swap", "libc", ] [[package]] name = "slab" -version = "0.4.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "sled" @@ -1440,7 +1458,7 @@ checksum = "8fb6824dde66ad33bf20c6e8476f5b82b871bc8bc3c129a10ea2f7dae5060fa3" dependencies = [ "crc32fast", "crossbeam-epoch", - "crossbeam-utils 0.7.0", + "crossbeam-utils 0.7.2", "fs2", "fxhash", "libc", @@ -1456,41 +1474,29 @@ checksum = "31ef6ee280cdefba6d2d0b4b78a84a1c1a3f3a4cec98c2d4231c8bc225de0f25" dependencies = [ "libc", "mach", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "smallvec" -version = "1.2.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "snap" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fb9b0bb877b35a1cc1474a3b43d9c226a2625311760cdda2cbccbc0c7a8376" +checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "socket2" -version = "0.3.11" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.8", -] - -[[package]] -name = "sodiumoxide" -version = "0.2.4" -source = "git+https://github.com/Dhole/sodiumoxidez?branch=extra#53c0fb16069309c35010eb568d9ed05f5bd52ce8" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", - "libsodium-sys", - "serde", + "winapi 0.3.9", ] [[package]] @@ -1501,7 +1507,7 @@ dependencies = [ "async-ctrlc", "async-std", "async-trait", - "base64 0.11.0", + "base64", "env_logger", "futures", "kuska-ssb", @@ -1532,9 +1538,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.14" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863246aaf5ddd0d6928dfeb1a9ca65f505599e4e1b399935ef7e75107516b4ef" +checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ "clap", "lazy_static", @@ -1543,9 +1549,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.7" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d239ca4b13aee7a2142e6795cbd69e457665ff8037aed33b3effdc430d2f927a" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck", "proc-macro-error", @@ -1556,54 +1562,13 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "syn-mid" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "synstructure" -version = "0.12.3" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" dependencies = [ "proc-macro2", "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "take_mut" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" - -[[package]] -name = "tar" -version = "0.4.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3196bfbffbba3e57481b6ea32249fbaf590396a52505a2615adbb79d9d826d3" -dependencies = [ - "filetime", - "libc", - "redox_syscall", - "xattr", + "unicode-ident", ] [[package]] @@ -1618,9 +1583,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] @@ -1636,18 +1601,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.11" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee14bf8e6767ab4c687c9e8bc003879e042a96fd67a3ba5934eadb6536bef4db" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.11" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7b51e1fbc44b5a0840be594fbc0f960be09050f2617e61e6aa43bef97cd3ef4" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", @@ -1655,121 +1620,190 @@ dependencies = [ ] [[package]] -name = "thread_local" -version = "1.0.1" +name = "time" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ - "lazy_static", + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", ] [[package]] -name = "time" -version = "0.1.42" +name = "toml" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ - "libc", - "redox_syscall", - "winapi 0.3.8", + "serde", ] [[package]] -name = "tokio" -version = "0.2.9" +name = "typenum" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffa2fdcfa937b20cb3c822a635ceecd5fc1a27a6a474527e5516aa24b8c8820a" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "libc", - "memchr", - "mio", - "mio-named-pipes", - "mio-uds", - "num_cpus", - "pin-project-lite", - "signal-hook-registry", - "slab", - "tokio-macros", - "winapi 0.3.8", -] +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] -name = "tokio-macros" -version = "0.2.3" +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "unicode-segmentation" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "value-bag" +version = "1.0.0-alpha.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50a61f268a3db2acee8dcab514efc813dc6dbe8a00e86076f935f94304b59a7a" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" dependencies = [ - "quote", - "syn", + "ctor", + "version_check", ] [[package]] -name = "toml" -version = "0.5.6" +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "walkdir" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ - "serde", + "same-file", + "winapi 0.3.9", + "winapi-util", ] [[package]] -name = "typenum" -version = "1.11.2" +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "unicode-segmentation" -version = "1.6.0" +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] -name = "unicode-width" -version = "0.1.7" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "unicode-xid" -version = "0.2.0" +name = "wasm-bindgen" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] [[package]] -name = "vcpkg" -version = "0.2.8" +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] [[package]] -name = "vec_map" -version = "0.8.1" +name = "wasm-bindgen-macro" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] [[package]] -name = "version_check" -version = "0.9.1" +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] -name = "void" -version = "1.0.2" +name = "web-sys" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] [[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +name = "wepoll-ffi" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] [[package]] name = "winapi" @@ -1779,20 +1813,14 @@ checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -1801,11 +1829,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -1815,26 +1843,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "ws2_32-sys" -version = "0.2.1" +name = "windows-sys" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] -name = "xattr" -version = "0.2.2" +name = "windows_aarch64_gnullvm" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" -dependencies = [ - "libc", -] +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" [[package]] name = "xdg" -version = "2.2.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" +checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" +dependencies = [ + "dirs 4.0.0", +] diff --git a/Cargo.toml b/Cargo.toml index 5dbba2f..0e20c81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,27 +13,27 @@ path = "src/main.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } -async-std = { version = "1.5.0", features=["unstable","attributes"] } -futures = "0.3.4" -serde = { version = "1.0.104", features = ["derive"] } -serde_json = { version = "1.0.48", features=["preserve_order","arbitrary_precision"] } -serde_cbor = "0.11.1" -tempdir = "0.3.7" -log = "0.4.8" -env_logger = "0.7.1" -thiserror = "1.0.11" -async-ctrlc = "1.0.0" -snap = "1.0.0" -rand = "0.7.3" -sled = "0.31.0" -xdg = "2.2.0" -base64 = "0.11.0" -once_cell = "1.3.1" -async-trait = "0.1.29" -sha2 = "0.8.1" -procfs = "0.7.8" -slice-deque = "0.3.0" -toml = "0.5.6" -regex = "1.3.7" -structopt = "0.3.14" -anyhow = "1.0.32" +async-std = { version = "1", features=["unstable","attributes"] } +futures = "0.3" +serde = { version = "1", features = ["derive"] } +serde_json = { version = "1", features=["preserve_order","arbitrary_precision"] } +serde_cbor = "0.11" +tempdir = "0.3" +log = "0.4" +env_logger = "0.7" +thiserror = "1" +async-ctrlc = "1" +snap = "1" +rand = "0.7" +sled = "0.31" +xdg = "2.2" +base64 = "0.11" +once_cell = "1.3" +async-trait = "0.1" +sha2 = "0.8" +procfs = "0.7" +slice-deque = "0.3" +toml = "0.5" +regex = "1" +structopt = "0.3" +anyhow = "1" From 25eb758ab1977c4e845aa1164bffe69aa887a175 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Tue, 29 Nov 2022 19:02:58 +0200 Subject: [PATCH 04/28] handle compiler warnings --- src/actors/peer.rs | 2 +- src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/actors/peer.rs b/src/actors/peer.rs index d072789..61ee606 100644 --- a/src/actors/peer.rs +++ b/src/actors/peer.rs @@ -155,7 +155,7 @@ async fn peer_loop { + _value = ch_terminate_fuse => { break; }, packet = rpc_recv_stream.select_next_some() => { diff --git a/src/main.rs b/src/main.rs index 6834b32..b651acc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,15 +110,15 @@ async fn main() -> Result<()> { let invalid_peer_msg = || format!("invalid peer {}", peer); let parts = peer.split(':').collect::>(); if parts.len() != 3 { - panic!(invalid_peer_msg()); + panic!("{}", invalid_peer_msg()); } let server = parts[0].to_string(); let port = parts[1] .parse::() - .unwrap_or_else(|_| panic!(invalid_peer_msg())); + .unwrap_or_else(|_| panic!("{}", invalid_peer_msg())); let peer_pk = parts[2] .to_ed25519_pk_no_suffix() - .unwrap_or_else(|_| panic!(invalid_peer_msg())); + .unwrap_or_else(|_| panic!("{}", invalid_peer_msg())); connects.push((server, port, peer_pk)); } } From b34c423f91a572e5f6fc9eec4039d6ef79ebd2ae Mon Sep 17 00:00:00 2001 From: mycognosist Date: Tue, 29 Nov 2022 19:26:21 +0200 Subject: [PATCH 05/28] handle clippy warning --- src/actors/rpc/blobs_get.rs | 2 +- src/actors/rpc/blobs_wants.rs | 4 ++-- src/actors/rpc/history_stream.rs | 4 ++-- src/broker.rs | 2 +- src/storage/blob.rs | 12 ++---------- src/storage/kv.rs | 14 +++----------- 6 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/actors/rpc/blobs_get.rs b/src/actors/rpc/blobs_get.rs index 94b46ab..7230bad 100644 --- a/src/actors/rpc/blobs_get.rs +++ b/src/actors/rpc/blobs_get.rs @@ -68,7 +68,7 @@ where return self.recv_cancelstream(api, *req_no).await; } RpcInput::Network(req_no, rpc::RecvMsg::RpcResponse(_type, res)) => { - return self.recv_rpc_response(api, *req_no, &res).await; + return self.recv_rpc_response(api, *req_no, res).await; } RpcInput::Message(msg) => { if let Some(get_event) = msg.downcast_ref::() { diff --git a/src/actors/rpc/blobs_wants.rs b/src/actors/rpc/blobs_wants.rs index 5785564..2359327 100644 --- a/src/actors/rpc/blobs_wants.rs +++ b/src/actors/rpc/blobs_wants.rs @@ -157,13 +157,13 @@ where if let Some(wants_event) = msg.downcast_ref::() { match wants_event { RpcBlobsWantsEvent::BroadcastWants(ids) => { - return self.event_wants_broadcast(api, &ids).await + return self.event_wants_broadcast(api, ids).await } } } else if let Some(stoblob_event) = msg.downcast_ref::() { match stoblob_event { StoBlobEvent::Added(blob_id) => { - return self.event_stoblob_added(api, &blob_id).await + return self.event_stoblob_added(api, blob_id).await } } } diff --git a/src/actors/rpc/history_stream.rs b/src/actors/rpc/history_stream.rs index 834d951..f4b382b 100644 --- a/src/actors/rpc/history_stream.rs +++ b/src/actors/rpc/history_stream.rs @@ -67,7 +67,7 @@ where } } RpcInput::Network(req_no, rpc::RecvMsg::RpcResponse(_type, res)) => { - self.recv_rpc_response(api, ch_broker, *req_no, &res).await + self.recv_rpc_response(api, ch_broker, *req_no, res).await } RpcInput::Network(req_no, rpc::RecvMsg::CancelStreamRespose()) => { self.recv_cancelstream(api, *req_no).await @@ -112,7 +112,7 @@ where let _ = api.create_history_stream_req_send(&args).await?; for friend in &CONFIG.get().unwrap().friends { let mut args = dto::CreateHistoryStreamIn::new(friend.to_string()).live(true); - if let Some(last_feed) = KV_STORAGE.read().await.get_last_feed_no(&friend)? { + if let Some(last_feed) = KV_STORAGE.read().await.get_last_feed_no(friend)? { args = args.after_seq(last_feed); } let id = api.create_history_stream_req_send(&args).await?; diff --git a/src/broker.rs b/src/broker.rs index e9ee31c..5ebabb9 100644 --- a/src/broker.rs +++ b/src/broker.rs @@ -27,7 +27,7 @@ pub type ChSigRecv = oneshot::Receiver; pub type ChMsgSend = mpsc::UnboundedSender; pub type ChMsgRecv = mpsc::UnboundedReceiver; -#[derive(PartialEq, Debug)] +#[derive(Eq, PartialEq, Debug)] pub enum Destination { Actor(usize), Broadcast, diff --git a/src/storage/blob.rs b/src/storage/blob.rs index 66b2221..0b77451 100644 --- a/src/storage/blob.rs +++ b/src/storage/blob.rs @@ -12,20 +12,12 @@ pub enum StoBlobEvent { Added(String), } +#[derive(Default)] pub struct BlobStorage { path: Option, ch_broker: Option, } -impl Default for BlobStorage { - fn default() -> Self { - Self { - path: None, - ch_broker: None, - } - } -} - pub trait ToBlobHashId { fn blob_hash_id(&self) -> String; } @@ -44,7 +36,7 @@ impl BlobStorage { self.ch_broker = Some(ch_broker); } fn path_of(&self, id: &str) -> PathBuf { - let id = id.replace("&", "").replace("/", "_"); + let id = id.replace('&', "").replace('/', "_"); [self.path.as_ref().unwrap(), Path::new(&id)] .iter() .collect() diff --git a/src/storage/kv.rs b/src/storage/kv.rs index 3ceeb03..74b4458 100644 --- a/src/storage/kv.rs +++ b/src/storage/kv.rs @@ -14,6 +14,7 @@ pub enum StoKvEvent { IdChanged(String), } +#[derive(Default)] pub struct KvStorage { db: Option, ch_broker: Option, @@ -66,15 +67,6 @@ impl From for Error { impl std::error::Error for Error {} pub type Result = std::result::Result; -impl Default for KvStorage { - fn default() -> Self { - Self { - db: None, - ch_broker: None, - } - } -} - impl KvStorage { pub fn open(&mut self, path: &std::path::Path, ch_broker: ChBrokerSend) -> Result<()> { self.db = Some(sled::open(path)?); @@ -85,7 +77,7 @@ impl KvStorage { pub fn get_last_feed_no(&self, user_id: &str) -> Result> { let db = self.db.as_ref().unwrap(); let key = Self::key_lastfeed(user_id); - let count = if let Some(value) = db.get(&key)?.map(|v| v) { + let count = if let Some(value) = db.get(&key)? { let mut u64_buffer = [0u8; 8]; u64_buffer.copy_from_slice(&value); Some(u64::from_be_bytes(u64_buffer)) @@ -168,7 +160,7 @@ impl KvStorage { pub fn get_message(&self, msg_id: &str) -> Result> { let db = self.db.as_ref().unwrap(); - if let Some(raw) = db.get(Self::key_message(&msg_id))? { + if let Some(raw) = db.get(Self::key_message(msg_id))? { let feed_ref = serde_cbor::from_slice::(&raw)?; let msg = self .get_feed(&feed_ref.author, feed_ref.seq_no)? From c2e0a719b8912a213a2b7ba4113167b6f84b1062 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Tue, 29 Nov 2022 19:38:03 +0200 Subject: [PATCH 06/28] remove cargo manifest comment --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0e20c81..52d8261 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ build = "build.rs" name = "solar" path = "src/main.rs" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } async-std = { version = "1", features=["unstable","attributes"] } From 02117180f388866bb26a8f74cfa893fc8d99f6ec Mon Sep 17 00:00:00 2001 From: mycognosist Date: Tue, 29 Nov 2022 19:38:22 +0200 Subject: [PATCH 07/28] add in-progress notes --- notes | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 notes diff --git a/notes b/notes new file mode 100644 index 0000000..92a6b19 --- /dev/null +++ b/notes @@ -0,0 +1,31 @@ + + +[ phase 1: leaner and cleaner ] + + - easy wins first + - bump deps + - handle compiler warnings + - handle clippy warnings + - remove sensor code + - remove plotting dep + + - custom error type + - remove anyhow and thiserror deps + - implement error type + - implement result type + + - replace env_logger with lighter option + + - replace serde with nanoserde or miniserde + - eventually, replace in kuska-ssb too + +error inspiration: + +https://github.com/xvxx/vial/blob/master/src/error.rs +https://github.com/xvxx/vial/blob/master/src/lib.rs#L241 + +[ phase 2: move relevant code to new workspace ] + +[ phase 3: write connection handler ] + +[ phase 4: write ebt replication ] From 87710e86a8cec576a0b2f8b53e185660810c7f87 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Wed, 30 Nov 2022 17:17:37 +0200 Subject: [PATCH 08/28] replace anyhow and thiserror with custom error type --- Cargo.lock | 9 -- Cargo.toml | 5 +- build.rs | 2 +- notes | 17 ++-- src/actors/ctrlc.rs | 3 +- src/actors/lan_discovery.rs | 3 +- src/actors/peer.rs | 3 +- src/actors/rpc/blobs_get.rs | 3 +- src/actors/rpc/blobs_wants.rs | 3 +- src/actors/rpc/get.rs | 3 +- src/actors/rpc/handler.rs | 6 +- src/actors/rpc/history_stream.rs | 6 +- src/actors/rpc/whoami.rs | 3 +- src/actors/tcp_server.rs | 3 +- src/broker.rs | 2 +- src/config.rs | 3 +- src/error.rs | 145 +++++++++++++++++++++++++++++++ src/main.rs | 6 +- 18 files changed, 178 insertions(+), 47 deletions(-) create mode 100644 src/error.rs diff --git a/Cargo.lock b/Cargo.lock index dc4a7c2..8b30813 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,12 +35,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "anyhow" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" - [[package]] name = "async-attributes" version = "1.1.2" @@ -901,7 +895,6 @@ dependencies = [ [[package]] name = "kuska-ssb" version = "0.4.1" -source = "git+https://github.com/Kuska-ssb/ssb?branch=master#0ba96450567f597a5642a23b85a0e08df4c7cab0" dependencies = [ "async-std", "async-stream", @@ -1503,7 +1496,6 @@ dependencies = [ name = "solar" version = "0.2.0" dependencies = [ - "anyhow", "async-ctrlc", "async-std", "async-trait", @@ -1525,7 +1517,6 @@ dependencies = [ "snap", "structopt", "tempdir", - "thiserror", "toml", "xdg", ] diff --git a/Cargo.toml b/Cargo.toml index 52d8261..de5ef97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ name = "solar" path = "src/main.rs" [dependencies] -kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } +#kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } +kuska-ssb = { path = "../kuska-ssb" } async-std = { version = "1", features=["unstable","attributes"] } futures = "0.3" serde = { version = "1", features = ["derive"] } @@ -20,7 +21,6 @@ serde_cbor = "0.11" tempdir = "0.3" log = "0.4" env_logger = "0.7" -thiserror = "1" async-ctrlc = "1" snap = "1" rand = "0.7" @@ -35,4 +35,3 @@ slice-deque = "0.3" toml = "0.5" regex = "1" structopt = "0.3" -anyhow = "1" diff --git a/build.rs b/build.rs index bb4e363..14f7cf1 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ // build.rs use std::process::Command; fn main() { - let git_hash = if let Ok(output) = Command::new("git").args(&["rev-parse", "HEAD"]).output() { + let git_hash = if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() { String::from_utf8(output.stdout).unwrap() } else { "unknown".to_string() diff --git a/notes b/notes index 92a6b19..dc055dd 100644 --- a/notes +++ b/notes @@ -3,16 +3,17 @@ [ phase 1: leaner and cleaner ] - easy wins first - - bump deps - - handle compiler warnings - - handle clippy warnings - - remove sensor code - - remove plotting dep + x bump deps + x handle compiler warnings + x handle clippy warnings + x remove sensor code + x remove plotting dep - custom error type - - remove anyhow and thiserror deps - - implement error type - - implement result type + x remove anyhow and thiserror deps + x implement error type + x implement result type + / implement From for each variant - replace env_logger with lighter option diff --git a/src/actors/ctrlc.rs b/src/actors/ctrlc.rs index 3140393..a1d10c2 100644 --- a/src/actors/ctrlc.rs +++ b/src/actors/ctrlc.rs @@ -1,8 +1,7 @@ use async_ctrlc::CtrlC; use futures::SinkExt; -use crate::broker::*; -use anyhow::Result; +use crate::{broker::*, Result}; pub async fn actor() -> Result<()> { let mut broker = BROKER.lock().await.register("crtlc", false).await?; diff --git a/src/actors/lan_discovery.rs b/src/actors/lan_discovery.rs index 1864c6f..7bff53f 100644 --- a/src/actors/lan_discovery.rs +++ b/src/actors/lan_discovery.rs @@ -7,8 +7,7 @@ use futures::FutureExt; use kuska_ssb::{discovery::LanBroadcast, keystore::OwnedIdentity}; -use crate::broker::*; -use anyhow::Result; +use crate::{broker::*, Result}; pub async fn actor(server_id: OwnedIdentity, rpc_port: u16) -> Result<()> { let broadcaster = LanBroadcast::new(&server_id.pk, rpc_port).await?; diff --git a/src/actors/peer.rs b/src/actors/peer.rs index 61ee606..1f8ab50 100644 --- a/src/actors/peer.rs +++ b/src/actors/peer.rs @@ -23,8 +23,7 @@ use kuska_ssb::{ rpc::{RpcReader, RpcWriter}, }; -use crate::broker::*; -use anyhow::Result; +use crate::{broker::*, Result}; use super::rpc::{ BlobsGetHandler, BlobsWantsHandler, GetHandler, HistoryStreamHandler, RpcHandler, RpcInput, diff --git a/src/actors/rpc/blobs_get.rs b/src/actors/rpc/blobs_get.rs index 7230bad..7888035 100644 --- a/src/actors/rpc/blobs_get.rs +++ b/src/actors/rpc/blobs_get.rs @@ -13,8 +13,7 @@ use kuska_ssb::{ }; use super::{RpcHandler, RpcInput}; -use crate::{broker::ChBrokerSend, storage::blob::ToBlobHashId, BLOB_STORAGE}; -use anyhow::Result; +use crate::{broker::ChBrokerSend, storage::blob::ToBlobHashId, Result, BLOB_STORAGE}; pub enum RpcBlobsGetEvent { Get(dto::BlobsGetIn), diff --git a/src/actors/rpc/blobs_wants.rs b/src/actors/rpc/blobs_wants.rs index 2359327..2f6cef6 100644 --- a/src/actors/rpc/blobs_wants.rs +++ b/src/actors/rpc/blobs_wants.rs @@ -13,9 +13,8 @@ use kuska_ssb::{ use crate::{ broker::ChBrokerSend, storage::blob::{StoBlobEvent, ToBlobHashId}, - BLOB_STORAGE, + Result, BLOB_STORAGE, }; -use anyhow::Result; use super::{RpcHandler, RpcInput}; use crate::broker::{BrokerEvent, Destination}; diff --git a/src/actors/rpc/get.rs b/src/actors/rpc/get.rs index fe6462d..43d09cf 100644 --- a/src/actors/rpc/get.rs +++ b/src/actors/rpc/get.rs @@ -7,8 +7,7 @@ use kuska_ssb::{ rpc, }; -use crate::{broker::ChBrokerSend, KV_STORAGE}; -use anyhow::Result; +use crate::{broker::ChBrokerSend, Result, KV_STORAGE}; use super::{RpcHandler, RpcInput}; diff --git a/src/actors/rpc/handler.rs b/src/actors/rpc/handler.rs index 1834252..9155e3c 100644 --- a/src/actors/rpc/handler.rs +++ b/src/actors/rpc/handler.rs @@ -1,7 +1,9 @@ use async_std::io::Write; -use crate::broker::{BrokerMessage, ChBrokerSend}; -use anyhow::Result; +use crate::{ + broker::{BrokerMessage, ChBrokerSend}, + Result, +}; use async_trait::async_trait; use kuska_ssb::{api::ApiCaller, rpc::RecvMsg}; diff --git a/src/actors/rpc/history_stream.rs b/src/actors/rpc/history_stream.rs index f4b382b..89419f6 100644 --- a/src/actors/rpc/history_stream.rs +++ b/src/actors/rpc/history_stream.rs @@ -17,9 +17,8 @@ use super::{RpcHandler, RpcInput}; use crate::{ broker::{BrokerEvent, ChBrokerSend, Destination}, storage::kv::StoKvEvent, - BLOB_STORAGE, CONFIG, KV_STORAGE, + Result, BLOB_STORAGE, CONFIG, KV_STORAGE, }; -use anyhow::Result; pub static BLOB_REGEX: Lazy = Lazy::new(|| Regex::new(r"(&[0-9A-Za-z/+=]*.sha256)").unwrap()); @@ -126,8 +125,7 @@ where fn extract_blob_refs(&mut self, msg: &Message) -> Vec { let mut refs = Vec::new(); - let msg: Result = - serde_json::from_value(msg.content().clone()); + let msg = serde_json::from_value(msg.content().clone()); if let Ok(dto::content::TypedMessage::Post { text, .. }) = msg { for cap in BLOB_REGEX.captures_iter(&text) { let key = cap.get(0).unwrap().as_str().to_owned(); diff --git a/src/actors/rpc/whoami.rs b/src/actors/rpc/whoami.rs index d9bf89f..5b5ef2e 100644 --- a/src/actors/rpc/whoami.rs +++ b/src/actors/rpc/whoami.rs @@ -9,8 +9,7 @@ use kuska_ssb::{ }; use super::{RpcHandler, RpcInput}; -use crate::broker::ChBrokerSend; -use anyhow::Result; +use crate::{broker::ChBrokerSend, Result}; pub struct WhoAmIHandler<'a, W> where diff --git a/src/actors/tcp_server.rs b/src/actors/tcp_server.rs index 59ffeb9..e5ee465 100644 --- a/src/actors/tcp_server.rs +++ b/src/actors/tcp_server.rs @@ -7,8 +7,7 @@ use futures::FutureExt; use kuska_ssb::keystore::OwnedIdentity; -use crate::broker::*; -use anyhow::Result; +use crate::{broker::*, Result}; pub async fn actor(server_id: OwnedIdentity, addr: impl ToSocketAddrs) -> Result<()> { let broker = BROKER.lock().await.register("sbot-listener", false).await?; diff --git a/src/broker.rs b/src/broker.rs index 5ebabb9..745e224 100644 --- a/src/broker.rs +++ b/src/broker.rs @@ -14,7 +14,7 @@ use once_cell::sync::Lazy; use std::collections::hash_map::HashMap; -use anyhow::Result; +use crate::Result; #[derive(Debug)] pub struct Void {} diff --git a/src/config.rs b/src/config.rs index 000ad77..4eda635 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,9 +1,10 @@ -use anyhow::Result; use kuska_ssb::{ crypto::{ToSodiumObject, ToSsbId}, keystore::OwnedIdentity, }; +use crate::Result; + #[derive(Serialize, Deserialize)] pub struct Config { pub id: String, diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..ec558db --- /dev/null +++ b/src/error.rs @@ -0,0 +1,145 @@ +use std::{error::Error as ErrorTrait, fmt, io}; + +use kuska_ssb::{api, crypto, discovery, feed, handshake, rpc}; +use serde_json; +use toml::{de, ser}; + +use crate::storage::kv; + +/// Possible solar errors. +#[derive(Debug)] +pub enum Error { + /// xdg::BaseDirectoriesError. + BaseDirectories(xdg::BaseDirectoriesError), + /// Failed to deserialization TOML. + DeserializeToml(de::Error), + /// io::Error. + IO(io::Error), + /// SSB API error. + KuskaApi(api::Error), + /// SSB cryptograpy error. + KuskaCrypto(crypto::Error), + /// LAN UDP discovery error. + KuskaDiscovery(discovery::Error), + /// SSB feed error. + KuskaFeed(feed::Error), + /// Secret handshake error. + KuskaHandshake(handshake::async_std::Error), + /// SSB RPC error. + KuskaRpc(rpc::Error), + /// Key-value database error. + KV(kv::Error), + /// Serde JSON error. + SerdeJson(serde_json::Error), + /// Failed to serialization TOML. + SerializeToml(ser::Error), + /// Unknown error. + Other(String), +} + +impl ErrorTrait for Error { + fn source(&self) -> Option<&(dyn ErrorTrait + 'static)> { + match self { + Error::IO(source) => Some(source), + _ => None, + } + } +} + +impl From for Error { + fn from(err: xdg::BaseDirectoriesError) -> Error { + Error::BaseDirectories(err) + } +} + +impl From for Error { + fn from(err: de::Error) -> Error { + Error::DeserializeToml(err) + } +} + +impl From for Error { + fn from(err: io::Error) -> Error { + Error::IO(err) + } +} + +impl From for Error { + fn from(err: api::Error) -> Error { + Error::KuskaApi(err) + } +} + +impl From for Error { + fn from(err: crypto::Error) -> Error { + Error::KuskaCrypto(err) + } +} + +impl From for Error { + fn from(err: discovery::Error) -> Error { + Error::KuskaDiscovery(err) + } +} + +impl From for Error { + fn from(err: feed::Error) -> Error { + Error::KuskaFeed(err) + } +} + +impl From for Error { + fn from(err: handshake::async_std::Error) -> Error { + Error::KuskaHandshake(err) + } +} + +impl From for Error { + fn from(err: rpc::Error) -> Error { + Error::KuskaRpc(err) + } +} + +impl From for Error { + fn from(err: kv::Error) -> Error { + Error::KV(err) + } +} + +impl From for Error { + fn from(err: serde_json::Error) -> Error { + Error::SerdeJson(err) + } +} + +impl From for Error { + fn from(err: ser::Error) -> Error { + Error::SerializeToml(err) + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "{}", + match self { + Error::BaseDirectories(err) => format!("{}", err), + Error::DeserializeToml(err) => format!("{}", err), + Error::IO(err) => format!("{}", err), + Error::KuskaApi(err) => format!("{}", err), + Error::KuskaCrypto(err) => format!("{}", err), + Error::KuskaDiscovery(err) => format!("{}", err), + Error::KuskaFeed(err) => format!("{}", err), + Error::KuskaHandshake(err) => format!("{}", err), + Error::KuskaRpc(err) => format!("{}", err), + Error::KV(err) => format!("{}", err), + Error::SerdeJson(err) => format!("{}", err), + Error::SerializeToml(err) => format!("{}", err), + Error::Other(reason) => reason.to_string(), + } + ) + } +} + +//impl PartialEq for Error { diff --git a/src/main.rs b/src/main.rs index b651acc..35b318a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,6 @@ extern crate sha2; extern crate slice_deque; #[macro_use] extern crate serde; -extern crate anyhow; extern crate toml; use async_std::{fs::File, io::ReadExt, prelude::*}; @@ -46,14 +45,17 @@ struct Opt { mod actors; mod broker; mod config; +mod error; mod storage; -use anyhow::Result; use broker::*; use config::Config; use kuska_ssb::crypto::{ToSodiumObject, ToSsbId}; use storage::{blob::BlobStorage, kv::KvStorage}; +/// Convenience Result that returns `solar::Error`. +pub type Result = std::result::Result; + const RPC_PORT: u16 = 8008; pub static KV_STORAGE: Lazy>> = From 240a641105ba11789eaa74938c7af41593ef9d84 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Wed, 30 Nov 2022 17:28:15 +0200 Subject: [PATCH 09/28] remove ci --- .github/workflows/clippy.yaml | 13 ------------- .github/workflows/rust.yaml | 16 ---------------- .github/workflows/rustfmt.yaml | 15 --------------- 3 files changed, 44 deletions(-) delete mode 100644 .github/workflows/clippy.yaml delete mode 100644 .github/workflows/rust.yaml delete mode 100644 .github/workflows/rustfmt.yaml diff --git a/.github/workflows/clippy.yaml b/.github/workflows/clippy.yaml deleted file mode 100644 index 9fbe9db..0000000 --- a/.github/workflows/clippy.yaml +++ /dev/null @@ -1,13 +0,0 @@ -on: [push] - -name: Clippy check -jobs: - clippy_check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - run: rustup component add clippy - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features -- -D warnings diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml deleted file mode 100644 index 4abdd97..0000000 --- a/.github/workflows/rust.yaml +++ /dev/null @@ -1,16 +0,0 @@ - -name: Rust - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/.github/workflows/rustfmt.yaml b/.github/workflows/rustfmt.yaml deleted file mode 100644 index bc7edf4..0000000 --- a/.github/workflows/rustfmt.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: Rustfmt - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Install rustfmt - run: rustup component add rustfmt - - name: Check style - run: cargo fmt --all -- --check --config=merge_imports=true From 92e63ba25b641041cc46bc0bbb94b57c9b87457c Mon Sep 17 00:00:00 2001 From: mycognosist Date: Thu, 1 Dec 2022 09:55:16 +0200 Subject: [PATCH 10/28] bump dependencies --- Cargo.lock | 378 +++++++++++++++++++++++--------------------- Cargo.toml | 20 +-- src/storage/blob.rs | 4 +- 3 files changed, 210 insertions(+), 192 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b30813..1e99d3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,10 +3,10 @@ version = 3 [[package]] -name = "adler32" -version = "1.2.0" +name = "adler" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" @@ -154,7 +154,7 @@ dependencies = [ "async-io", "async-lock", "async-process", - "crossbeam-utils 0.8.14", + "crossbeam-utils", "futures-channel", "futures-core", "futures-io", @@ -220,7 +220,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi 0.3.9", ] @@ -237,6 +237,12 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "bitflags" version = "1.3.2" @@ -245,25 +251,13 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - [[package]] name = "blocking" version = "1.3.0" @@ -284,12 +278,6 @@ version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.4.3" @@ -350,15 +338,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "codespan-reporting" version = "0.11.1" @@ -375,7 +354,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" dependencies = [ - "crossbeam-utils 0.8.14", + "crossbeam-utils", ] [[package]] @@ -384,6 +363,15 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -395,37 +383,34 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.8.2" +version = "0.9.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" dependencies = [ "autocfg", - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "lazy_static", - "maybe-uninit", + "cfg-if 1.0.0", + "crossbeam-utils", "memoffset", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", + "cfg-if 1.0.0", ] [[package]] -name = "crossbeam-utils" -version = "0.8.14" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "cfg-if 1.0.0", + "generic-array", + "typenum", ] [[package]] @@ -494,11 +479,12 @@ dependencies = [ [[package]] name = "digest" -version = "0.8.1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "generic-array", + "block-buffer", + "crypto-common", ] [[package]] @@ -533,28 +519,43 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.7.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ - "atty", "humantime", + "is-terminal", "log", "regex", "termcolor", ] [[package]] -name = "event-listener" -version = "2.5.3" +name = "errno" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi 0.3.9", +] [[package]] -name = "fake-simd" +name = "errno-dragonfly" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fastrand" @@ -565,6 +566,16 @@ dependencies = [ "instant", ] +[[package]] +name = "flate2" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fs2" version = "0.4.3" @@ -702,11 +713,12 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generic-array" -version = "0.12.4" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", + "version_check", ] [[package]] @@ -731,17 +743,6 @@ dependencies = [ "libc", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.8" @@ -795,6 +796,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -803,12 +813,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "humantime" -version = "1.3.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" @@ -853,6 +860,34 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes 1.0.3", + "rustix 0.36.4", + "windows-sys", +] + [[package]] name = "itoa" version = "1.0.4" @@ -898,7 +933,7 @@ version = "0.4.1" dependencies = [ "async-std", "async-stream", - "base64", + "base64 0.11.0", "dirs 2.0.2", "futures", "get_if_addrs", @@ -934,26 +969,6 @@ version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" -[[package]] -name = "libflate" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05605ab2bce11bcfc0e9c635ff29ef8b2ea83f29be257ee7d730cac3ee373093" -dependencies = [ - "adler32", - "crc32fast", - "libflate_lz77", -] - -[[package]] -name = "libflate_lz77" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39a734c0493409afcd49deee13c006a04e3586b9761a03543c6272c9c51f2f5a" -dependencies = [ - "rle-decode-fast", -] - [[package]] name = "libsodium-sys" version = "0.2.7" @@ -975,12 +990,25 @@ dependencies = [ "cc", ] +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + +[[package]] +name = "linux-raw-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" + [[package]] name = "lock_api" -version = "0.3.4" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ + "autocfg", "scopeguard", ] @@ -1003,12 +1031,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.5.0" @@ -1017,13 +1039,22 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.5.6" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "nix" version = "0.25.0" @@ -1061,12 +1092,6 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "parking" version = "2.0.0" @@ -1075,24 +1100,25 @@ checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" -version = "0.10.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ + "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.7.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", + "cfg-if 1.0.0", + "instant", "libc", - "redox_syscall 0.1.57", + "redox_syscall", "smallvec", "winapi 0.3.9", ] @@ -1170,25 +1196,19 @@ dependencies = [ [[package]] name = "procfs" -version = "0.7.9" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c434e93ef69c216e68e4f417c927b4f31502c3560b72cfdb6827e2321c5c6b3e" +checksum = "2dfb6451c91904606a1abe93e83a8ec851f45827fa84273f256ade45dc095818" dependencies = [ "bitflags", "byteorder", "chrono", + "flate2", "hex", "lazy_static", - "libc", - "libflate", + "rustix 0.35.13", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - [[package]] name = "quote" version = "1.0.21" @@ -1213,25 +1233,23 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "getrandom 0.1.16", "libc", "rand_chacha", - "rand_core 0.5.1", - "rand_hc", + "rand_core 0.6.4", ] [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", + "rand_core 0.6.4", ] [[package]] @@ -1251,20 +1269,11 @@ checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] name = "rand_core" -version = "0.5.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -1276,12 +1285,6 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "redox_syscall" version = "0.2.16" @@ -1297,8 +1300,8 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", - "redox_syscall 0.2.16", + "getrandom", + "redox_syscall", "thiserror", ] @@ -1329,10 +1332,32 @@ dependencies = [ ] [[package]] -name = "rle-decode-fast" -version = "1.0.3" +name = "rustix" +version = "0.35.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 0.7.5", + "libc", + "linux-raw-sys 0.0.46", + "windows-sys", +] + +[[package]] +name = "rustix" +version = "0.36.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 1.0.3", + "libc", + "linux-raw-sys 0.1.3", + "windows-sys", +] [[package]] name = "ryu" @@ -1405,14 +1430,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.8.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ - "block-buffer", + "cfg-if 1.0.0", + "cpufeatures", "digest", - "fake-simd", - "opaque-debug", ] [[package]] @@ -1445,13 +1469,13 @@ dependencies = [ [[package]] name = "sled" -version = "0.31.0" +version = "0.34.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb6824dde66ad33bf20c6e8476f5b82b871bc8bc3c129a10ea2f7dae5060fa3" +checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935" dependencies = [ "crc32fast", "crossbeam-epoch", - "crossbeam-utils 0.7.2", + "crossbeam-utils", "fs2", "fxhash", "libc", @@ -1499,14 +1523,14 @@ dependencies = [ "async-ctrlc", "async-std", "async-trait", - "base64", + "base64 0.13.1", "env_logger", "futures", "kuska-ssb", "log", "once_cell", "procfs", - "rand 0.7.3", + "rand 0.8.5", "regex", "serde", "serde_cbor", @@ -1693,12 +1717,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index de5ef97..2d292c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,24 +13,24 @@ path = "src/main.rs" [dependencies] #kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } kuska-ssb = { path = "../kuska-ssb" } -async-std = { version = "1", features=["unstable","attributes"] } +async-std = { version = "1", features=["unstable", "attributes"] } futures = "0.3" serde = { version = "1", features = ["derive"] } -serde_json = { version = "1", features=["preserve_order","arbitrary_precision"] } +serde_json = { version = "1", features=["preserve_order", "arbitrary_precision"] } serde_cbor = "0.11" tempdir = "0.3" log = "0.4" -env_logger = "0.7" +env_logger = "0.10" async-ctrlc = "1" snap = "1" -rand = "0.7" -sled = "0.31" -xdg = "2.2" -base64 = "0.11" -once_cell = "1.3" +rand = "0.8" +sled = "0.34" +xdg = "2.4" +base64 = "0.13" +once_cell = "1.16" async-trait = "0.1" -sha2 = "0.8" -procfs = "0.7" +sha2 = "0.10" +procfs = "0.14" slice-deque = "0.3" toml = "0.5" regex = "1" diff --git a/src/storage/blob.rs b/src/storage/blob.rs index 0b77451..dd7046a 100644 --- a/src/storage/blob.rs +++ b/src/storage/blob.rs @@ -25,8 +25,8 @@ pub trait ToBlobHashId { impl ToBlobHashId for &[u8] { fn blob_hash_id(&self) -> String { let mut hasher = Sha256::new(); - hasher.input(self); - format!("&{}.sha256", base64::encode(&hasher.result())) + hasher.update(self); + format!("&{}.sha256", base64::encode(&hasher.finalize())) } } From 6fc98ae23964ada268555dd17ceb2b9887a9aea2 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Thu, 1 Dec 2022 09:55:27 +0200 Subject: [PATCH 11/28] update notes --- notes | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/notes b/notes index dc055dd..4fb9fae 100644 --- a/notes +++ b/notes @@ -9,13 +9,17 @@ x remove sensor code x remove plotting dep - - custom error type + x custom error type x remove anyhow and thiserror deps x implement error type x implement result type - / implement From for each variant + x implement From for each variant - - replace env_logger with lighter option + x remove ci (annoying for now) + +----- + + nice to haves... - replace serde with nanoserde or miniserde - eventually, replace in kuska-ssb too @@ -27,6 +31,10 @@ https://github.com/xvxx/vial/blob/master/src/lib.rs#L241 [ phase 2: move relevant code to new workspace ] + - might be time to create a workspace + - start working on the connection scheduler + - or replication core + [ phase 3: write connection handler ] [ phase 4: write ebt replication ] From 16d2ad6fd8723a943d93a3b9f3ae34287ec4527a Mon Sep 17 00:00:00 2001 From: mycognosist Date: Thu, 1 Dec 2022 09:55:38 +0200 Subject: [PATCH 12/28] fix typo --- src/actors/peer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actors/peer.rs b/src/actors/peer.rs index 1f8ab50..f72e6f5 100644 --- a/src/actors/peer.rs +++ b/src/actors/peer.rs @@ -75,7 +75,7 @@ pub async fn actor_inner(id: OwnedIdentity, connect: Connect) -> Result<()> { return Ok(()); } info!( - "💃 recieved connection from peer {}", + "💃 received connection from peer {}", handshake.peer_pk.to_ssb_id() ); From eb08c9049f69aad2b33db3b50509a629b97d63f3 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 08:41:08 +0200 Subject: [PATCH 13/28] revert to git path for kuska-ssb crate --- Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2d292c2..e0ddc37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,7 @@ name = "solar" path = "src/main.rs" [dependencies] -#kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } -kuska-ssb = { path = "../kuska-ssb" } +kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } async-std = { version = "1", features=["unstable", "attributes"] } futures = "0.3" serde = { version = "1", features = ["derive"] } From 50105d9ec78857a138ca6a9f19a08fa4e82cefe1 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 08:42:40 +0200 Subject: [PATCH 14/28] add comments, fix typos and indentation --- src/actors/lan_discovery.rs | 2 +- src/actors/peer.rs | 78 +++++++++++++++++++++++++------- src/actors/rpc/history_stream.rs | 5 +- 3 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/actors/lan_discovery.rs b/src/actors/lan_discovery.rs index 7bff53f..aee7bdf 100644 --- a/src/actors/lan_discovery.rs +++ b/src/actors/lan_discovery.rs @@ -25,7 +25,7 @@ pub async fn actor(server_id: OwnedIdentity, rpc_port: u16) -> Result<()> { recv = socket.recv_from(&mut buf).fuse() => { if let Ok((amt, _)) = recv { if let Err(err) = process_broadcast(&server_id,&buf[..amt]).await { - warn!("failed to process brodcast: {:?}",err); + warn!("failed to process broadcast: {:?}",err); } } } diff --git a/src/actors/peer.rs b/src/actors/peer.rs index f72e6f5..bc2571d 100644 --- a/src/actors/peer.rs +++ b/src/actors/peer.rs @@ -41,6 +41,8 @@ pub enum Connect { }, } +/// A list (`HashSet`) of public keys representing peers to whom we are +/// currently connected. pub static CONNECTED_PEERS: Lazy>>> = Lazy::new(|| Arc::new(RwLock::new(HashSet::new()))); @@ -51,29 +53,50 @@ pub async fn actor(id: OwnedIdentity, connect: Connect) -> Result<()> { Ok(()) } +/// Handle a TCP connection, update the list of connected peers, register the +/// peer actor endpoint, spawn the peer loop and report on the connection +/// outcome. pub async fn actor_inner(id: OwnedIdentity, connect: Connect) -> Result<()> { + // Parse the public key and secret key from the identity. let OwnedIdentity { pk, sk, .. } = id; + + // Handle a TCP connection event (inbound or outbound). let (stream, handshake) = match connect { + // Handle an outgoing TCP connection event. Connect::TcpServer { server, port, peer_pk, } => { + // First check if we are already connected to the selected peer. + // If yes, return immediately. + // If no, continue with the connection attempt. if CONNECTED_PEERS.read().await.contains(&peer_pk) { return Ok(()); } + + // Define the server address and port. let server_port = format!("{}:{}", server, port); + // Attempt a TCP connection. let mut stream = TcpStream::connect(server_port).await?; + // Attempt a secret handshake. let handshake = handshake_client(&mut stream, ssb_net_id(), pk, sk, peer_pk).await?; + info!("💃 connected to peer {}", handshake.peer_pk.to_ssb_id()); (stream, handshake) } + // Handle an incoming TCP connection event. Connect::ClientStream { mut stream } => { + // Attempt a secret handshake. let handshake = handshake_server(&mut stream, ssb_net_id(), pk, sk).await?; + // Check if we are already connected to the selected peer. + // If yes, return immediately. + // If no, return the stream and handshake. if CONNECTED_PEERS.read().await.contains(&handshake.peer_pk) { return Ok(()); } + info!( "💃 received connection from peer {}", handshake.peer_pk.to_ssb_id() @@ -83,6 +106,7 @@ pub async fn actor_inner(id: OwnedIdentity, connect: Connect) -> Result<()> { } }; + // Register the "peer" actor endpoint with the broker. let ActorEndpoint { ch_terminate, mut ch_broker, @@ -91,8 +115,13 @@ pub async fn actor_inner(id: OwnedIdentity, connect: Connect) -> Result<()> { .. } = BROKER.lock().await.register("peer", true).await?; + // Parse the peer public key from the handshake. let peer_pk = handshake.peer_pk; + + // Add the peer to the list of connected peers. CONNECTED_PEERS.write().await.insert(peer_pk); + + // Spawn the peer loop (responsible for negotiating RPC requests). let res = peer_loop( actor_id, &stream, @@ -102,6 +131,8 @@ pub async fn actor_inner(id: OwnedIdentity, connect: Connect) -> Result<()> { ch_msg.unwrap(), ) .await; + + // Remove the peer from the list of connected peers. CONNECTED_PEERS.write().await.remove(&peer_pk); if let Err(err) = res { @@ -123,15 +154,19 @@ async fn peer_loop Result<()> { + // Parse the peer public key from the handshake. let peer_ssb_id = handshake.peer_pk.to_ssb_id(); + // Instantiate a box stream and split it into reader and writer streams. let (box_stream_read, box_stream_write) = BoxStream::from_handshake(reader, writer, handshake, 0x8000).split_read_write(); + // Instantiate RPC reader and writer using the box streams. let rpc_reader = RpcReader::new(box_stream_read); let rpc_writer = RpcWriter::new(box_stream_write); let mut api = ApiCaller::new(rpc_writer); + // Instantiate the MUXRPC handlers. let mut history_stream_handler = HistoryStreamHandler::new(actor_id); let mut whoami_handler = WhoAmIHandler::new(&peer_ssb_id); let mut get_handler = GetHandler::default(); @@ -146,31 +181,39 @@ async fn peer_loop { - break; - }, - packet = rpc_recv_stream.select_next_some() => { - let (rpc_id, packet) = packet; - RpcInput::Network(rpc_id,packet) - }, - msg = ch_msg.next().fuse() => { - if let Some(msg) = msg { - RpcInput::Message(msg) - } else { - RpcInput::None - } - }, - _ = task::sleep(Duration::from_secs(1)).fuse() => { - RpcInput::Timer - }, + _value = ch_terminate_fuse => { + break; + }, + packet = rpc_recv_stream.select_next_some() => { + let (rpc_id, packet) = packet; + RpcInput::Network(rpc_id,packet) + }, + msg = ch_msg.next().fuse() => { + if let Some(msg) = msg { + RpcInput::Message(msg) + } else { + RpcInput::None + } + }, + _ = task::sleep(Duration::from_secs(1)).fuse() => { + RpcInput::Timer + }, }; let mut handled = false; @@ -191,5 +234,6 @@ async fn peer_loop, req_no: i32, req: &rpc::Body, From 6ea1e368cdd0654cdc8e59dbb025bfaff262ef5c Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 08:46:35 +0200 Subject: [PATCH 15/28] deser into msg value, not kvt --- src/actors/rpc/history_stream.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actors/rpc/history_stream.rs b/src/actors/rpc/history_stream.rs index 5faf0f6..8de3d76 100644 --- a/src/actors/rpc/history_stream.rs +++ b/src/actors/rpc/history_stream.rs @@ -7,7 +7,7 @@ use regex::Regex; use kuska_ssb::{ api::{dto, ApiCaller, ApiMethod}, - feed::{Feed, Message}, + feed::Message, rpc, }; @@ -143,7 +143,7 @@ where res: &[u8], ) -> Result { if self.friends.contains_key(&req_no) { - let msg = Feed::from_slice(res)?.into_message()?; + let msg = Message::from_slice(res)?; let last_feed = KV_STORAGE .read() .await From fa6692d582bdc2303895a9aa40c24bb920a43c81 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 08:47:12 +0200 Subject: [PATCH 16/28] satisfy clippy --- src/error.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index ec558db..830f5b1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,7 +1,6 @@ use std::{error::Error as ErrorTrait, fmt, io}; use kuska_ssb::{api, crypto, discovery, feed, handshake, rpc}; -use serde_json; use toml::{de, ser}; use crate::storage::kv; From 5ab2e60355439d50fbf6bd2dfb9154381a037ead Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 09:07:40 +0200 Subject: [PATCH 17/28] allow setting sled cache size via env var (with fallback) --- src/main.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 35b318a..b682079 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,8 @@ use async_std::{fs::File, io::ReadExt, prelude::*}; use async_std::sync::{Arc, RwLock}; use once_cell::sync::{Lazy, OnceCell}; -use std::path::PathBuf; +use sled::Config as KvConfig; +use std::{env, path::PathBuf}; use structopt::StructOpt; #[derive(StructOpt, Debug)] @@ -146,10 +147,23 @@ async fn main() -> Result<()> { base64::encode(&owned_id.pk[..]) ); + // Read KV database cache capacity setting from environment variable. + // Define default value (1 GB) if env var is unset. + // TODO: find a neater way to do this. Consider using config file. + let kv_cache_capacity: u64 = match env::var("SLED_CACHE_CAPACITY") { + Ok(val) => val.parse().unwrap_or(1000 * 1000 * 1000), + Err(_) => 1000 * 1000 * 1000, + }; + + // Define configuration parameters for KV database (Sled). + let kv_storage_config = KvConfig::new() + .path(&feeds_folder) + .cache_capacity(kv_cache_capacity); + KV_STORAGE .write() .await - .open(&feeds_folder, BROKER.lock().await.create_sender())?; + .open(kv_storage_config, BROKER.lock().await.create_sender())?; BLOB_STORAGE .write() From 801cf886d46ae303af094b400824796747f9f48c Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 09:08:20 +0200 Subject: [PATCH 18/28] pass config struct as arg, instead of path --- src/storage/kv.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storage/kv.rs b/src/storage/kv.rs index 74b4458..4eda679 100644 --- a/src/storage/kv.rs +++ b/src/storage/kv.rs @@ -68,8 +68,8 @@ impl std::error::Error for Error {} pub type Result = std::result::Result; impl KvStorage { - pub fn open(&mut self, path: &std::path::Path, ch_broker: ChBrokerSend) -> Result<()> { - self.db = Some(sled::open(path)?); + pub fn open(&mut self, config: sled::Config, ch_broker: ChBrokerSend) -> Result<()> { + self.db = Some(config.open()?); self.ch_broker = Some(ch_broker); Ok(()) } From b7e29a22cdd3a91bb2dfbca4a32eaf7ea159751a Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 09:08:37 +0200 Subject: [PATCH 19/28] update lockfile and ignore list --- .gitignore | 1 + Cargo.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 53eaa21..a00ce94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target **/*.rs.bk +go_sbot_benchmarks diff --git a/Cargo.lock b/Cargo.lock index 1e99d3b..23bd631 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -930,6 +930,7 @@ dependencies = [ [[package]] name = "kuska-ssb" version = "0.4.1" +source = "git+https://github.com/Kuska-ssb/ssb?branch=master#cbebe1633f0c72f165c94226545af2e9c3877c3b" dependencies = [ "async-std", "async-stream", From 460fac9d3a75c347367c617df55d395edb1e44b4 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 10:43:02 +0200 Subject: [PATCH 20/28] support parsing of multiple multiaddresses from a single lan broadcast msg --- src/actors/lan_discovery.rs | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/actors/lan_discovery.rs b/src/actors/lan_discovery.rs index aee7bdf..eb4c83d 100644 --- a/src/actors/lan_discovery.rs +++ b/src/actors/lan_discovery.rs @@ -24,7 +24,7 @@ pub async fn actor(server_id: OwnedIdentity, rpc_port: u16) -> Result<()> { _ = ch_terminate => break, recv = socket.recv_from(&mut buf).fuse() => { if let Ok((amt, _)) = recv { - if let Err(err) = process_broadcast(&server_id,&buf[..amt]).await { + if let Err(err) = process_broadcast(&server_id, &buf[..amt]).await { warn!("failed to process broadcast: {:?}",err); } } @@ -38,19 +38,26 @@ pub async fn actor(server_id: OwnedIdentity, rpc_port: u16) -> Result<()> { Ok(()) } async fn process_broadcast(server_id: &OwnedIdentity, buff: &[u8]) -> Result<()> { + // Parse the broadcast message to string. let msg = String::from_utf8_lossy(buff); - if let Some((server, port, peer_pk)) = LanBroadcast::parse(&msg) { - Broker::spawn(super::peer::actor( - server_id.clone(), - super::peer::Connect::TcpServer { - server, - port, - peer_pk, - }, - )); - } else { - warn!("failed to parse broadcast {}", msg); + // Split and collect the multiserver addresses from the broadcast message. + // One string may include several addresses, such as `net` and `wss`. + let addresses: Vec<&str> = msg.split(';').collect(); + + for address in addresses { + if let Some((server, port, peer_pk)) = LanBroadcast::parse(address) { + Broker::spawn(super::peer::actor( + server_id.clone(), + super::peer::Connect::TcpServer { + server, + port, + peer_pk, + }, + )); + } else { + warn!("failed to parse broadcast {}", address); + } } Ok(()) From f61a57cc732cbabea2b38ab5410e10da83da4bd8 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 11:03:31 +0200 Subject: [PATCH 21/28] Revert "support parsing of multiple multiaddresses from a single lan broadcast msg" Parsing is already performed in kuska-ssb/src/discovery/lan.rs:84. This reverts commit 460fac9d3a75c347367c617df55d395edb1e44b4. --- src/actors/lan_discovery.rs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/actors/lan_discovery.rs b/src/actors/lan_discovery.rs index eb4c83d..aee7bdf 100644 --- a/src/actors/lan_discovery.rs +++ b/src/actors/lan_discovery.rs @@ -24,7 +24,7 @@ pub async fn actor(server_id: OwnedIdentity, rpc_port: u16) -> Result<()> { _ = ch_terminate => break, recv = socket.recv_from(&mut buf).fuse() => { if let Ok((amt, _)) = recv { - if let Err(err) = process_broadcast(&server_id, &buf[..amt]).await { + if let Err(err) = process_broadcast(&server_id,&buf[..amt]).await { warn!("failed to process broadcast: {:?}",err); } } @@ -38,26 +38,19 @@ pub async fn actor(server_id: OwnedIdentity, rpc_port: u16) -> Result<()> { Ok(()) } async fn process_broadcast(server_id: &OwnedIdentity, buff: &[u8]) -> Result<()> { - // Parse the broadcast message to string. let msg = String::from_utf8_lossy(buff); - // Split and collect the multiserver addresses from the broadcast message. - // One string may include several addresses, such as `net` and `wss`. - let addresses: Vec<&str> = msg.split(';').collect(); - - for address in addresses { - if let Some((server, port, peer_pk)) = LanBroadcast::parse(address) { - Broker::spawn(super::peer::actor( - server_id.clone(), - super::peer::Connect::TcpServer { - server, - port, - peer_pk, - }, - )); - } else { - warn!("failed to parse broadcast {}", address); - } + if let Some((server, port, peer_pk)) = LanBroadcast::parse(&msg) { + Broker::spawn(super::peer::actor( + server_id.clone(), + super::peer::Connect::TcpServer { + server, + port, + peer_pk, + }, + )); + } else { + warn!("failed to parse broadcast {}", msg); } Ok(()) From b89605778ee4635a5980e8065a62a26a34c1cfbc Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 12:06:53 +0200 Subject: [PATCH 22/28] fix typos --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c2733c..9751097 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Rust](https://github.com/Kuska-ssb/solar/workflows/Rust/badge.svg) -The idea behing solar is to enable community hardware devices to speaks [Secure Scuttlebut](https://scuttlebutt.nz/), using the [Kuska](https://github.com/Kuska-ssb) rust libraries and mainly based on [async_std](https://async.rs/) +The idea behing solar is to enable community hardware devices to speak [Secure Scuttlebutt](https://scuttlebutt.nz/) using the [Kuska](https://github.com/Kuska-ssb) rust libraries, mainly based on [async_std](https://async.rs/). Current status is: From 6ee2e94d114dce258dcf459b08d7393b488a5168 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 15:16:26 +0200 Subject: [PATCH 23/28] add jsonrpc server crate and alphabetise dependencies --- Cargo.lock | 508 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 33 ++-- 2 files changed, 518 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23bd631..8129ce8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,13 +249,34 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + [[package]] name = "block-buffer" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ - "generic-array", + "generic-array 0.14.6", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", ] [[package]] @@ -272,18 +293,49 @@ dependencies = [ "futures-lite", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "memchr", +] + [[package]] name = "bumpalo" version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + [[package]] name = "c_linked_list" version = "1.1.1" @@ -409,7 +461,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array", + "generic-array 0.14.6", "typenum", ] @@ -477,13 +529,22 @@ dependencies = [ "syn", ] +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + [[package]] name = "digest" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer", + "block-buffer 0.10.3", "crypto-common", ] @@ -557,6 +618,12 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + [[package]] name = "fastrand" version = "1.8.0" @@ -576,6 +643,21 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs2" version = "0.4.3" @@ -592,6 +674,22 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + [[package]] name = "futures" version = "0.3.25" @@ -711,6 +809,15 @@ version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + [[package]] name = "generic-array" version = "0.14.6" @@ -743,6 +850,17 @@ dependencies = [ "libc", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.8" @@ -754,6 +872,19 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "globset" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + [[package]] name = "gloo-timers" version = "0.2.5" @@ -811,6 +942,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + [[package]] name = "humantime" version = "2.1.0" @@ -841,6 +978,16 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.2" @@ -876,6 +1023,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + [[package]] name = "is-terminal" version = "0.4.1" @@ -903,6 +1059,64 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpc-core" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" +dependencies = [ + "futures", + "futures-executor", + "futures-util", + "log", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "jsonrpc-server-utils" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4fdea130485b572c39a460d50888beb00afb3e35de23ccd7fad8ff19f0e0d4" +dependencies = [ + "bytes 1.3.0", + "futures", + "globset", + "jsonrpc-core", + "lazy_static", + "log", + "tokio", + "tokio-stream", + "tokio-util", + "unicase", +] + +[[package]] +name = "jsonrpc-ws-server" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f892c7d766369475ab7b0669f417906302d7c0fb521285c0a0c92e52e7c8e946" +dependencies = [ + "futures", + "jsonrpc-core", + "jsonrpc-server-utils", + "log", + "parity-ws", + "parking_lot", + "slab", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "kuska-handshake" version = "0.2.0" @@ -964,6 +1178,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.137" @@ -1056,6 +1276,72 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" +dependencies = [ + "lazycell", + "log", + "mio 0.6.23", + "slab", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "net2" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d0df99cfcd2530b2e694f6e17e7f37b8e26bb23983ac530c0c97408837c631" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + [[package]] name = "nix" version = "0.25.0" @@ -1087,12 +1373,46 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +dependencies = [ + "hermit-abi 0.1.19", + "libc", +] + [[package]] name = "once_cell" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "parity-ws" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5983d3929ad50f12c3eb9a6743f19d691866ecd44da74c0a3308c3f8a56df0c6" +dependencies = [ + "byteorder", + "bytes 0.4.12", + "httparse", + "log", + "mio 0.6.23", + "mio-extras", + "rand 0.7.3", + "sha-1", + "slab", + "url", +] + [[package]] name = "parking" version = "2.0.0" @@ -1124,6 +1444,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1232,6 +1558,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -1239,10 +1578,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + [[package]] name = "rand_chacha" version = "0.3.1" @@ -1268,13 +1617,31 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.8", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -1301,7 +1668,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom", + "getrandom 0.2.8", "redox_syscall", "thiserror", ] @@ -1429,6 +1796,18 @@ dependencies = [ "serde", ] +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.10.6" @@ -1437,7 +1816,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest", + "digest 0.10.6", ] [[package]] @@ -1527,6 +1906,7 @@ dependencies = [ "base64 0.13.1", "env_logger", "futures", + "jsonrpc-ws-server", "kuska-ssb", "log", "once_cell", @@ -1646,6 +2026,63 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" +dependencies = [ + "autocfg", + "bytes 1.3.0", + "libc", + "memchr", + "mio 0.8.5", + "num_cpus", + "pin-project-lite", + "socket2", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +dependencies = [ + "bytes 1.3.0", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.9" @@ -1661,12 +2098,36 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + [[package]] name = "unicode-ident" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.10.0" @@ -1679,6 +2140,17 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "value-bag" version = "1.0.0-alpha.9" @@ -1718,6 +2190,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -1831,6 +2309,12 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -1909,6 +2393,16 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "xdg" version = "2.4.1" diff --git a/Cargo.toml b/Cargo.toml index e0ddc37..74f5b0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,26 +11,27 @@ name = "solar" path = "src/main.rs" [dependencies] -kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } +async-ctrlc = "1" async-std = { version = "1", features=["unstable", "attributes"] } +async-trait = "0.1" +base64 = "0.13" +env_logger = "0.10" futures = "0.3" -serde = { version = "1", features = ["derive"] } -serde_json = { version = "1", features=["preserve_order", "arbitrary_precision"] } -serde_cbor = "0.11" -tempdir = "0.3" +jsonrpc-ws-server = "18" +kuska-ssb = { git = "https://github.com/Kuska-ssb/ssb", branch = "master" } log = "0.4" -env_logger = "0.10" -async-ctrlc = "1" -snap = "1" -rand = "0.8" -sled = "0.34" -xdg = "2.4" -base64 = "0.13" once_cell = "1.16" -async-trait = "0.1" -sha2 = "0.10" procfs = "0.14" -slice-deque = "0.3" -toml = "0.5" +rand = "0.8" regex = "1" +serde = { version = "1", features = ["derive"] } +serde_cbor = "0.11" +serde_json = { version = "1", features=["preserve_order", "arbitrary_precision"] } +sha2 = "0.10" +sled = "0.34" +slice-deque = "0.3" +snap = "1" structopt = "0.3" +tempdir = "0.3" +toml = "0.5" +xdg = "2.4" From d628b373bb535e94f177c27f08f03dfdbb7aa941 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 15:16:56 +0200 Subject: [PATCH 24/28] fix indentation --- src/actors/tcp_server.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/actors/tcp_server.rs b/src/actors/tcp_server.rs index e5ee465..1ebd477 100644 --- a/src/actors/tcp_server.rs +++ b/src/actors/tcp_server.rs @@ -19,18 +19,20 @@ pub async fn actor(server_id: OwnedIdentity, addr: impl ToSocketAddrs) -> Result loop { select_biased! { - _ = ch_terminate => break, - stream = incoming.next().fuse() => { - if let Some(stream) = stream { - if let Ok(stream) = stream { - Broker::spawn(super::peer::actor(server_id.clone(), super::peer::Connect::ClientStream{stream})); + _ = ch_terminate => break, + stream = incoming.next().fuse() => { + if let Some(stream) = stream { + if let Ok(stream) = stream { + Broker::spawn(super::peer::actor(server_id.clone(), super::peer::Connect::ClientStream{stream})); + } + } else { + break; } - } else { - break; - } - }, + }, } } + let _ = broker.ch_terminated.send(Void {}); + Ok(()) } From 3aab08758f516d469e6204144acbd1ca76983611 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 15:17:52 +0200 Subject: [PATCH 25/28] add jsonrpc module, implement from error impls and spawn actor --- src/actors/jsonrpc_server.rs | 61 ++++++++++++++++++++++++++++++++++++ src/actors/mod.rs | 1 + src/error.rs | 20 +++++++++++- src/main.rs | 7 ++++- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/actors/jsonrpc_server.rs diff --git a/src/actors/jsonrpc_server.rs b/src/actors/jsonrpc_server.rs new file mode 100644 index 0000000..42e8de3 --- /dev/null +++ b/src/actors/jsonrpc_server.rs @@ -0,0 +1,61 @@ +// src/actors/json_rpc_server.rs + +use async_std::task; +use futures::FutureExt; +use jsonrpc_ws_server::jsonrpc_core::*; +use jsonrpc_ws_server::ServerBuilder; + +use kuska_ssb::keystore::OwnedIdentity; + +use crate::{broker::*, Result}; + +/// Register the JSON-RPC server endpoint, define the JSON-RPC methods +/// and spawn the server. +/// +/// Listens for a termination signal from the broker. When received, the +/// JSON-RPC server is closed and a terminated signal is sent to the broker. +pub async fn actor(server_id: OwnedIdentity, port: u16) -> Result<()> { + let broker = BROKER + .lock() + .await + .register("jsonrpc-listener", false) + .await?; + + let ch_terminate = broker.ch_terminate.fuse(); + + let mut io = IoHandler::default(); + + // Simple `ping` endpoint. + io.add_sync_method("ping", |_| Ok(Value::String("pong!".to_owned()))); + + // Return the public key of the local SSB server. + io.add_sync_method("whoami", move |_| { + Ok(Value::String(server_id.id.to_owned())) + }); + + let server_addr = format!("0.0.0.0:{}", port); + let server = ServerBuilder::new(io).start(&server_addr.parse()?)?; + + // Create a close handle to be used when the termination signal is + // received. + let close_handle = server.close_handle(); + + // Start the JSON-RPC server in a task. + // This allows us to listen for the termination signal (without blocking). + task::spawn(async { + server.wait().expect("json-rpc server startup failed"); + }); + + // Listen for termination signal from broker. + if let Err(err) = ch_terminate.await { + warn!("ch_terminate sender dropped: {}", err) + } + + // When received, close (stop) the server. + close_handle.close(); + + // Then send terminated signal back to broker. + let _ = broker.ch_terminated.send(Void {}); + + Ok(()) +} diff --git a/src/actors/mod.rs b/src/actors/mod.rs index ae008bb..8f4b5c4 100644 --- a/src/actors/mod.rs +++ b/src/actors/mod.rs @@ -1,4 +1,5 @@ pub mod ctrlc; +pub mod jsonrpc_server; pub mod lan_discovery; pub mod peer; pub mod rpc; diff --git a/src/error.rs b/src/error.rs index 830f5b1..76e254e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use std::{error::Error as ErrorTrait, fmt, io}; +use std::{error::Error as ErrorTrait, fmt, io, net}; use kuska_ssb::{api, crypto, discovery, feed, handshake, rpc}; use toml::{de, ser}; @@ -8,12 +8,16 @@ use crate::storage::kv; /// Possible solar errors. #[derive(Debug)] pub enum Error { + /// IP address parsing error. + AddrParse(net::AddrParseError), /// xdg::BaseDirectoriesError. BaseDirectories(xdg::BaseDirectoriesError), /// Failed to deserialization TOML. DeserializeToml(de::Error), /// io::Error. IO(io::Error), + /// JSON-RPC server error. + JsonRpc(jsonrpc_ws_server::Error), /// SSB API error. KuskaApi(api::Error), /// SSB cryptograpy error. @@ -45,6 +49,12 @@ impl ErrorTrait for Error { } } +impl From for Error { + fn from(err: net::AddrParseError) -> Error { + Error::AddrParse(err) + } +} + impl From for Error { fn from(err: xdg::BaseDirectoriesError) -> Error { Error::BaseDirectories(err) @@ -57,6 +67,12 @@ impl From for Error { } } +impl From for Error { + fn from(err: jsonrpc_ws_server::Error) -> Error { + Error::JsonRpc(err) + } +} + impl From for Error { fn from(err: io::Error) -> Error { Error::IO(err) @@ -123,9 +139,11 @@ impl fmt::Display for Error { f, "{}", match self { + Error::AddrParse(err) => format!("{}", err), Error::BaseDirectories(err) => format!("{}", err), Error::DeserializeToml(err) => format!("{}", err), Error::IO(err) => format!("{}", err), + Error::JsonRpc(err) => format!("{}", err), Error::KuskaApi(err) => format!("{}", err), Error::KuskaCrypto(err) => format!("{}", err), Error::KuskaDiscovery(err) => format!("{}", err), diff --git a/src/main.rs b/src/main.rs index b682079..9f32980 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,6 +58,7 @@ use storage::{blob::BlobStorage, kv::KvStorage}; pub type Result = std::result::Result; const RPC_PORT: u16 = 8008; +const JSON_RPC_PORT: u16 = 3030; pub static KV_STORAGE: Lazy>> = Lazy::new(|| Arc::new(RwLock::new(KvStorage::default()))); @@ -171,8 +172,12 @@ async fn main() -> Result<()> { .open(blobs_folder, BROKER.lock().await.create_sender()); Broker::spawn(actors::ctrlc::actor()); - Broker::spawn(actors::tcp_server::actor(owned_id.clone(), listen)); + Broker::spawn(actors::jsonrpc_server::actor( + owned_id.clone(), + JSON_RPC_PORT, + )); + if lan_discovery { Broker::spawn(actors::lan_discovery::actor(owned_id.clone(), RPC_PORT)); } From 56aceafdb73725d48b45151dbab925e7a0d1f66c Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 15:27:45 +0200 Subject: [PATCH 26/28] update readme and add whitespace --- README.md | 15 +++++++++++++-- src/main.rs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9751097..2bd47f7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ ![Rust](https://github.com/Kuska-ssb/solar/workflows/Rust/badge.svg) -The idea behing solar is to enable community hardware devices to speak [Secure Scuttlebutt](https://scuttlebutt.nz/) using the [Kuska](https://github.com/Kuska-ssb) rust libraries, mainly based on [async_std](https://async.rs/). +The idea behing solar is to enable community hardware devices to speak [Secure Scuttlebutt](https://scuttlebutt.nz/) using the [Kuska](https://github.com/Kuska-ssb) Rust libraries, mainly based on [async_std](https://async.rs/). -Current status is: +Core features: - [X] auto-create private key if not exists - [X] broadcast the identity via lan discovery @@ -16,3 +16,14 @@ Current status is: - [X] `createHistoryStream` - [X] `blobs createWants` & `blobs get` - [X] patchwork and cryptoscope interoperability + +Extensions (undergoing active development): + +- [X] json-rpc server over ws for user queries + +JSON-RPC endpoints: + +`ping` -> `pong!` +`whoami` -> `@2gAUKQzPiXZWeaC/eOyyIke83RAAKwNB/QxFWm66iJg=.ed25519` + +_Note:_ [jsonrpc-cli](https://github.com/monomadic/jsonrpc-cli) is a Rust tool useful for testing JSON-RPC endpoints. diff --git a/src/main.rs b/src/main.rs index 9f32980..22b095a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -138,7 +138,7 @@ async fn main() -> Result<()> { } } } - debug!(target:"solar", "friends are {:?}",config.friends); + debug!(target:"solar", "friends are {:?}", config.friends); let owned_id = config.owned_identity()?; let _err = CONFIG.set(config); From 75658a14ea71e273a7337e736be99ded9219c900 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Fri, 2 Dec 2022 15:39:25 +0200 Subject: [PATCH 27/28] formatting --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2bd47f7..e7d1b29 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The idea behing solar is to enable community hardware devices to speak [Secure Scuttlebutt](https://scuttlebutt.nz/) using the [Kuska](https://github.com/Kuska-ssb) Rust libraries, mainly based on [async_std](https://async.rs/). -Core features: +## Core Features - [X] auto-create private key if not exists - [X] broadcast the identity via lan discovery @@ -17,13 +17,17 @@ Core features: - [X] `blobs createWants` & `blobs get` - [X] patchwork and cryptoscope interoperability -Extensions (undergoing active development): +## Extensions + +_Undergoing active development._ - [X] json-rpc server over ws for user queries -JSON-RPC endpoints: +## JSON-RPC Endpoints -`ping` -> `pong!` +`ping` -> `pong!` `whoami` -> `@2gAUKQzPiXZWeaC/eOyyIke83RAAKwNB/QxFWm66iJg=.ed25519` +----- + _Note:_ [jsonrpc-cli](https://github.com/monomadic/jsonrpc-cli) is a Rust tool useful for testing JSON-RPC endpoints. From 3a48872f186c791124fcf4876ff70ed630fd7717 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Sat, 3 Dec 2022 11:25:11 +0200 Subject: [PATCH 28/28] update readme and notes --- README.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++-------- notes | 51 ++++++++++++++++++++++++++++------ 2 files changed, 113 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e7d1b29..fcb61d4 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,93 @@ # 🌞 Solar -![Rust](https://github.com/Kuska-ssb/solar/workflows/Rust/badge.svg) +Solar was written by [@adria0](https://github.com/adria0) with the idea to +enable community hardware devices to speak [Secure Scuttlebutt](https://scuttlebutt.nz/) +using the [Kuska](https://github.com/Kuska-ssb) Rust libraries, mainly based on +[async_std](https://async.rs/). -The idea behing solar is to enable community hardware devices to speak [Secure Scuttlebutt](https://scuttlebutt.nz/) using the [Kuska](https://github.com/Kuska-ssb) Rust libraries, mainly based on [async_std](https://async.rs/). +This fork aims to evolve solar into a minimal Scuttlebutt node capable of +lightweight replication and feed storage. Much like +[scuttlego](https://github.com/planetary-social/scuttlego), this fork is not +intended to reproduce the full suite of MUXRPC methods used in the JS SSB +ecosystem. It will only implement the core MUXRPC methods required for +message publishing and replication. Indexing of database messages will be +offloaded to client applications (ie. piping feeds from solar into a SQLite +database). + +## Quick Start + +Clone the source and build the binary: + +``` +git clone git@github.com:mycognosist/solar.git +cd solar +cargo build --release +``` + +Add friend(s) to `solar.toml` (public key(s) of feeds you wish to replicate): + +``` +vim ~/.local/share/solar/solar.toml + +id = "@...=.ed25519" +secret "...==.ed25519" +friends = ["@...=.ed25519"] +``` + +Run solar with LAN discovery enabled: + +``` +./target/release/solar --lan true +``` ## Core Features - [X] auto-create private key if not exists - [X] broadcast the identity via lan discovery -- [X] automatic feed generation +- [X] automatic feed generation - [X] minimal [sled](https://github.com/spacejam/sled) database to store generate feeds - [X] mux-rpc implementation - [X] `whoami` - [X] `get` - - [X] `createHistoryStream` - - [X] `blobs createWants` & `blobs get` -- [X] patchwork and cryptoscope interoperability + - [X] `createHistoryStream` + - [X] `blobs createWants` + - [X] `blobs get` + - [X] [patchwork](https://github.com/ssbc/patchwork) and [go-ssb](https://github.com/ssbc/go-ssb) interoperability +- [X] legacy replication (using `createHistoryStream`) ## Extensions _Undergoing active development._ -- [X] json-rpc server over ws for user queries +- [X] json-rpc server for user queries + - [X] ping + - [X] whoami + - [ ] ... +- [ ] improved connection handler +- [ ] ebt replication -## JSON-RPC Endpoints +## Documentation -`ping` -> `pong!` -`whoami` -> `@2gAUKQzPiXZWeaC/eOyyIke83RAAKwNB/QxFWm66iJg=.ed25519` +_Undergoing active development._ + +- [ ] comprehensive doc comments +- [ ] comprehensive code comments + +## JSON-RPC API + +The server currently supports Websocket connections. This may soon change to +HTTP. + +| Method | Parameters | Response | Description | +| --- | --- | --- | --- | +| `ping` | | `pong!` | Responds if the JSON-RPC server is running | +| `whoami` | | `<@...=.ed25519>` | Returns the public key of the local node | ----- -_Note:_ [jsonrpc-cli](https://github.com/monomadic/jsonrpc-cli) is a Rust tool useful for testing JSON-RPC endpoints. +_Note:_ [jsonrpc-cli](https://github.com/monomadic/jsonrpc-cli) is a Rust tool +useful for testing JSON-RPC endpoints. + +## License + +AGPL-3.0 diff --git a/notes b/notes index 4fb9fae..7dadd36 100644 --- a/notes +++ b/notes @@ -17,24 +17,57 @@ x remove ci (annoying for now) +[ phase 2: improve docs & deepen understanding ] + + - let's really understand this thing deeply before adding more to it + - still need to do a lot of documenting + - work through these files first and document for clarity of understanding + - src/actors/rpc/history_stream.rs + - src/storage/kv.rs + +[ phase 3: write connection handler ] + + - first we need to store public keys of feeds we wish to replicate + - this is currently stored in `solar.toml` as "friends" + - might be good to split into `secret.toml` and `replicate.toml` + - later we might move the content of `replicate.toml` into a kv + - then we can track things like 'last replication event with xyz peer' + - expose the ability to read and update `replicate.toml` via jsonrpc + - conn-db + - write a minimal api to open and update a kv store + - consider basing it on rust HashMap interface or sled api (BTreeMap) + - based on ssb-conn-db + +[ phase 4: write ebt replication ] + +----- + +[ brainstorm ] + + - ability to pause replication + - expose methods via jsonrpc server + - add an additional match to the select! loop in src/actors/peer.rs + - maybe track state in a separate actor (state machine) + - this also opens the door to schedule replication + - get list of feeds from the main kv database + - `get_peers` + - whose logs do we hold? + - should match the friends list + ----- - nice to haves... +[ nice to haves... ] - replace serde with nanoserde or miniserde - eventually, replace in kuska-ssb too +[ links ] + error inspiration: https://github.com/xvxx/vial/blob/master/src/error.rs https://github.com/xvxx/vial/blob/master/src/lib.rs#L241 -[ phase 2: move relevant code to new workspace ] +ssb-conn-db: - - might be time to create a workspace - - start working on the connection scheduler - - or replication core - -[ phase 3: write connection handler ] - -[ phase 4: write ebt replication ] +https://github.com/ssbc/ssb-conn-db