From 5f4ae90316013286523a39292126d147264e1e02 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Fri, 5 Feb 2021 00:17:12 -0300 Subject: [PATCH 01/16] Initial structure - update libs and create project --- Cargo.lock | 1698 +++++++++++++++-------- Cargo.toml | 1 + colmeia-bins/Cargo.toml | 2 +- colmeia-hypercore/Cargo.toml | 13 +- colmeia-hypercore/src/network.rs | 3 +- colmeia-hyperdrive/Cargo.toml | 17 +- colmeia-hyperdrive/src/network.rs | 11 +- colmeia-hyperdrive/src/schema.rs | 272 ++-- colmeia-hyperstack/Cargo.toml | 10 +- colmeia-hyperswarm-dht/Cargo.toml | 18 + colmeia-hyperswarm-dht/src/announcer.rs | 30 + colmeia-hyperswarm-dht/src/lib.rs | 77 + colmeia-hyperswarm-dht/src/locator.rs | 30 + colmeia-hyperswarm-mdns/Cargo.toml | 10 +- colmeiad/Cargo.toml | 13 +- colmeiad/src/main.rs | 4 +- 16 files changed, 1447 insertions(+), 762 deletions(-) create mode 100644 colmeia-hyperswarm-dht/Cargo.toml create mode 100644 colmeia-hyperswarm-dht/src/announcer.rs create mode 100644 colmeia-hyperswarm-dht/src/lib.rs create mode 100644 colmeia-hyperswarm-dht/src/locator.rs diff --git a/Cargo.lock b/Cargo.lock index a8c9f09..01c239f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "addr2line" -version = "0.13.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ "gimli", ] @@ -17,118 +17,117 @@ checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" [[package]] name = "aead" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf01b9b56e767bb57b94ebf91a58b338002963785cdd7013e21c0d4679471e4" +checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.14.4", ] [[package]] -name = "aead" -version = "0.3.2" +name = "aes" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +checksum = "dd2bc6d3f370b5666245ff421e231cba4353df936e26986d2918e61a8fd6aef6" dependencies = [ - "generic-array 0.14.3", + "aes-soft 0.5.0", + "aesni 0.8.0", + "block-cipher", ] [[package]] name = "aes" -version = "0.3.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" +checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" dependencies = [ - "aes-soft 0.3.3", - "aesni 0.6.0", - "block-cipher-trait", + "aes-soft 0.6.4", + "aesni 0.10.0", + "cipher", ] [[package]] -name = "aes" -version = "0.4.0" +name = "aes-gcm" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7001367fde4c768a19d1029f0a8be5abd9308e1119846d5bd9ad26297b8faf5" +checksum = "0301c9e9c443494d970a07885e8cf3e587bae8356a1d5abd0999068413f7205f" dependencies = [ - "aes-soft 0.4.0", - "aesni 0.7.0", + "aead", + "aes 0.5.0", "block-cipher", + "ghash", + "subtle", ] [[package]] name = "aes-gcm" -version = "0.5.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "834a6bda386024dbb7c8fc51322856c10ffe69559f972261c868485f5759c638" +checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" dependencies = [ - "aead 0.2.0", - "aes 0.3.2", - "block-cipher-trait", - "ghash 0.2.3", - "subtle 2.2.3", - "zeroize", + "aead", + "aes 0.6.0", + "cipher", + "ctr", + "ghash", + "subtle", ] [[package]] -name = "aes-gcm" -version = "0.6.0" +name = "aes-soft" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f5007801316299f922a6198d1d09a0bae95786815d066d5880d13f7c45ead1" +checksum = "63dd91889c49327ad7ef3b500fd1109dbd3c509a03db0d4a9ce413b79f575cb6" dependencies = [ - "aead 0.3.2", - "aes 0.4.0", "block-cipher", - "ghash 0.3.0", - "subtle 2.2.3", + "byteorder", + "opaque-debug 0.3.0", ] [[package]] name = "aes-soft" -version = "0.3.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" dependencies = [ - "block-cipher-trait", - "byteorder", - "opaque-debug 0.2.3", + "cipher", + "opaque-debug 0.3.0", ] [[package]] -name = "aes-soft" -version = "0.4.0" +name = "aesni" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4925647ee64e5056cf231608957ce7c81e12d6d6e316b9ce1404778cc1d35fa7" +checksum = "0a6fe808308bb07d393e2ea47780043ec47683fcf19cf5efc8ca51c50cc8c68a" dependencies = [ "block-cipher", - "byteorder", - "opaque-debug 0.2.3", + "opaque-debug 0.3.0", ] [[package]] name = "aesni" -version = "0.6.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" dependencies = [ - "block-cipher-trait", - "opaque-debug 0.2.3", + "cipher", + "opaque-debug 0.3.0", ] [[package]] -name = "aesni" -version = "0.7.0" +name = "ahash" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050d39b0b7688b3a3254394c3e30a9d66c41dcf9b05b0e2dbdc623f6505d264" +checksum = "29661b60bec623f0586702976ff4d0c9942dcb6723161c2df0eea78455cfedfb" dependencies = [ - "block-cipher", - "opaque-debug 0.2.3", + "const-random", ] [[package]] name = "aho-corasick" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] @@ -139,6 +138,12 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + [[package]] name = "arrayvec" version = "0.4.12" @@ -148,11 +153,17 @@ dependencies = [ "nodrop", ] +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "async-attributes" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" dependencies = [ "quote", "syn", @@ -160,21 +171,63 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.1.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee81ba99bee79f3c8ae114ae4baa7eaa326f63447cf2ec65e4393618b63f8770" +checksum = "59740d83946db6a5af71ae25ddf9562c2b176b2ca42cf99a455f09f4a220d6b9" dependencies = [ "concurrent-queue", "event-listener", "futures-core", ] +[[package]] +name = "async-dup" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7427a12b8dc09291528cfb1da2447059adb4a257388c2acd6497a79d55cf6f7c" +dependencies = [ + "futures-io", + "simple-mutex", +] + +[[package]] +name = "async-executor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb877970c7b440ead138f6321a3b5395d6061183af779340b65e20c0fede9146" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", + "vec-arena", +] + +[[package]] +name = "async-global-executor" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-mutex", + "blocking", + "futures-lite", + "num_cpus", + "once_cell", +] + [[package]] name = "async-h1" -version = "2.1.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ad1494db96c4a94ca8a31a9aa56f15f3419c98bd4d3575f1ba682a06f5c1ac7" +checksum = "3e9e2a9745d9cd0d92ed7641ce4d07568985762f92633260f0afe8ac7917d9d7" dependencies = [ + "async-channel", + "async-dup", "async-std", "byte-pool", "futures-core", @@ -182,65 +235,150 @@ dependencies = [ "httparse", "lazy_static", "log", - "pin-project-lite", + "pin-project 1.0.5", +] + +[[package]] +name = "async-io" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9315f8f07556761c3e48fec2e6b276004acf426e6dc068b2c2251854d65ee0fd" +dependencies = [ + "concurrent-queue", + "fastrand", + "futures-lite", + "libc", + "log", + "nb-connect", + "once_cell", + "parking", + "polling", + "vec-arena", + "waker-fn", + "winapi 0.3.9", +] + +[[package]] +name = "async-lock" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1996609732bde4a9988bc42125f55f2af5f3c36370e27c778d5191a4a1b63bfb" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-mutex" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-process" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8cea09c1fb10a317d1b5af8024eeba256d6554763e85ecd90ff8df31c7bbda" +dependencies = [ + "async-io", + "blocking", + "cfg-if 0.1.10", + "event-listener", + "futures-lite", + "once_cell", + "signal-hook", + "winapi 0.3.9", +] + +[[package]] +name = "async-session" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345022a2eed092cd105cc1b26fd61c341e100bd5fcbbd792df4baf31c2cc631f" +dependencies = [ + "anyhow", + "async-std", + "async-trait", + "base64 0.12.3", + "bincode", + "blake3", + "chrono", + "hmac 0.8.1", + "kv-log-macro", + "rand 0.7.3", + "serde", + "serde_json", + "sha2 0.9.3", ] [[package]] name = "async-sse" -version = "4.0.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "885fb340b166aff3a3b16dd49ef169d8ee34428aa10c0432c61fff584aa222b9" +checksum = "53bba003996b8fd22245cd0c59b869ba764188ed435392cf2796d03b805ade10" dependencies = [ "async-channel", "async-std", "http-types", "log", "memchr", - "pin-project-lite", + "pin-project-lite 0.1.11", ] [[package]] name = "async-std" -version = "1.6.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d68a33ebc8b57800847d00787307f84a562224a14db069b0acefe4c2abbf5d" +checksum = "d9f06685bad74e0570f5213741bea82158279a4103d988e57bfada11ad230341" dependencies = [ "async-attributes", - "async-task", - "crossbeam-utils", + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "async-process", + "crossbeam-utils 0.8.1", "futures-channel", "futures-core", "futures-io", - "futures-timer", + "futures-lite", + "gloo-timers", "kv-log-macro", "log", "memchr", "num_cpus", "once_cell", - "pin-project-lite", + "pin-project-lite 0.2.4", "pin-utils", "slab", - "smol", "wasm-bindgen-futures", ] [[package]] name = "async-task" -version = "3.0.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" +checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-trait" -version = "0.1.36" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a265e3abeffdce30b2e26b7a11b222fe37c6067404001b434101457d0385eb92" +checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" 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" @@ -254,18 +392,24 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "autocfg" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.50" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", "object", @@ -274,9 +418,9 @@ dependencies = [ [[package]] name = "base-x" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" [[package]] name = "base64" @@ -284,6 +428,22 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bincode" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" +dependencies = [ + "byteorder", + "serde", +] + [[package]] name = "bitfield-rle" version = "0.2.0" @@ -302,15 +462,13 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blake2" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ce5b6108f8e154604bd4eb76a2f726066c3464d5a552a4229262a18c9bb471" +checksum = "10a5720225ef5daecf08657f23791354e1685a8c91a4c60c7f3d3b2892f978f4" dependencies = [ - "byte-tools", - "byteorder", "crypto-mac 0.8.0", "digest 0.9.0", - "opaque-debug 0.2.3", + "opaque-debug 0.3.0", ] [[package]] @@ -319,8 +477,23 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" dependencies = [ - "arrayvec", + "arrayvec 0.4.12", + "constant_time_eq", +] + +[[package]] +name = "blake3" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "cc", + "cfg-if 0.1.10", "constant_time_eq", + "crypto-mac 0.8.0", + "digest 0.9.0", ] [[package]] @@ -341,25 +514,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.3", + "generic-array 0.14.4", ] [[package]] name = "block-cipher" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa136449e765dc7faa244561ccae839c394048667929af599b5d931ebe7b7f10" -dependencies = [ - "generic-array 0.14.3", -] - -[[package]] -name = "block-cipher-trait" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +checksum = "f337a3e6da609650eb74e02bc9fac7b735049f7623ab12f2e4c719316fcc7e80" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.14.4", ] [[package]] @@ -373,28 +537,29 @@ dependencies = [ [[package]] name = "blocking" -version = "0.4.6" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d17efb70ce4421e351d61aafd90c16a20fb5bfe339fcdc32a86816280e62ce0" +checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" dependencies = [ - "futures-channel", - "futures-util", + "async-channel", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", "once_cell", - "parking", - "waker-fn", ] [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" [[package]] name = "byte-pool" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9342e102eac8b1879fbedf9a7e0572c40b0cc5805b663c4d4ca791cae0bae221" +checksum = "1e38e98299d518ec351ca016363e0cbfc77059dcd08dfa9700d15e405536097a" dependencies = [ "crossbeam-queue", "stable_deref_trait", @@ -408,9 +573,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" @@ -432,9 +597,9 @@ checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" [[package]] name = "cc" -version = "1.0.58" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" [[package]] name = "cfg-if" @@ -442,36 +607,56 @@ 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 = "chacha20" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086c0f07ac275808b7bf9a39f2fd013aae1498be83632814c8c4e0bd53f2dc58" +checksum = "244fbce0d47e97e8ef2f63b81d5e05882cb518c68531eb33194990d7b7e85845" dependencies = [ - "stream-cipher 0.4.1", + "stream-cipher 0.7.1", "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18b0c90556d8e3fec7cf18d84a2f53d27b21288f2fe481b830fadcf809e48205" +checksum = "9bf18d374d66df0c05cdddd528a7db98f78c28e2519b120855c4f84c5027b1f5" dependencies = [ - "aead 0.3.2", + "aead", "chacha20", "poly1305", - "stream-cipher 0.4.1", + "stream-cipher 0.7.1", "zeroize", ] [[package]] -name = "clear_on_drop" -version = "0.2.4" +name = "chrono" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9cc5db465b294c3fa986d5bbb0f3017cd850bff6dd6c52f9ccff8b4d21b7b08" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ - "cc", + "libc", + "num-integer", + "num-traits", + "serde", + "time 0.1.43", + "winapi 0.3.9", +] + +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array 0.14.4", ] [[package]] @@ -481,7 +666,7 @@ dependencies = [ "async-std", "colmeia-hyperstack", "colmeia-hyperswarm-mdns", - "env_logger", + "env_logger 0.8.2", "hex", "hypercore-protocol", "log", @@ -539,6 +724,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "colmeia-hyperswarm-dht" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-std", + "futures", + "hyperswarm-dht", +] + [[package]] name = "colmeia-hyperswarm-mdns" version = "0.1.0" @@ -550,7 +745,7 @@ dependencies = [ "lazy_static", "log", "multicast-socket", - "rand", + "rand 0.7.3", "trust-dns-proto", ] @@ -560,7 +755,7 @@ version = "0.1.0" dependencies = [ "async-std", "colmeia-hyperstack", - "env_logger", + "env_logger 0.8.2", "futures", "hypercore", "random-access-storage", @@ -570,13 +765,41 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "1.1.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83c06aff61f2d899eb87c379df3cbf7876f14471dcab474e0b6dc90ab96c080" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" dependencies = [ "cache-padded", ] +[[package]] +name = "const-random" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40" +dependencies = [ + "getrandom 0.2.2", + "lazy_static", + "proc-macro-hack", + "tiny-keccak", +] + +[[package]] +name = "const_fn" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -585,25 +808,32 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cookie" -version = "0.14.1" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca761767cf3fa9068cc893ec8c247a22d0fd0535848e65640c0548bd1f8bbb36" +checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f" dependencies = [ - "aes-gcm 0.5.0", - "base64", + "aes-gcm 0.8.0", + "base64 0.12.3", "hkdf", - "hmac", + "hmac 0.10.1", "percent-encoding", - "rand", - "sha2 0.8.2", - "time", + "rand 0.7.3", + "sha2 0.9.3", + "time 0.2.25", + "version_check", ] [[package]] name = "cpuid-bool" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec6763c20301ab0dc67051d1b6f4cc9132ad9e6eddcb1f10c6c53ea6d6ae2183" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + +[[package]] +name = "cpuid-bool" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" [[package]] name = "crossbeam-queue" @@ -611,8 +841,8 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" dependencies = [ - "cfg-if", - "crossbeam-utils", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", "maybe-uninit", ] @@ -622,49 +852,85 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg", - "cfg-if", + "autocfg 1.0.1", + "cfg-if 0.1.10", "lazy_static", ] [[package]] -name = "crypto-mac" -version = "0.7.0" +name = "crossbeam-utils" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ - "generic-array 0.12.3", - "subtle 1.0.0", + "autocfg 1.0.1", + "cfg-if 1.0.0", + "lazy_static", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-mac" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.3", - "subtle 2.2.3", + "generic-array 0.14.4", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" +dependencies = [ + "generic-array 0.14.4", + "subtle", +] + +[[package]] +name = "ctor" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8f45d9ad417bcef4817d614a501ab55cdd96a6fdb24f49aab89a54acfd66b19" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "ctr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" +dependencies = [ + "cipher", ] [[package]] name = "curve25519-dalek" -version = "2.1.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5" +checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" dependencies = [ "byteorder", - "digest 0.8.1", - "rand_core", - "subtle 2.2.3", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", "zeroize", ] [[package]] name = "data-encoding" -version = "2.2.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72aa14c04dfae8dd7d8a2b1cb7ca2152618cd01336dbfe704b8dcbf8d41dbd69" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" [[package]] name = "digest" @@ -681,7 +947,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.3", + "generic-array 0.14.4", ] [[package]] @@ -691,34 +957,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" [[package]] -name = "dtoa" -version = "0.4.6" +name = "ed25519" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +checksum = "37c66a534cbb46ab4ea03477eae19d5c22c01da8258030280b7bd9d8433fb6ef" +dependencies = [ + "signature", +] [[package]] name = "ed25519-dalek" -version = "1.0.0-pre.3" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "clear_on_drop", "curve25519-dalek", - "rand", - "sha2 0.8.2", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.3", + "zeroize", ] [[package]] name = "either" -version = "1.5.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "enum-as-inner" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc4bfcfacb61d231109d1d55202c1f33263319668b168843e02ad4652725ec9c" +checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595" dependencies = [ "heck", "proc-macro2", @@ -733,27 +1004,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" dependencies = [ "atty", - "humantime", + "humantime 1.3.0", "log", "regex", "termcolor", ] [[package]] -name = "error-chain" -version = "0.12.2" +name = "env_logger" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" +checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" dependencies = [ - "backtrace", - "version_check", + "atty", + "humantime 2.1.0", + "log", + "regex", + "termcolor", ] [[package]] name = "event-listener" -version = "2.2.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "699d84875f1b72b4da017e6b0f77dfa88c0137f089958a88974d15938cbc2976" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "failure" @@ -785,21 +1059,25 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "fastrand" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36a9cb09840f81cd211e435d00a4e487edd263dc3c8ff815c32dd76ad668ebed" +checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3" +dependencies = [ + "instant", +] [[package]] name = "femme" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b6b21baebbed15551f2170010ca4101b9ed3fdc05822791c8bd4631840eab81" +checksum = "2af1a24f391a5a94d756db5092c6576aad494b88a71a5a36b20c67b63e0df034" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "js-sys", "log", "serde", "serde_derive", + "serde_json", "wasm-bindgen", "web-sys", ] @@ -817,26 +1095,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f55d280d4b6d9585f3d1458eb082fb30f541ad227b2102965e4c7aa239a5e9e4" [[package]] -name = "fuchsia-zircon" -version = "0.3.3" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" +name = "form_urlencoded" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" +dependencies = [ + "matches", + "percent-encoding", +] [[package]] name = "futures" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" dependencies = [ "futures-channel", "futures-core", @@ -849,9 +1127,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" dependencies = [ "futures-core", "futures-sink", @@ -859,15 +1137,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" [[package]] name = "futures-executor" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" dependencies = [ "futures-core", "futures-task", @@ -876,15 +1154,30 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.5" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" + +[[package]] +name = "futures-lite" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite 0.2.4", + "waker-fn", +] [[package]] name = "futures-macro" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -894,15 +1187,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" dependencies = [ "once_cell", ] @@ -912,16 +1205,12 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" -dependencies = [ - "gloo-timers", - "send_wrapper", -] [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" dependencies = [ "futures-channel", "futures-core", @@ -930,13 +1219,25 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project", + "pin-project-lite 0.2.4", "pin-utils", "proc-macro-hack", "proc-macro-nested", "slab", ] +[[package]] +name = "futures_codec" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce54d63f8b0c75023ed920d46fd71d0cbbb830b0ee012726b5b4f506fb6dea5b" +dependencies = [ + "bytes", + "futures", + "memchr", + "pin-project 0.4.27", +] + [[package]] name = "gcc" version = "0.3.55" @@ -954,9 +1255,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60fb4bb6bba52f78a471264d9a3b7d026cc0af47b22cd2cffbc0b787ca003e63" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", "version_check", @@ -986,38 +1287,41 @@ 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 = "ghash" -version = "0.2.3" +name = "getrandom" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f0930ed19a7184089ea46d2fedead2f6dc2b674c5db4276b7da336c7cd83252" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ - "polyval 0.3.3", + "cfg-if 1.0.0", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "ghash" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6e27f0689a6e15944bdce7e45425efb87eaa8ab0c6e87f11d0987a9133e2531" +checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" dependencies = [ - "polyval 0.4.0", + "opaque-debug 0.3.0", + "polyval", ] [[package]] name = "gimli" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" [[package]] name = "gloo-timers" @@ -1034,27 +1338,34 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.8.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" dependencies = [ - "autocfg", + "ahash", + "autocfg 0.1.7", ] +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.15" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -1067,36 +1378,60 @@ checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" [[package]] name = "hkdf" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" +checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" dependencies = [ - "digest 0.8.1", - "hmac", + "digest 0.9.0", + "hmac 0.10.1", ] [[package]] name = "hmac" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" dependencies = [ - "crypto-mac 0.7.0", - "digest 0.8.1", + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" +dependencies = [ + "crypto-mac 0.10.0", + "digest 0.9.0", +] + +[[package]] +name = "http-client" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010092b71b94ee49293995625ce7a607778b8b4099c8088fa84fd66bd3e0f21c" +dependencies = [ + "async-trait", + "http-types", + "log", ] [[package]] name = "http-types" -version = "2.3.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bc341c4b7a71eb0d85c760dc7363648b82ecc38fa5ead50f69b52858df708b9" +checksum = "32613ebb139d1d430ef5783676f84abfa06fc5f2b4b5a25220cdeeff7e16ef5c" dependencies = [ "anyhow", + "async-channel", "async-std", + "base64 0.13.0", "cookie", + "futures-lite", "infer", - "pin-project-lite", - "rand", + "pin-project-lite 0.2.4", + "rand 0.7.3", "serde", "serde_json", "serde_qs", @@ -1106,9 +1441,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" [[package]] name = "humantime" @@ -1119,11 +1454,16 @@ dependencies = [ "quick-error", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hypercore" version = "0.11.1-beta.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599e25603458f46ff86b0a8174a6b45146eee5263fa859b9bd644ce36b54a5c4" +source = "git+https://github.com/bltavares/hypercore?branch=update-ed25519-dalek#2a6b0761e416400e9a421b61d4260f69d3ca12f0" dependencies = [ "anyhow", "async-std", @@ -1137,11 +1477,11 @@ dependencies = [ "memory-pager", "merkle-tree-stream", "pretty-hash", - "rand", + "rand 0.7.3", "random-access-disk", "random-access-memory", "random-access-storage", - "sha2 0.8.2", + "sha2 0.9.3", "sleep-parser", "sparse-bitfield", "tree-index", @@ -1149,27 +1489,54 @@ dependencies = [ [[package]] name = "hypercore-protocol" -version = "0.0.1" -source = "git+https://github.com/Frando/hypercore-protocol-rs#9a3ad0e17364a2ed3d5801e8e90153e214a4b64d" +version = "0.0.2" +source = "git+https://github.com/Frando/hypercore-protocol-rs#3186877a888c75fc99cee69588cc313fda9f5db5" dependencies = [ "async-trait", "blake2-rfc", "bytes", "futures", "futures-timer", - "getrandom", + "getrandom 0.1.16", "hex", "instant", "log", "pretty-hash", "prost", "prost-build", - "rand", + "rand 0.7.3", "salsa20", "snow", "varinteger", ] +[[package]] +name = "hyperswarm-dht" +version = "0.1.0" +source = "git+https://github.com/bltavares/hyperswarm-dht?branch=update-ed25519-dalek#3646ee540205c15ca3869c635f6187307df49cc2" +dependencies = [ + "anyhow", + "arrayvec 0.5.2", + "async-std", + "blake2", + "bytes", + "ed25519-dalek", + "either", + "fnv", + "futures", + "futures_codec", + "log", + "lru", + "pretty_env_logger", + "prost", + "prost-build", + "rand 0.7.3", + "sha2 0.8.2", + "smallvec", + "uint", + "wasm-timer", +] + [[package]] name = "idna" version = "0.2.0" @@ -1183,34 +1550,34 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ - "autocfg", - "hashbrown", + "autocfg 1.0.1", + "hashbrown 0.9.1", ] [[package]] name = "infer" -version = "0.1.7" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6854dd77ddc4f9ba1a448f487e27843583d407648150426a30c2ea3a2c39490a" +checksum = "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" [[package]] name = "instant" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", +] [[package]] -name = "iovec" -version = "0.1.4" +name = "ipnet" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] +checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" [[package]] name = "itertools" @@ -1223,29 +1590,19 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" -version = "0.3.42" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52732a3d3ad72c58ad2dc70624f9c17b46ecd0943b9a4f1ee37c4c18c5d983e2" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] -[[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 = "kv-log-macro" version = "1.0.7" @@ -1263,27 +1620,36 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.77" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" +checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" + +[[package]] +name = "lock_api" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +dependencies = [ + "scopeguard", +] [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", + "value-bag", ] [[package]] -name = "logtest" -version = "2.0.0" +name = "lru" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3e43a8657c1d64516dcc9db8ca03826a4aceaf89d5ce1b37b59f6ff0e43026" +checksum = "35c456c123957de3a220cd03786e0d86aa542a88b46029973b542f426da6ef34" dependencies = [ - "lazy_static", - "log", + "hashbrown 0.6.3", ] [[package]] @@ -1300,9 +1666,9 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memory-pager" @@ -1321,42 +1687,35 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ "adler", + "autocfg 1.0.1", ] [[package]] name = "mio" -version = "0.6.22" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7" dependencies = [ - "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", "libc", "log", "miow", - "net2", - "slab", - "winapi 0.2.8", + "ntapi", + "winapi 0.3.9", ] [[package]] name = "miow" -version = "0.2.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "socket2", + "winapi 0.3.9", ] [[package]] @@ -1380,17 +1739,16 @@ dependencies = [ [[package]] name = "multimap" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8883adfde9756c1d30b0f519c9b8c502a94b41ac62f696453c37c7fc0a958ce" +checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" [[package]] -name = "net2" -version = "0.2.34" +name = "nb-connect" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "8123a81538e457d44b933a02faf885d3fe8408806b23fa700e8f01c6c3a98998" dependencies = [ - "cfg-if", "libc", "winapi 0.3.9", ] @@ -1403,7 +1761,7 @@ checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" dependencies = [ "bitflags", "cc", - "cfg-if", + "cfg-if 0.1.10", "libc", ] @@ -1413,6 +1771,34 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg 1.0.1", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg 1.0.1", +] + [[package]] name = "num_cpus" version = "1.13.0" @@ -1425,15 +1811,15 @@ dependencies = [ [[package]] name = "object" -version = "0.20.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "once_cell" -version = "1.4.0" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "opaque-debug" @@ -1449,9 +1835,34 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "parking" -version = "1.0.5" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d4a6da31f8144a32532fe38fe8fb439a6842e0ec633f0037f0144c14e7f907" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall 0.1.57", + "smallvec", + "winapi 0.3.9", +] [[package]] name = "percent-encoding" @@ -1460,29 +1871,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] -name = "petgraph" -version = "0.5.1" +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" +dependencies = [ + "pin-project-internal 0.4.27", +] + +[[package]] +name = "pin-project" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63" dependencies = [ - "fixedbitset", - "indexmap", + "pin-project-internal 1.0.5", ] [[package]] -name = "pin-project" -version = "0.4.22" +name = "pin-project-internal" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" +checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ - "pin-project-internal", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "pin-project-internal" -version = "0.4.22" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" +checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b" dependencies = [ "proc-macro2", "quote", @@ -1491,9 +1922,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.7" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" + +[[package]] +name = "pin-project-lite" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "pin-utils" @@ -1502,39 +1939,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "poly1305" -version = "0.6.0" +name = "polling" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b42192ab143ed7619bf888a7f9c6733a9a2153b218e2cd557cfdb52fbf9bb1" +checksum = "a2a7bc6b2a29e632e45451c941832803a18cce6781db04de8a04696cdca8bde4" dependencies = [ - "universal-hash 0.4.0", + "cfg-if 0.1.10", + "libc", + "log", + "wepoll-sys", + "winapi 0.3.9", ] [[package]] -name = "polyval" -version = "0.3.3" +name = "poly1305" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ec3341498978de3bfd12d1b22f1af1de22818f5473a11e8a6ef997989e3a212" +checksum = "4b7456bc1ad2d4cf82b3a016be4c2ac48daf11bf990c1603ebd447fe6f30fca8" dependencies = [ - "cfg-if", - "universal-hash 0.3.0", + "cpuid-bool 0.2.0", + "universal-hash", ] [[package]] name = "polyval" -version = "0.4.0" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a50142b55ab3ed0e9f68dfb3709f1d90d29da24e91033f28b96330643107dc" +checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" dependencies = [ - "cfg-if", - "universal-hash 0.4.0", + "cpuid-bool 0.2.0", + "opaque-debug 0.3.0", + "universal-hash", ] [[package]] name = "ppv-lite86" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "pretty-hash" @@ -1545,23 +1987,33 @@ dependencies = [ "failure", ] +[[package]] +name = "pretty_env_logger" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" +dependencies = [ + "env_logger 0.7.1", + "log", +] + [[package]] name = "proc-macro-hack" -version = "0.5.16" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.18" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] @@ -1619,24 +2071,24 @@ dependencies = [ [[package]] name = "protobuf" -version = "2.16.2" +version = "2.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d883f78645c21b7281d21305181aa1f4dd9e9363e7cf2566c93121552cff003e" +checksum = "86473d5f16580f10b131a0bf0afb68f8e029d1835d33a00f37281b05694e5312" [[package]] name = "protobuf-codegen" -version = "2.16.2" +version = "2.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c3f99b1babb22152c6591b076d46f64e313c6e30f6f334a89e260e1b3569e6" +checksum = "c8b6ba4581fcd9c3ce3576f25e528467b0d3516e332884c0da6f2084fe59045f" dependencies = [ "protobuf", ] [[package]] name = "protobuf-codegen-pure" -version = "2.16.2" +version = "2.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cd0751bffc065c0ebb04871866924a0028c5707249da39bc058a73bd348b55f" +checksum = "e0cc5a64733bf127b466ca734a39ad1b123ac37bfe96c5a340fa6f5393dfd964" dependencies = [ "protobuf", "protobuf-codegen", @@ -1650,9 +2102,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2", ] @@ -1663,11 +2115,23 @@ 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", - "rand_hc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.1", + "rand_hc 0.3.0", ] [[package]] @@ -1677,7 +2141,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.1", ] [[package]] @@ -1686,7 +2160,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" +dependencies = [ + "getrandom 0.2.2", ] [[package]] @@ -1695,7 +2178,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.1", ] [[package]] @@ -1739,11 +2231,20 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +dependencies = [ + "bitflags", +] + [[package]] name = "regex" -version = "1.3.9" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -1753,9 +2254,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.18" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "remove_dir_all" @@ -1774,9 +2275,15 @@ checksum = "56770675ebc04927ded3e60633437841581c285dc6236109ea25fbf3beb7b59e" [[package]] name = "rustc-demangle" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustc_version" @@ -1803,10 +2310,10 @@ dependencies = [ ] [[package]] -name = "scoped-tls" -version = "1.0.0" +name = "scopeguard" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" @@ -1823,26 +2330,20 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "serde" -version = "1.0.114" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" +checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.114" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" +checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" dependencies = [ "proc-macro2", "quote", @@ -1851,9 +2352,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "itoa", "ryu", @@ -1862,26 +2363,26 @@ dependencies = [ [[package]] name = "serde_qs" -version = "0.6.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f3acf84e23ab27c01cb5917551765c01c50b2000089db8fa47fe018a3260cf" +checksum = "5af82de3c6549b001bec34961ff2d6a54339a87bab37ce901b693401f27de6cb" dependencies = [ "data-encoding", - "error-chain", "percent-encoding", "serde", + "thiserror", ] [[package]] name = "serde_urlencoded" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" dependencies = [ - "dtoa", + "form_urlencoded", "itoa", + "ryu", "serde", - "url", ] [[package]] @@ -1904,17 +2405,51 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer 0.9.0", - "cfg-if", - "cpuid-bool", + "cfg-if 1.0.0", + "cpuid-bool 0.1.2", "digest 0.9.0", "opaque-debug 0.3.0", ] +[[package]] +name = "signal-hook" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" + +[[package]] +name = "simple-mutex" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38aabbeafa6f6dead8cebf246fe9fae1f9215c8d29b3a69f93bd62a9e4a3dcd6" +dependencies = [ + "event-listener", +] + [[package]] name = "slab" version = "0.4.2" @@ -1933,57 +2468,35 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" - -[[package]] -name = "smol" -version = "0.1.18" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" -dependencies = [ - "async-task", - "blocking", - "concurrent-queue", - "fastrand", - "futures-io", - "futures-util", - "libc", - "once_cell", - "scoped-tls", - "slab", - "socket2", - "wepoll-sys-stjepang", - "winapi 0.3.9", -] +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "snow" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32bf8474159a95551661246cda4976e89356999e3cbfef36f493dacc3fae1e8e" +checksum = "795dd7aeeee24468e5a32661f6d27f7b5cbed802031b2d7640c7b10f8fb2dd50" dependencies = [ - "aes-gcm 0.6.0", + "aes-gcm 0.7.0", "blake2", "chacha20poly1305", - "rand", - "rand_core", + "rand 0.7.3", + "rand_core 0.5.1", "rustc_version", - "sha2 0.9.1", - "subtle 2.2.3", + "sha2 0.9.3", + "subtle", "x25519-dalek", ] [[package]] name = "socket2" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi 0.3.9", ] @@ -2004,13 +2517,19 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "standback" -version = "0.2.9" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0437cfb83762844799a60e1e3b489d5ceb6a650fbacb86437badc1b6d87b246" +checksum = "a2beb4d1860a61f571530b3f855a1b538d0200f7871c63331ecd6f17b1f014f8" dependencies = [ "version_check", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "stdweb" version = "0.4.20" @@ -2071,30 +2590,31 @@ dependencies = [ [[package]] name = "stream-cipher" -version = "0.4.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f8ed9974042b8c3672ff3030a69fcc03b74c47c3d1ecb7755e8a3626011e88" +checksum = "c80e15f898d8d8f25db24c253ea615cc14acf418ff307822995814e7d42cfa89" dependencies = [ - "generic-array 0.14.3", + "block-cipher", + "generic-array 0.14.4", ] [[package]] name = "subtle" -version = "1.0.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] -name = "subtle" -version = "2.2.3" +name = "sval" +version = "1.0.0-alpha.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1" +checksum = "45f6ee7c7b87caf59549e9fe45d6a69c75c8019e79e212a835c5da0e92f0ba08" [[package]] name = "syn" -version = "1.0.34" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" dependencies = [ "proc-macro2", "quote", @@ -2115,41 +2635,41 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", - "rand", - "redox_syscall", + "rand 0.8.3", + "redox_syscall 0.2.4", "remove_dir_all", "winapi 0.3.9", ] [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2", "quote", @@ -2158,29 +2678,31 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "tide" -version = "0.12.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d10b7fd81fa0a75b30538de52f2e1c07c57327f2499edcfc4874e7f9963ff0" +checksum = "c459573f0dd2cc734b539047f57489ea875af8ee950860ded20cf93a79a1dee0" dependencies = [ "async-h1", + "async-session", "async-sse", "async-std", "async-trait", "femme", "futures-util", + "http-client", "http-types", "kv-log-macro", - "logtest", - "pin-project-lite", + "log", + "pin-project-lite 0.2.4", "route-recognizer", "serde", "serde_json", @@ -2188,11 +2710,21 @@ dependencies = [ [[package]] name = "time" -version = "0.2.16" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "time" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a51cadc5b1eec673a685ff7c33192ff7b7603d0b75446fb354939ee615acb15" +checksum = "1195b046942c221454c2539395f85413b33383a067449d78aab2b7b052a142f7" dependencies = [ - "cfg-if", + "const_fn", "libc", "standback", "stdweb", @@ -2203,9 +2735,9 @@ dependencies = [ [[package]] name = "time-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ae9b6e9f095bc105e183e3cd493d72579be3181ad4004fceb01adbe9eecab2d" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" dependencies = [ "proc-macro-hack", "time-macros-impl", @@ -2224,24 +2756,41 @@ dependencies = [ "syn", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinyvec" -version = "0.3.3" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "0.2.21" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" +checksum = "6714d663090b6b0acb0fa85841c6d66233d150cdb2602c8f9b8abb03370beb3f" dependencies = [ - "bytes", - "iovec", - "lazy_static", + "autocfg 1.0.1", + "libc", "mio", - "pin-project-lite", - "slab", + "num_cpus", + "pin-project-lite 0.2.4", ] [[package]] @@ -2256,18 +2805,22 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.19.5" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd7061ba6f4d4d9721afedffbfd403f20f39a4301fee1b70d6fcd09cca69f28" +checksum = "98a0381b2864c2978db7f8e17c7b23cca5a3a5f99241076e13002261a8ecbabd" dependencies = [ "async-trait", - "backtrace", + "cfg-if 1.0.0", + "data-encoding", "enum-as-inner", - "futures", + "futures-channel", + "futures-io", + "futures-util", "idna", + "ipnet", "lazy_static", "log", - "rand", + "rand 0.8.3", "smallvec", "thiserror", "tokio", @@ -2280,6 +2833,18 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +[[package]] +name = "uint" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" +dependencies = [ + "byteorder", + "crunchy", + "rustc-hex", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.4" @@ -2291,18 +2856,18 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.13" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-xid" @@ -2310,35 +2875,37 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" -[[package]] -name = "universal-hash" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0c900f2f9b4116803415878ff48b63da9edb268668e08cf9292d7503114a01" -dependencies = [ - "generic-array 0.12.3", - "subtle 2.2.3", -] - [[package]] name = "universal-hash" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ - "generic-array 0.14.3", - "subtle 2.2.3", + "generic-array 0.14.4", + "subtle", ] [[package]] name = "url" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" dependencies = [ + "form_urlencoded", "idna", "matches", "percent-encoding", + "serde", +] + +[[package]] +name = "value-bag" +version = "1.0.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b676010e055c99033117c2343b33a40a30b91fecd6c49055ac9cd2d6c305ab1" +dependencies = [ + "ctor", + "sval", ] [[package]] @@ -2347,6 +2914,12 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ea29db9f94ff08bb619656b8120878f280526f71dc88b5262c958a510181812" +[[package]] +name = "vec-arena" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d" + [[package]] name = "version_check" version = "0.9.2" @@ -2355,9 +2928,9 @@ checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] name = "waker-fn" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9571542c2ce85ce642e6b58b3364da2fb53526360dfb7c211add4f5c23105ff7" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "wasi" @@ -2365,13 +2938,19 @@ 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.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "wasm-bindgen" -version = "0.2.65" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3edbcc9536ab7eababcc6d2374a0b7bfe13a2b6d562c5e07f370456b1a8f33d" +checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "serde", "serde_json", "wasm-bindgen-macro", @@ -2379,9 +2958,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.65" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ed2fb8c84bfad20ea66b26a3743f3e7ba8735a69fe7d95118c33ec8fc1244d" +checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" dependencies = [ "bumpalo", "lazy_static", @@ -2394,11 +2973,11 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.15" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ad6e4e8b2b7f8c90b6e09a9b590ea15cb0d1dbe28502b5a405cd95d1981671" +checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -2406,9 +2985,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.65" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e" +checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2416,9 +2995,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.65" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6" +checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" dependencies = [ "proc-macro2", "quote", @@ -2429,25 +3008,40 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.65" +version = "0.2.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" + +[[package]] +name = "wasm-timer" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b6c0220ded549d63860c78c38f3bcc558d1ca3f4efa74942c536ddbbb55e87" +checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" +dependencies = [ + "futures", + "js-sys", + "parking_lot", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] [[package]] name = "web-sys" -version = "0.3.42" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be2398f326b7ba09815d0b403095f34dd708579220d099caae89be0b32137b2" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "wepoll-sys-stjepang" -version = "1.0.6" +name = "wepoll-sys" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd319e971980166b53e17b1026812ad66c6b54063be879eb182342b55284694" +checksum = "0fcb14dea929042224824779fbc82d9fab8d2e6d3cbc0ac404de8edf489e77ff" dependencies = [ "cc", ] @@ -2477,12 +3071,6 @@ 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" @@ -2504,41 +3092,31 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[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 = "x25519-dalek" -version = "0.6.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637ff90c9540fa3073bb577e65033069e4bae7c79d49d74aa3ffdf5342a53217" +checksum = "bc614d95359fd7afc321b66d2107ede58b246b844cf5d8a0adcca413e439f088" dependencies = [ "curve25519-dalek", - "rand_core", + "rand_core 0.5.1", "zeroize", ] [[package]] name = "zeroize" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" +checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index dae353a..c128fef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ 'colmeia-hypercore', 'colmeia-hyperdrive', 'colmeia-hyperstack', + 'colmeia-hyperswarm-dht', 'colmeia-hyperswarm-mdns', 'colmeiad', ] diff --git a/colmeia-bins/Cargo.toml b/colmeia-bins/Cargo.toml index 994b34f..2a6328a 100644 --- a/colmeia-bins/Cargo.toml +++ b/colmeia-bins/Cargo.toml @@ -10,7 +10,7 @@ log = '*' hex = '*' [dependencies.async-std] -version = '1.6.2' +version = '1.9.0' features = ['unstable'] [dependencies.hypercore-protocol] diff --git a/colmeia-hypercore/Cargo.toml b/colmeia-hypercore/Cargo.toml index 636eb22..c4858ff 100644 --- a/colmeia-hypercore/Cargo.toml +++ b/colmeia-hypercore/Cargo.toml @@ -5,16 +5,19 @@ authors = ['Bruno Tavares '] edition = '2018' [dependencies] -futures = '0.3.5' -hypercore = '0.11.1-beta.9' -anyhow = '1.0.34' +futures = '0.3.12' +anyhow = '1.0.38' random-access-storage = '4.0.0' -log = '0.4.8' +log = '0.4.14' bitfield-rle = '0.2.0' [dependencies.async-std] -version = '1.6.2' +version = '1.9.0' features = ['unstable'] [dependencies.hypercore-protocol] git = 'https://github.com/Frando/hypercore-protocol-rs' + +[dependencies.hypercore] +git = 'https://github.com/bltavares/hypercore' +branch = 'update-ed25519-dalek' diff --git a/colmeia-hypercore/src/network.rs b/colmeia-hypercore/src/network.rs index 053bc3f..d8c14ef 100644 --- a/colmeia-hypercore/src/network.rs +++ b/colmeia-hypercore/src/network.rs @@ -2,6 +2,7 @@ use anyhow::Context; use async_std::sync::RwLock; use futures::{SinkExt, StreamExt}; use hypercore_protocol as proto; +use std::convert::TryFrom; use std::io; use std::sync::Arc; @@ -57,7 +58,7 @@ where signature: message .signature .clone() - .and_then(|s| hypercore::Signature::from_bytes(&s).ok()), + .and_then(|s| hypercore::Signature::try_from(&s[..]).ok()), }; self.feed diff --git a/colmeia-hyperdrive/Cargo.toml b/colmeia-hyperdrive/Cargo.toml index 322386b..8007909 100644 --- a/colmeia-hyperdrive/Cargo.toml +++ b/colmeia-hyperdrive/Cargo.toml @@ -5,25 +5,28 @@ authors = ['Bruno Tavares '] edition = '2018' [dependencies] -futures = '0.3.5' -hypercore = '0.11.1-beta.9' -anyhow = '1.0.34' +futures = '0.3.12' +anyhow = '1.0.38' random-access-storage = '4.0.0' random-access-memory = '2.0.0' random-access-disk = '2.0.0' async-trait = '0.1.36' -log = '0.4.8' -protobuf = '2.10.1' +log = '0.4.14' +protobuf = '2.20.0' [dependencies.colmeia-hypercore] path = '../colmeia-hypercore' [dependencies.async-std] -version = '1.6.2' +version = '1.9.0' features = ['unstable'] [dependencies.hypercore-protocol] git = 'https://github.com/Frando/hypercore-protocol-rs' +[dependencies.hypercore] +git = 'https://github.com/bltavares/hypercore' +branch = 'update-ed25519-dalek' + [build-dependencies] -protobuf-codegen-pure = '2.10.1' +protobuf-codegen-pure = '2.20.0' diff --git a/colmeia-hyperdrive/src/network.rs b/colmeia-hyperdrive/src/network.rs index 4a5716f..1ef7723 100644 --- a/colmeia-hyperdrive/src/network.rs +++ b/colmeia-hyperdrive/src/network.rs @@ -111,12 +111,11 @@ pub async fn replicate_hyperdrive( metadata.get(0).await }; if let Ok(Some(initial_metadata)) = initial_metadata { - let content = match protobuf::parse_from_bytes::( - &initial_metadata, - ) { - Ok(e) => e, - _ => continue, - }; + let content: crate::schema::Index = + match protobuf::Message::parse_from_bytes(&initial_metadata) { + Ok(e) => e, + _ => continue, + }; let public_key = match hypercore::PublicKey::from_bytes(content.get_content()) { diff --git a/colmeia-hyperdrive/src/schema.rs b/colmeia-hyperdrive/src/schema.rs index e329d4d..c02c661 100644 --- a/colmeia-hyperdrive/src/schema.rs +++ b/colmeia-hyperdrive/src/schema.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 2.16.2. Do not edit +// This file is generated by rust-protobuf 2.20.0. Do not edit // @generated // https://github.com/rust-lang/rust-clippy/issues/702 @@ -21,9 +21,9 @@ /// Generated files are compatible only with the same version /// of protobuf runtime. -// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_16_2; +// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_20_0; -#[derive(PartialEq, Clone, Default)] +#[derive(PartialEq,Clone,Default)] pub struct Index { // message fields field_type: ::protobuf::SingularField<::std::string::String>, @@ -46,6 +46,7 @@ impl Index { // required string type = 1; + pub fn get_field_type(&self) -> &str { match self.field_type.as_ref() { Some(v) => &v, @@ -76,13 +77,12 @@ impl Index { // Take field pub fn take_field_type(&mut self) -> ::std::string::String { - self.field_type - .take() - .unwrap_or_else(|| ::std::string::String::new()) + self.field_type.take().unwrap_or_else(|| ::std::string::String::new()) } // optional bytes content = 2; + pub fn get_content(&self) -> &[u8] { match self.content.as_ref() { Some(v) => &v, @@ -113,9 +113,7 @@ impl Index { // Take field pub fn take_content(&mut self) -> ::std::vec::Vec { - self.content - .take() - .unwrap_or_else(|| ::std::vec::Vec::new()) + self.content.take().unwrap_or_else(|| ::std::vec::Vec::new()) } } @@ -127,27 +125,19 @@ impl ::protobuf::Message for Index { true } - fn merge_from( - &mut self, - is: &mut ::protobuf::CodedInputStream<'_>, - ) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.field_type)?; - } + }, 2 => { ::protobuf::rt::read_singular_bytes_into(wire_type, is, &mut self.content)?; - } + }, _ => { - ::protobuf::rt::read_unknown_or_skip_group( - field_number, - wire_type, - is, - self.mut_unknown_fields(), - )?; - } + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, }; } ::std::result::Result::Ok(()) @@ -168,10 +158,7 @@ impl ::protobuf::Message for Index { my_size } - fn write_to_with_cached_sizes( - &self, - os: &mut ::protobuf::CodedOutputStream<'_>, - ) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(ref v) = self.field_type.as_ref() { os.write_string(1, &v)?; } @@ -213,34 +200,23 @@ impl ::protobuf::Message for Index { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = - ::protobuf::rt::LazyV2::INIT; + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); - fields.push( - ::protobuf::reflect::accessor::make_singular_field_accessor::< - _, - ::protobuf::types::ProtobufTypeString, - >( - "type", - |m: &Index| &m.field_type, - |m: &mut Index| &mut m.field_type, - ), - ); - fields.push( - ::protobuf::reflect::accessor::make_singular_field_accessor::< - _, - ::protobuf::types::ProtobufTypeBytes, - >( - "content", - |m: &Index| &m.content, - |m: &mut Index| &mut m.content, - ), - ); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "type", + |m: &Index| { &m.field_type }, + |m: &mut Index| { &mut m.field_type }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( + "content", + |m: &Index| { &m.content }, + |m: &mut Index| { &mut m.content }, + )); ::protobuf::reflect::MessageDescriptor::new_pb_name::( "Index", fields, - file_descriptor_proto(), + file_descriptor_proto() ) }) } @@ -271,7 +247,7 @@ impl ::protobuf::reflect::ProtobufValue for Index { } } -#[derive(PartialEq, Clone, Default)] +#[derive(PartialEq,Clone,Default)] pub struct Stat { // message fields mode: ::std::option::Option, @@ -301,6 +277,7 @@ impl Stat { // required uint32 mode = 1; + pub fn get_mode(&self) -> u32 { self.mode.unwrap_or(0) } @@ -319,6 +296,7 @@ impl Stat { // optional uint32 uid = 2; + pub fn get_uid(&self) -> u32 { self.uid.unwrap_or(0) } @@ -337,6 +315,7 @@ impl Stat { // optional uint32 gid = 3; + pub fn get_gid(&self) -> u32 { self.gid.unwrap_or(0) } @@ -355,6 +334,7 @@ impl Stat { // optional uint64 size = 4; + pub fn get_size(&self) -> u64 { self.size.unwrap_or(0) } @@ -373,6 +353,7 @@ impl Stat { // optional uint64 blocks = 5; + pub fn get_blocks(&self) -> u64 { self.blocks.unwrap_or(0) } @@ -391,6 +372,7 @@ impl Stat { // optional uint64 offset = 6; + pub fn get_offset(&self) -> u64 { self.offset.unwrap_or(0) } @@ -409,6 +391,7 @@ impl Stat { // optional uint64 byteOffset = 7; + pub fn get_byteOffset(&self) -> u64 { self.byteOffset.unwrap_or(0) } @@ -427,6 +410,7 @@ impl Stat { // optional uint64 mtime = 8; + pub fn get_mtime(&self) -> u64 { self.mtime.unwrap_or(0) } @@ -445,6 +429,7 @@ impl Stat { // optional uint64 ctime = 9; + pub fn get_ctime(&self) -> u64 { self.ctime.unwrap_or(0) } @@ -470,102 +455,76 @@ impl ::protobuf::Message for Stat { true } - fn merge_from( - &mut self, - is: &mut ::protobuf::CodedInputStream<'_>, - ) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint32()?; self.mode = ::std::option::Option::Some(tmp); - } + }, 2 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint32()?; self.uid = ::std::option::Option::Some(tmp); - } + }, 3 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint32()?; self.gid = ::std::option::Option::Some(tmp); - } + }, 4 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint64()?; self.size = ::std::option::Option::Some(tmp); - } + }, 5 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint64()?; self.blocks = ::std::option::Option::Some(tmp); - } + }, 6 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint64()?; self.offset = ::std::option::Option::Some(tmp); - } + }, 7 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint64()?; self.byteOffset = ::std::option::Option::Some(tmp); - } + }, 8 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint64()?; self.mtime = ::std::option::Option::Some(tmp); - } + }, 9 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { - return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type( - wire_type, - )); + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); } let tmp = is.read_uint64()?; self.ctime = ::std::option::Option::Some(tmp); - } + }, _ => { - ::protobuf::rt::read_unknown_or_skip_group( - field_number, - wire_type, - is, - self.mut_unknown_fields(), - )?; - } + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, }; } ::std::result::Result::Ok(()) @@ -607,10 +566,7 @@ impl ::protobuf::Message for Stat { my_size } - fn write_to_with_cached_sizes( - &self, - os: &mut ::protobuf::CodedOutputStream<'_>, - ) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(v) = self.mode { os.write_uint32(1, v)?; } @@ -673,74 +629,58 @@ impl ::protobuf::Message for Stat { } fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = - ::protobuf::rt::LazyV2::INIT; + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; descriptor.get(|| { let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint32, - >( - "mode", |m: &Stat| &m.mode, |m: &mut Stat| &mut m.mode + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "mode", + |m: &Stat| { &m.mode }, + |m: &mut Stat| { &mut m.mode }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint32, - >( - "uid", |m: &Stat| &m.uid, |m: &mut Stat| &mut m.uid + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "uid", + |m: &Stat| { &m.uid }, + |m: &mut Stat| { &mut m.uid }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint32, - >( - "gid", |m: &Stat| &m.gid, |m: &mut Stat| &mut m.gid + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "gid", + |m: &Stat| { &m.gid }, + |m: &mut Stat| { &mut m.gid }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint64, - >( - "size", |m: &Stat| &m.size, |m: &mut Stat| &mut m.size + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "size", + |m: &Stat| { &m.size }, + |m: &mut Stat| { &mut m.size }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint64, - >( + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( "blocks", - |m: &Stat| &m.blocks, - |m: &mut Stat| &mut m.blocks, + |m: &Stat| { &m.blocks }, + |m: &mut Stat| { &mut m.blocks }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint64, - >( + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( "offset", - |m: &Stat| &m.offset, - |m: &mut Stat| &mut m.offset, + |m: &Stat| { &m.offset }, + |m: &mut Stat| { &mut m.offset }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint64, - >( + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( "byteOffset", - |m: &Stat| &m.byteOffset, - |m: &mut Stat| &mut m.byteOffset, + |m: &Stat| { &m.byteOffset }, + |m: &mut Stat| { &mut m.byteOffset }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint64, - >( - "mtime", |m: &Stat| &m.mtime, |m: &mut Stat| &mut m.mtime + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "mtime", + |m: &Stat| { &m.mtime }, + |m: &mut Stat| { &mut m.mtime }, )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::< - _, - ::protobuf::types::ProtobufTypeUint64, - >( - "ctime", |m: &Stat| &m.ctime, |m: &mut Stat| &mut m.ctime + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "ctime", + |m: &Stat| { &m.ctime }, + |m: &mut Stat| { &mut m.ctime }, )); ::protobuf::reflect::MessageDescriptor::new_pb_name::( "Stat", fields, - file_descriptor_proto(), + file_descriptor_proto() ) }) } @@ -779,24 +719,26 @@ impl ::protobuf::reflect::ProtobufValue for Stat { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x0cschema.proto\x12\0\",\n\x05Index\x12\x0e\n\x04type\x18\x01\x20\x02\ - (\tB\0\x12\x11\n\x07content\x18\x02\x20\x01(\x0cB\0:\0\"\xa2\x01\n\x04St\ - at\x12\x0e\n\x04mode\x18\x01\x20\x02(\rB\0\x12\r\n\x03uid\x18\x02\x20\ - \x01(\rB\0\x12\r\n\x03gid\x18\x03\x20\x01(\rB\0\x12\x0e\n\x04size\x18\ - \x04\x20\x01(\x04B\0\x12\x10\n\x06blocks\x18\x05\x20\x01(\x04B\0\x12\x10\ - \n\x06offset\x18\x06\x20\x01(\x04B\0\x12\x14\n\nbyteOffset\x18\x07\x20\ - \x01(\x04B\0\x12\x0f\n\x05mtime\x18\x08\x20\x01(\x04B\0\x12\x0f\n\x05cti\ - me\x18\t\x20\x01(\x04B\0:\0B\0b\x06proto2\ + \n\x0cschema.proto\";\n\x05Index\x12\x14\n\x04type\x18\x01\x20\x02(\tR\ + \x04typeB\0\x12\x1a\n\x07content\x18\x02\x20\x01(\x0cR\x07contentB\0:\0\ + \"\xe2\x01\n\x04Stat\x12\x14\n\x04mode\x18\x01\x20\x02(\rR\x04modeB\0\ + \x12\x12\n\x03uid\x18\x02\x20\x01(\rR\x03uidB\0\x12\x12\n\x03gid\x18\x03\ + \x20\x01(\rR\x03gidB\0\x12\x14\n\x04size\x18\x04\x20\x01(\x04R\x04sizeB\ + \0\x12\x18\n\x06blocks\x18\x05\x20\x01(\x04R\x06blocksB\0\x12\x18\n\x06o\ + ffset\x18\x06\x20\x01(\x04R\x06offsetB\0\x12\x20\n\nbyteOffset\x18\x07\ + \x20\x01(\x04R\nbyteOffsetB\0\x12\x16\n\x05mtime\x18\x08\x20\x01(\x04R\ + \x05mtimeB\0\x12\x16\n\x05ctime\x18\t\x20\x01(\x04R\x05ctimeB\0:\0B\0b\ + \x06proto2\ "; -static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2< - ::protobuf::descriptor::FileDescriptorProto, -> = ::protobuf::rt::LazyV2::INIT; +static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() } pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - file_descriptor_proto_lazy.get(|| parse_descriptor_proto()) + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) } diff --git a/colmeia-hyperstack/Cargo.toml b/colmeia-hyperstack/Cargo.toml index b720a59..1fdfe1b 100644 --- a/colmeia-hyperstack/Cargo.toml +++ b/colmeia-hyperstack/Cargo.toml @@ -5,13 +5,13 @@ authors = ['Bruno Tavares '] edition = '2018' [dependencies] -futures = '0.3.5' -ed25519-dalek = '1.0.0-pre.3' -anyhow = '1.0.34' +futures = '0.3.12' +ed25519-dalek = '1.0.1' +anyhow = '1.0.38' random-access-storage = '4.0.0' random-access-memory = '2.0.0' random-access-disk = '2.0.0' -log = '0.4.8' +log = '0.4.14' hex = '0.4.2' thiserror = '1.0.20' @@ -22,7 +22,7 @@ path = '../colmeia-hyperswarm-mdns' path = '../colmeia-hyperdrive' [dependencies.async-std] -version = '1.6.2' +version = '1.9.0' features = ['unstable'] [dependencies.hypercore-protocol] diff --git a/colmeia-hyperswarm-dht/Cargo.toml b/colmeia-hyperswarm-dht/Cargo.toml new file mode 100644 index 0000000..c8470da --- /dev/null +++ b/colmeia-hyperswarm-dht/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = 'colmeia-hyperswarm-dht' +version = '0.1.0' +authors = ['Bruno Tavares '] +edition = '2018' + +[dependencies] +anyhow = '1.0.38' +futures = '0.3.12' + +[dependencies.hyperswarm-dht] +git = 'https://github.com/bltavares/hyperswarm-dht' +branch = 'update-ed25519-dalek' + +[dependencies.async-std] +version = '1.9.0' +features = ['unstable'] + diff --git a/colmeia-hyperswarm-dht/src/announcer.rs b/colmeia-hyperswarm-dht/src/announcer.rs new file mode 100644 index 0000000..d8d4af2 --- /dev/null +++ b/colmeia-hyperswarm-dht/src/announcer.rs @@ -0,0 +1,30 @@ +use async_std::sync::RwLock; +use futures::Stream; +use std::{ + net::SocketAddr, + pin::Pin, + sync::Arc, + task::{Context, Poll}, +}; + +pub struct Announcer { + topics: Arc>>, +} + +impl Announcer { + pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + Ok(()) + } + + pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + Ok(()) + } +} + +impl Stream for Announcer { + type Item = (Vec, SocketAddr); + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + Poll::Pending + } +} diff --git a/colmeia-hyperswarm-dht/src/lib.rs b/colmeia-hyperswarm-dht/src/lib.rs new file mode 100644 index 0000000..4ad45d9 --- /dev/null +++ b/colmeia-hyperswarm-dht/src/lib.rs @@ -0,0 +1,77 @@ +use std::{ + net::SocketAddr, + pin::Pin, + task::{Context, Poll}, + time::Duration, +}; + +use announcer::Announcer; +use futures::{Stream, StreamExt}; +use locator::Locator; + +pub mod announcer; +pub mod locator; + +struct DHTDiscovery { + announce: Option, + locate: Option, +} + +impl DHTDiscovery { + pub fn new() -> Self { + Self { + announce: None, + locate: None, + } + } + + pub fn with_locator(&mut self, duration: Duration) -> &mut Self { + self + } + + pub fn with_announcer(&mut self, port: u16) -> &mut Self { + self + } + + pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + if let Some(announcer) = &self.announce { + announcer.add_topic(topic).await?; + } + if let Some(locator) = &self.locate { + locator.add_topic(topic).await?; + } + Ok(()) + } + + pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + if let Some(announcer) = &self.announce { + announcer.remove_topic(topic).await?; + } + if let Some(locator) = &self.locate { + locator.remove_topic(topic).await?; + } + Ok(()) + } +} + +impl Stream for DHTDiscovery { + type Item = (Vec, SocketAddr); + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + if let Some(ref mut announcer) = &mut self.announce { + let _ = announcer.poll_next_unpin(cx); + }; + + if let Some(ref mut locate) = &mut self.locate { + return locate.poll_next_unpin(cx); + } + + Poll::Pending + } +} + +impl Default for DHTDiscovery { + fn default() -> Self { + Self::new() + } +} diff --git a/colmeia-hyperswarm-dht/src/locator.rs b/colmeia-hyperswarm-dht/src/locator.rs new file mode 100644 index 0000000..246114b --- /dev/null +++ b/colmeia-hyperswarm-dht/src/locator.rs @@ -0,0 +1,30 @@ +use async_std::sync::RwLock; +use futures::Stream; +use std::{ + net::SocketAddr, + pin::Pin, + sync::Arc, + task::{Context, Poll}, +}; + +pub struct Locator { + topics: Arc>>, +} + +impl Locator { + pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + Ok(()) + } + + pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + Ok(()) + } +} + +impl Stream for Locator { + type Item = (Vec, SocketAddr); + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + Poll::Pending + } +} diff --git a/colmeia-hyperswarm-mdns/Cargo.toml b/colmeia-hyperswarm-mdns/Cargo.toml index 6e114f3..ac46385 100644 --- a/colmeia-hyperswarm-mdns/Cargo.toml +++ b/colmeia-hyperswarm-mdns/Cargo.toml @@ -6,14 +6,14 @@ edition = '2018' [dependencies] hex = '0.4.2' -trust-dns-proto = '0.19.5' +trust-dns-proto = '0.20.0' lazy_static = '1.4.0' -log = '0.4.8' -futures = '0.3.5' -anyhow = '1.0.34' +log = '0.4.14' +futures = '0.3.12' +anyhow = '1.0.38' rand = '0.7.3' multicast-socket = '0.2.0' [dependencies.async-std] -version = '1.6.0' +version = '1.9.0' features = ['unstable'] diff --git a/colmeiad/Cargo.toml b/colmeiad/Cargo.toml index 8cf4969..6b6c2cf 100644 --- a/colmeiad/Cargo.toml +++ b/colmeiad/Cargo.toml @@ -5,11 +5,10 @@ authors = ['Bruno Tavares '] edition = '2018' [dependencies] -tide = '0.12.0' -env_logger = '0.7.1' +tide = '0.16.0' +env_logger = '0.8.2' random-access-storage = '4.0.0' -hypercore = '0.11.1-beta.9' -futures = '0.3.5' +futures = '0.3.12' [dependencies.serde] version = '1.0' @@ -19,8 +18,12 @@ features = ['derive'] path = '../colmeia-hyperstack' [dependencies.async-std] -version = '1.6.0' +version = '1.9.0' features = [ 'unstable', 'attributes', ] + +[dependencies.hypercore] +git = 'https://github.com/bltavares/hypercore' +branch = 'update-ed25519-dalek' diff --git a/colmeiad/src/main.rs b/colmeiad/src/main.rs index a5c0c79..5ed729e 100644 --- a/colmeiad/src/main.rs +++ b/colmeiad/src/main.rs @@ -65,7 +65,7 @@ where #[async_std::main] async fn main() -> Result<(), std::io::Error> { - env_logger::from_env(env_logger::Env::default().default_filter_or("info")).init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let key = name(); let hash = key.parse_from_hash().expect("invalid hash argument"); @@ -83,7 +83,7 @@ async fn main() -> Result<(), std::io::Error> { let hyperdrive = hyperstack.hyperdrive(); let mut app = tide::with_state(hyperdrive); - app.middleware(tide::log::LogMiddleware::new()); + app.with(tide::log::LogMiddleware::new()); app.at("/").get(get_info); app.listen("127.0.0.1:8080").await?; job.await; From 76efa85618376b0ae0648a0fa93139ef0dc2dc07 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Fri, 5 Feb 2021 00:27:38 -0300 Subject: [PATCH 02/16] Update multicast socket --- Cargo.lock | 10 +++++----- colmeia-hyperswarm-mdns/Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 01c239f..a55081d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1726,9 +1726,9 @@ checksum = "864e1de64c29b386d2dc7822aea156a7e4d45d4393ac748878dc21c9c41037f0" [[package]] name = "multicast-socket" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4165a42af1448862a88ff0f706890484eb67e95c571aedfe677155e002967970" +checksum = "f57ecf9fdf74f516fc284b0ac77e496d434298b868c3e501e78a233d6a235c15" dependencies = [ "get_if_addrs", "libc", @@ -1755,13 +1755,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.18.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" +checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" dependencies = [ "bitflags", "cc", - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", ] diff --git a/colmeia-hyperswarm-mdns/Cargo.toml b/colmeia-hyperswarm-mdns/Cargo.toml index ac46385..fc4fafe 100644 --- a/colmeia-hyperswarm-mdns/Cargo.toml +++ b/colmeia-hyperswarm-mdns/Cargo.toml @@ -12,7 +12,7 @@ log = '0.4.14' futures = '0.3.12' anyhow = '1.0.38' rand = '0.7.3' -multicast-socket = '0.2.0' +multicast-socket = '0.2.1' [dependencies.async-std] version = '1.9.0' From c1a7508e95a114186e6955c8afb4f2c7270bdfe7 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sat, 6 Feb 2021 17:13:13 -0300 Subject: [PATCH 03/16] WIP - structures in places - in-theory it should work --- Cargo.lock | 3 + colmeia-bins/Cargo.toml | 7 ++ .../src/bin/colmeia-hyperswarm-dht.rs | 76 ++++++++++++++ colmeia-bins/src/bin/dht-bootstrap.rs | 22 +++++ colmeia-hyperswarm-dht/Cargo.toml | 1 + colmeia-hyperswarm-dht/src/announcer.rs | 98 ++++++++++++++++++- colmeia-hyperswarm-dht/src/dht.rs | 21 ++++ colmeia-hyperswarm-dht/src/lib.rs | 29 ++++-- colmeia-hyperswarm-dht/src/locator.rs | 77 ++++++++++++++- 9 files changed, 318 insertions(+), 16 deletions(-) create mode 100644 colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs create mode 100644 colmeia-bins/src/bin/dht-bootstrap.rs create mode 100644 colmeia-hyperswarm-dht/src/dht.rs diff --git a/Cargo.lock b/Cargo.lock index a55081d..ee1ecbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -665,10 +665,12 @@ version = "0.1.0" dependencies = [ "async-std", "colmeia-hyperstack", + "colmeia-hyperswarm-dht", "colmeia-hyperswarm-mdns", "env_logger 0.8.2", "hex", "hypercore-protocol", + "hyperswarm-dht", "log", ] @@ -732,6 +734,7 @@ dependencies = [ "async-std", "futures", "hyperswarm-dht", + "log", ] [[package]] diff --git a/colmeia-bins/Cargo.toml b/colmeia-bins/Cargo.toml index 2a6328a..0d4768f 100644 --- a/colmeia-bins/Cargo.toml +++ b/colmeia-bins/Cargo.toml @@ -16,8 +16,15 @@ features = ['unstable'] [dependencies.hypercore-protocol] git = 'https://github.com/Frando/hypercore-protocol-rs' +[dependencies.hyperswarm-dht] +git = 'https://github.com/bltavares/hyperswarm-dht' +branch = 'update-ed25519-dalek' + [dependencies.colmeia-hyperswarm-mdns] path = '../colmeia-hyperswarm-mdns' +[dependencies.colmeia-hyperswarm-dht] +path = '../colmeia-hyperswarm-dht' + [dependencies.colmeia-hyperstack] path = '../colmeia-hyperstack' diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs new file mode 100644 index 0000000..ff76fe4 --- /dev/null +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -0,0 +1,76 @@ +use async_std::{prelude::StreamExt, task}; +use colmeia_hyperstack::utils::PublicKeyExt; +use colmeia_hyperswarm_dht::{announcer::Announcer, dht::Config, locator::Locator}; +use std::{env, time::Duration}; + +// 7e5998407b3d9dbb94db21ff50ad6f1b1d2c79e476fbaf9856c342eb4382e7f5 +// pra +// b62ef6792a0e2f2c5be328593532415d80c0f52c // 32 bytes +// Derivacao igual ao dat1 +fn main() { + log::debug!("Starting up"); + let hyper_hash = env::args() + .nth(1) + .expect("provide a hyper hash as argument"); + + let bootstrap_servers = env::args() + .nth(2) + .map(|x| x.split(',').map(str::to_owned).collect()) + .unwrap_or_else(|| { + hyperswarm_dht::DEFAULT_BOOTSTRAP + .iter() + .map(|&x| x.to_owned()) + .collect() + }); + + let _duration = env::args() + .nth(3) + .unwrap_or_else(|| "10".into()) + .parse::() + .expect("Could not parse duration into a number"); + + env_logger::init(); + + let key = hyper_hash.parse_from_hash().expect("could not parse hash"); + + let config = Config { bootstrap_servers }; + + task::block_on(async move { + log::info!("Starting up"); + + let topic = hypercore_protocol::discovery_key(key.as_bytes()); + let announcer = Announcer::new(&config) + .await + .expect("could not start announcer"); + + let mut locator = Locator::new(&config) + .await + .expect("Could not start locator"); + + log::info!("Adding topic"); + announcer + .add_topic(&topic) + .await + .expect("could not write topic"); + + log::info!("Finding topic"); + locator + .add_topic(&topic) + .await + .expect("Could not exec find topic"); + + let result = locator.next().await; + log::debug!("Found peer: {:?}", result); + + log::info!("Remove topic"); + announcer + .remove_topic(&topic) + .await + .expect("could not remove topic"); + + log::info!("Sleep"); + task::sleep(Duration::from_secs(60)).await; + + log::info!("Done"); + }); +} diff --git a/colmeia-bins/src/bin/dht-bootstrap.rs b/colmeia-bins/src/bin/dht-bootstrap.rs new file mode 100644 index 0000000..da9bfc8 --- /dev/null +++ b/colmeia-bins/src/bin/dht-bootstrap.rs @@ -0,0 +1,22 @@ +use async_std::{prelude::StreamExt, task}; +use hyperswarm_dht::{DhtConfig, HyperDht}; + +fn main() { + env_logger::init(); + + task::block_on(async move { + let config = DhtConfig::default().ephemeral().empty_bootstrap_nodes(); + let mut bootstrap = HyperDht::with_config(config) + .await + .expect("Could not start service"); + + log::info!( + "Bootstrap server running on: {}", + bootstrap.local_addr().expect("could not get local address") + ); + + while let Some(event) = bootstrap.next().await { + log::debug!("Event: {:?}", event); + } + }); +} diff --git a/colmeia-hyperswarm-dht/Cargo.toml b/colmeia-hyperswarm-dht/Cargo.toml index c8470da..0a155a2 100644 --- a/colmeia-hyperswarm-dht/Cargo.toml +++ b/colmeia-hyperswarm-dht/Cargo.toml @@ -7,6 +7,7 @@ edition = '2018' [dependencies] anyhow = '1.0.38' futures = '0.3.12' +log = '0.4.14' [dependencies.hyperswarm-dht] git = 'https://github.com/bltavares/hyperswarm-dht' diff --git a/colmeia-hyperswarm-dht/src/announcer.rs b/colmeia-hyperswarm-dht/src/announcer.rs index d8d4af2..7ab5cbe 100644 --- a/colmeia-hyperswarm-dht/src/announcer.rs +++ b/colmeia-hyperswarm-dht/src/announcer.rs @@ -1,22 +1,112 @@ -use async_std::sync::RwLock; -use futures::Stream; +use async_std::{sync::RwLock, task}; +use futures::{channel::mpsc, FutureExt, SinkExt, Stream, StreamExt}; +use hyperswarm_dht::{HyperDht, QueryOpts}; use std::{ + collections::HashSet, + convert::{TryFrom, TryInto}, + io, net::SocketAddr, pin::Pin, sync::Arc, task::{Context, Poll}, + time::{Duration, Instant}, }; +use crate::dht::{dht, Config}; + pub struct Announcer { - topics: Arc>>, + swarm: Arc>, + topics: Arc>>>, + _listener_task: task::JoinHandle<()>, + receiver: mpsc::UnboundedReceiver<(Vec, SocketAddr)>, } +// TODO impl Drop unnanaounce impl Announcer { + pub async fn new(config: &Config) -> io::Result { + let swarm = dht(config).await?; + let swarm = Arc::new(RwLock::new(swarm)); + let topics: Arc>>> = Default::default(); + + let (mut sender, receiver) = mpsc::unbounded(); + + let _listener_task = { + let swarm = swarm.clone(); + let topics = topics.clone(); + task::spawn(async move { + let mut timer = std::time::Instant::now(); + + loop { + if let Some(Some(event)) = swarm.write().await.next().now_or_never() { + match event { + hyperswarm_dht::HyperDhtEvent::AnnounceResult { + peers, + topic, + query_id, + } => { + let topic = topic.to_vec(); + for peer in peers + .iter() + .flat_map(|z| z.peers.iter().copied()) + .chain(peers.iter().flat_map(|z| z.local_peers.iter().copied())) + { + let result = sender.send((topic.clone(), peer)).await; + if let Err(e) = result { + log::warn!("Could not send peer: {:?}", e); + } + } + log::debug!("announced {:?}", (peers, topic, query_id)); + } + hyperswarm_dht::HyperDhtEvent::UnAnnounceResult { + peers, + topic, + query_id, + } => { + log::debug!("un-announced {:?}", (peers, topic, query_id)); + } + e => { + log::debug!("another event {:?}", e); + } + } + } + + // TODO config + if timer.elapsed() > Duration::from_secs(10) { + log::debug!("Broadcasting new announcement of current topics"); + for topic in topics.read().await.iter() { + if let Ok(query) = QueryOpts::try_from(&topic[..]) { + // TODO config + let query = query.port(1000); + swarm.write().await.announce(query); + } + } + timer = Instant::now(); + } + } + }) + }; + + Ok(Self { + topics, + swarm, + _listener_task, + receiver, + }) + } + pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + let query: QueryOpts = topic.try_into()?; + let query = query.port(1000); // TODO: port + dbg!(self.swarm.write().await.announce(query)); // TODO: spawn await on io pool + self.topics.write().await.insert(topic.to_vec()); Ok(()) } pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + let query: QueryOpts = topic.try_into()?; + let query = query.port(1000); // TODO: port + self.swarm.write().await.unannounce(query); // TODO: spawn await on io pool + self.topics.write().await.remove(topic); Ok(()) } } @@ -25,6 +115,6 @@ impl Stream for Announcer { type Item = (Vec, SocketAddr); fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { - Poll::Pending + self.receiver.poll_next_unpin(cx) } } diff --git a/colmeia-hyperswarm-dht/src/dht.rs b/colmeia-hyperswarm-dht/src/dht.rs new file mode 100644 index 0000000..717d326 --- /dev/null +++ b/colmeia-hyperswarm-dht/src/dht.rs @@ -0,0 +1,21 @@ +use std::{io, net::SocketAddr}; + +use async_std::net::UdpSocket; +use hyperswarm_dht::{DhtConfig, HyperDht}; + +pub struct Config { + pub bootstrap_servers: Vec, +} + +pub(crate) async fn dht(config: &Config) -> io::Result { + // TODO config + let bind_address: SocketAddr = ([0, 0, 0, 0], 0).into(); + let socket = UdpSocket::bind(bind_address).await?; + let dht_config = DhtConfig::default() + .set_socket(socket) + .set_bootstrap_nodes(&config.bootstrap_servers) + .adaptive() // Becomes non-ephemeral after 30m + .ephemeral(); // ephemeral defaults to true in discovery but defaults to false in dht + let swarm = HyperDht::with_config(dht_config).await?; + Ok(swarm) +} diff --git a/colmeia-hyperswarm-dht/src/lib.rs b/colmeia-hyperswarm-dht/src/lib.rs index 4ad45d9..66e1580 100644 --- a/colmeia-hyperswarm-dht/src/lib.rs +++ b/colmeia-hyperswarm-dht/src/lib.rs @@ -1,3 +1,4 @@ +use futures::{Stream, StreamExt}; use std::{ net::SocketAddr, pin::Pin, @@ -5,31 +6,38 @@ use std::{ time::Duration, }; -use announcer::Announcer; -use futures::{Stream, StreamExt}; -use locator::Locator; +pub use announcer::Announcer; +pub use dht::Config; +pub use locator::Locator; pub mod announcer; +pub mod dht; pub mod locator; -struct DHTDiscovery { +pub struct DHTDiscovery { announce: Option, locate: Option, + config: Config, } impl DHTDiscovery { - pub fn new() -> Self { + pub fn new(config: Config) -> Self { Self { + config, announce: None, locate: None, } } - pub fn with_locator(&mut self, duration: Duration) -> &mut Self { + pub async fn with_announcer(&mut self, duration: Duration) -> &mut Self { + let announcer = Announcer::new(&self.config).await; + self.announce = announcer.ok(); self } - pub fn with_announcer(&mut self, port: u16) -> &mut Self { + pub async fn with_locator(&mut self, port: u16, duration: Duration) -> &mut Self { + let locator = Locator::new(&self.config).await; + self.locate = locator.ok(); self } @@ -72,6 +80,11 @@ impl Stream for DHTDiscovery { impl Default for DHTDiscovery { fn default() -> Self { - Self::new() + Self::new(Config { + bootstrap_servers: hyperswarm_dht::DEFAULT_BOOTSTRAP + .iter() + .map(|&z| z.to_owned()) + .collect(), + }) } } diff --git a/colmeia-hyperswarm-dht/src/locator.rs b/colmeia-hyperswarm-dht/src/locator.rs index 246114b..3baec04 100644 --- a/colmeia-hyperswarm-dht/src/locator.rs +++ b/colmeia-hyperswarm-dht/src/locator.rs @@ -1,22 +1,91 @@ -use async_std::sync::RwLock; -use futures::Stream; +use async_std::{sync::RwLock, task}; +use futures::{channel::mpsc, FutureExt, SinkExt, Stream, StreamExt}; +use hyperswarm_dht::QueryOpts; use std::{ + collections::HashSet, + convert::{TryFrom, TryInto}, + io, net::SocketAddr, pin::Pin, sync::Arc, task::{Context, Poll}, + time::{Duration, Instant}, }; +use crate::dht::{dht, Config}; + pub struct Locator { - topics: Arc>>, + topics: Arc>>>, + _job: task::JoinHandle<()>, + swarm: Arc>, + receiver: mpsc::UnboundedReceiver<(Vec, SocketAddr)>, } impl Locator { + pub async fn new(config: &Config) -> io::Result { + let swarm = dht(config).await?; + let swarm = Arc::new(RwLock::new(swarm)); + let topics: Arc>>> = Default::default(); + + let (mut sender, receiver) = mpsc::unbounded(); + + let _job = { + let swarm = swarm.clone(); + let topics = topics.clone(); + task::spawn(async move { + let mut timer = std::time::Instant::now(); + + loop { + if let Some(Some(event)) = swarm.write().await.next().now_or_never() { + match event { + hyperswarm_dht::HyperDhtEvent::LookupResult { lookup, query_id } => { + let topic = lookup.topic.to_vec(); + for peer in lookup.all_peers().copied() { + let result = sender.send((topic.clone(), peer)).await; + if let Err(e) = result { + log::warn!("Could not send peer: {:?}", e); + } + } + + log::debug!("lookup {:?}", (lookup, query_id)); + } + e => { + log::debug!("another event {:?}", e); + } + } + } + + // TODO config + if timer.elapsed() > Duration::from_secs(10) { + log::debug!("Broadcasting new lookup of current topics"); + for topic in topics.read().await.iter() { + if let Ok(query) = QueryOpts::try_from(&topic[..]) { + swarm.write().await.lookup(query); + } + } + timer = Instant::now(); + } + } + }) + }; + + Ok(Self { + topics, + swarm, + _job, + receiver, + }) + } + pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + let query: QueryOpts = topic.try_into()?; + self.swarm.write().await.lookup(query); + self.topics.write().await.insert(topic.to_vec()); Ok(()) } pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { + self.topics.write().await.remove(topic); Ok(()) } } @@ -25,6 +94,6 @@ impl Stream for Locator { type Item = (Vec, SocketAddr); fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { - Poll::Pending + self.receiver.poll_next_unpin(cx) } } From a45413cefd696c411d07211dbe2f830e11857067 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sat, 6 Feb 2021 17:28:30 -0300 Subject: [PATCH 04/16] Integrate dht on hyperstack --- Cargo.lock | 1 + colmeia-bins/src/bin/colmeia-sync.rs | 5 +++-- colmeia-hyperstack/Cargo.toml | 3 +++ colmeia-hyperstack/src/hyperstack.rs | 12 ++++++++++++ colmeia-hyperswarm-dht/src/dht.rs | 11 +++++++++++ colmeia-hyperswarm-dht/src/lib.rs | 11 +++-------- colmeiad/src/main.rs | 5 +++-- 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee1ecbf..0eabc30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -714,6 +714,7 @@ dependencies = [ "anyhow", "async-std", "colmeia-hyperdrive", + "colmeia-hyperswarm-dht", "colmeia-hyperswarm-mdns", "ed25519-dalek", "futures", diff --git a/colmeia-bins/src/bin/colmeia-sync.rs b/colmeia-bins/src/bin/colmeia-sync.rs index cad7060..f69d6b0 100644 --- a/colmeia-bins/src/bin/colmeia-sync.rs +++ b/colmeia-bins/src/bin/colmeia-sync.rs @@ -1,4 +1,4 @@ -use async_std::task; +use async_std::{prelude::StreamExt, task}; use colmeia_hyperstack::{utils::PublicKeyExt, Hyperstack}; fn name() -> String { @@ -25,7 +25,8 @@ fn main() { .await .expect("Could not start hyperdrive on the stack"); let mdns = hyperstack.lan().await.expect("could not configure mdns"); - hyperstack.with_discovery(mdns); + let dht = hyperstack.dht().await.expect("could not start dht"); + hyperstack.with_discovery(mdns.merge(dht)); hyperstack.replicate().await; }); } diff --git a/colmeia-hyperstack/Cargo.toml b/colmeia-hyperstack/Cargo.toml index 1fdfe1b..fce78b6 100644 --- a/colmeia-hyperstack/Cargo.toml +++ b/colmeia-hyperstack/Cargo.toml @@ -18,6 +18,9 @@ thiserror = '1.0.20' [dependencies.colmeia-hyperswarm-mdns] path = '../colmeia-hyperswarm-mdns' +[dependencies.colmeia-hyperswarm-dht] +path = '../colmeia-hyperswarm-dht' + [dependencies.colmeia-hyperdrive] path = '../colmeia-hyperdrive' diff --git a/colmeia-hyperstack/src/hyperstack.rs b/colmeia-hyperstack/src/hyperstack.rs index 687e097..ca682f1 100644 --- a/colmeia-hyperstack/src/hyperstack.rs +++ b/colmeia-hyperstack/src/hyperstack.rs @@ -6,6 +6,7 @@ use async_std::{ task, }; use colmeia_hyperdrive::Hyperdrive; +use colmeia_hyperswarm_dht::Config; use ed25519_dalek::PublicKey; use futures::{Future, Stream, StreamExt}; use hypercore_protocol::ProtocolBuilder; @@ -76,6 +77,17 @@ where Ok(mdns) } + pub async fn dht(&self) -> anyhow::Result, SocketAddr)>> { + let mut dht = colmeia_hyperswarm_dht::DHTDiscovery::default(); + dht.with_announcer(self.listen_address.port(), Duration::from_secs(60)) + .await + .with_locator(Duration::from_secs(60)) + .await; + dht.add_topic(&hypercore_protocol::discovery_key(self.key.as_bytes())) + .await?; + Ok(dht) + } + pub fn with_discovery( &mut self, mechanisms: impl Stream, SocketAddr)> + Unpin + 'static + Send, diff --git a/colmeia-hyperswarm-dht/src/dht.rs b/colmeia-hyperswarm-dht/src/dht.rs index 717d326..da98f5d 100644 --- a/colmeia-hyperswarm-dht/src/dht.rs +++ b/colmeia-hyperswarm-dht/src/dht.rs @@ -7,6 +7,17 @@ pub struct Config { pub bootstrap_servers: Vec, } +impl Default for Config { + fn default() -> Self { + Config { + bootstrap_servers: hyperswarm_dht::DEFAULT_BOOTSTRAP + .iter() + .map(|&z| z.to_owned()) + .collect(), + } + } +} + pub(crate) async fn dht(config: &Config) -> io::Result { // TODO config let bind_address: SocketAddr = ([0, 0, 0, 0], 0).into(); diff --git a/colmeia-hyperswarm-dht/src/lib.rs b/colmeia-hyperswarm-dht/src/lib.rs index 66e1580..8f0a9a1 100644 --- a/colmeia-hyperswarm-dht/src/lib.rs +++ b/colmeia-hyperswarm-dht/src/lib.rs @@ -29,13 +29,13 @@ impl DHTDiscovery { } } - pub async fn with_announcer(&mut self, duration: Duration) -> &mut Self { + pub async fn with_announcer(&mut self, port: u16, duration: Duration) -> &mut Self { let announcer = Announcer::new(&self.config).await; self.announce = announcer.ok(); self } - pub async fn with_locator(&mut self, port: u16, duration: Duration) -> &mut Self { + pub async fn with_locator(&mut self, duration: Duration) -> &mut Self { let locator = Locator::new(&self.config).await; self.locate = locator.ok(); self @@ -80,11 +80,6 @@ impl Stream for DHTDiscovery { impl Default for DHTDiscovery { fn default() -> Self { - Self::new(Config { - bootstrap_servers: hyperswarm_dht::DEFAULT_BOOTSTRAP - .iter() - .map(|&z| z.to_owned()) - .collect(), - }) + Self::new(Config::default()) } } diff --git a/colmeiad/src/main.rs b/colmeiad/src/main.rs index 5ed729e..15f9416 100644 --- a/colmeiad/src/main.rs +++ b/colmeiad/src/main.rs @@ -1,4 +1,4 @@ -use async_std::{sync::RwLock, task}; +use async_std::{prelude::StreamExt, sync::RwLock, task}; use colmeia_hyperstack::{hyperdrive::Hyperdrive, utils::PublicKeyExt, Hyperstack}; use futures::future::OptionFuture; use std::sync::Arc; @@ -77,7 +77,8 @@ async fn main() -> Result<(), std::io::Error> { .lan() .await .expect("could not add key to mdns discovery"); - hyperstack.with_discovery(mdns); + let dht = hyperstack.dht().await.expect("could not start dht"); + hyperstack.with_discovery(mdns.merge(dht)); let job = task::spawn(hyperstack.replicate()); let hyperdrive = hyperstack.hyperdrive(); From f3000ff440d3c9fb53ef699085aa33325ed79767 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 14 Mar 2021 23:07:41 -0300 Subject: [PATCH 05/16] Helper utils to dump hyper hash info --- Cargo.lock | 1 + README.md | 16 +++++++-- colmeia-bins/Cargo.toml | 1 + colmeia-bins/src/bin/colmeia-url-meta.rs | 44 ++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 colmeia-bins/src/bin/colmeia-url-meta.rs diff --git a/Cargo.lock b/Cargo.lock index 0eabc30..b7a2075 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -667,6 +667,7 @@ dependencies = [ "colmeia-hyperstack", "colmeia-hyperswarm-dht", "colmeia-hyperswarm-mdns", + "ed25519-dalek", "env_logger 0.8.2", "hex", "hypercore-protocol", diff --git a/README.md b/README.md index 112fcf5..23e68d8 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,18 @@ Uses NOISE protocol and a different handshake. ## CLI binaries +### Dump hash metadata + +```sh +cargo run --bin colmeia-url-meta -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 +``` + ```txt -Local dat2: be41e3d43d054982e14dfc60281d9d4425ab5d4b0b280a355b7927869ca08fc5 +Valid public key. +Public Hexa b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 +Public Bytes [180, 94, 202, 12, 223, 51, 25, 88, 33, 185, 77, 195, 131, 100, 96, 6, 88, 100, 235, 214, 33, 201, 160, 90, 168, 197, 70, 152, 200, 179, 136, 182] +Discovery Hexa b172d7304b7df9d539b67ca100a1930ae102111fc253cf784e649231956a9b9c +Discovery Bytes [177, 114, 215, 48, 75, 125, 249, 213, 57, 182, 124, 161, 0, 161, 147, 10, 225, 2, 17, 31, 194, 83, 207, 120, 78, 100, 146, 49, 149, 106, 155, 156] ``` ### Find a local peer @@ -89,7 +99,7 @@ Local dat2: be41e3d43d054982e14dfc60281d9d4425ab5d4b0b280a355b7927869ca08fc5 [colmeia-mdns](./colmeia-bins/src/bin/colmeia-hyperswarm-mdns.rs) ```sh -RUST_LOG=debug cargo run --bin colmeia-hyperswarm-mdns -- 7e5998407b3d9dbb94db21ff50ad6f1b1d2c79e476fbaf9856c342eb4382e7f5 8000 +RUST_LOG=debug cargo run --bin colmeia-hyperswarm-mdns -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 8000 ``` ### Connect and troubleshoot a peer @@ -97,7 +107,7 @@ RUST_LOG=debug cargo run --bin colmeia-hyperswarm-mdns -- 7e5998407b3d9dbb94db21 [colmeia-nc](./colmeia-bins/src/bin/colmeia-nc.rs) ```sh -RUST_LOG=debug cargo run --bin colmeia-nc -- 7e5998407b3d9dbb94db21ff50ad6f1b1d2c79e476fbaf9856c342eb4382e7f5 127.0.0.1:3282 +RUST_LOG=debug cargo run --bin colmeia-nc -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 127.0.0.1:3282 ``` ### Clone from a single host diff --git a/colmeia-bins/Cargo.toml b/colmeia-bins/Cargo.toml index 0d4768f..94cc36b 100644 --- a/colmeia-bins/Cargo.toml +++ b/colmeia-bins/Cargo.toml @@ -8,6 +8,7 @@ edition = '2018' env_logger = '*' log = '*' hex = '*' +ed25519-dalek = '*' [dependencies.async-std] version = '1.9.0' diff --git a/colmeia-bins/src/bin/colmeia-url-meta.rs b/colmeia-bins/src/bin/colmeia-url-meta.rs new file mode 100644 index 0000000..a00715c --- /dev/null +++ b/colmeia-bins/src/bin/colmeia-url-meta.rs @@ -0,0 +1,44 @@ +use std::env; + +use colmeia_hyperstack::utils::{HashParserError, PublicKeyExt}; +use ed25519_dalek::PublicKey; + +fn main() { + let hyper_hash = env::args() + .nth(1) + .expect("provide a hyper hash as argument"); + + let key = hyper_hash.parse_from_hash(); + + match key { + Ok(public) => { + valid_public_key(&public); + } + Err(e) => { + invalid_public_key(e); + } + } +} + +fn invalid_public_key(e: HashParserError) -> () { + match e { + HashParserError::InvalidHexHash(_) => { + eprintln!("Invalid hyper url"); + } + HashParserError::InvalidPublicKey(_) => { + eprintln!("Invalid public key. This is likely the discovery key."); + } + } +} + +fn valid_public_key(public: &PublicKey) { + println!("Valid public key."); + let bytes = public.as_bytes(); + println!("Public Hexa\t{}", hex::encode(bytes)); + println!("Public Bytes\t{:?}", bytes); + + let topic = hypercore_protocol::discovery_key(bytes); + + println!("Discovery Hexa\t{}", hex::encode(&topic)); + println!("Discovery Bytes\t{:?}", topic); +} From 0fe4b50ad2a8c05c0b633edf50b05d1d6becffdc Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Thu, 13 May 2021 01:39:09 -0300 Subject: [PATCH 06/16] Document changes --- README.md | 38 ++++++++++++++++++++++++- colmeia-hyperstack/src/hyperstack.rs | 6 ++-- colmeia-hyperswarm-dht/src/announcer.rs | 2 +- colmeia-hyperswarm-dht/src/dht.rs | 1 + 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 23e68d8..d90a59f 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,10 @@ Uses NOISE protocol and a different handshake. - [x] `Mdns`: announces and find dat in the network - [ ] Tests - [ ] All protocol 1:1 -- [ ] `colmeia-dht`: Interop with hypwerswarm dht infrastructure (:eyes: ) +- [x] `colmeia-dht`: Interop with hypwerswarm dht infrastructure (:eyes: ) + - [x] `Locator`: stream to find dat members in the network + - [x] `Announcer`: stream that announces a dat in the network + - [x] `Dht`: announces and find dat in the network - [ ] Tests - [ ] All protocol 1:1 @@ -80,6 +83,20 @@ Uses NOISE protocol and a different handshake. ## CLI binaries +### Server + +Start the web service using `colmeiad`: + +```sh +cargo run -p colmeiad -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 +``` + +You be able to get the information about the blocks on `/` + +```sh +curl -v http://localhost:8080 +``` + ### Dump hash metadata ```sh @@ -116,6 +133,20 @@ RUST_LOG=debug cargo run --bin colmeia-nc -- b45eca0cdf33195821b94dc383646006586 RUST_LOG=debug cargo run --bin colmeia-clone -- 192.168.15.173:3282 dat://6268b99fbacacea49c6bc3d4776b606db2aeadb3fa831342ba9f70d55c98929f ``` +### Test discovery mechanisms + +#### MDNS + +```sh +cargo run --bin colmeia-hyperswarm-mdns -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 8000 +``` + +#### DHT + +```sh +cargo run --bin colmeia-hyperswarm-dht -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 +``` + ## Platforms :warning: **TODO**: redo support as part of dat -> hypercore migration @@ -203,3 +234,8 @@ Run and `scp` the binaries on `target/mips-unknown-linux-musl`: ```sh cross build --target mips-unknown-linux-musl ``` + +## Other hypercores to test + +- `94f0cab7f60fcc2a711df11c85db5e0594d11e8a3efd04a06f46a3c34d03c418` +- `b282d5efe484143816362d33b3f9b3ea45ecfb8a6ada97e278fdfdc6a725e22f` diff --git a/colmeia-hyperstack/src/hyperstack.rs b/colmeia-hyperstack/src/hyperstack.rs index ca682f1..6eee675 100644 --- a/colmeia-hyperstack/src/hyperstack.rs +++ b/colmeia-hyperstack/src/hyperstack.rs @@ -71,8 +71,8 @@ where pub async fn lan(&self) -> anyhow::Result, SocketAddr)>> { let mut mdns = colmeia_hyperswarm_mdns::MdnsDiscovery::new(); mdns.with_announcer(self.listen_address.port()) - .with_locator(Duration::from_secs(60)); - mdns.add_topic(hypercore_protocol::discovery_key(self.key.as_bytes())) + .with_locator(Duration::from_secs(60)); // TODO: config + mdns.add_topic(&hypercore_protocol::discovery_key(self.key.as_bytes())) .await?; Ok(mdns) } @@ -81,7 +81,7 @@ where let mut dht = colmeia_hyperswarm_dht::DHTDiscovery::default(); dht.with_announcer(self.listen_address.port(), Duration::from_secs(60)) .await - .with_locator(Duration::from_secs(60)) + .with_locator(Duration::from_secs(60)) // TODO: config .await; dht.add_topic(&hypercore_protocol::discovery_key(self.key.as_bytes())) .await?; diff --git a/colmeia-hyperswarm-dht/src/announcer.rs b/colmeia-hyperswarm-dht/src/announcer.rs index 7ab5cbe..db6c77b 100644 --- a/colmeia-hyperswarm-dht/src/announcer.rs +++ b/colmeia-hyperswarm-dht/src/announcer.rs @@ -1,4 +1,4 @@ -use async_std::{sync::RwLock, task}; +use async_std::{future, sync::RwLock, task}; use futures::{channel::mpsc, FutureExt, SinkExt, Stream, StreamExt}; use hyperswarm_dht::{HyperDht, QueryOpts}; use std::{ diff --git a/colmeia-hyperswarm-dht/src/dht.rs b/colmeia-hyperswarm-dht/src/dht.rs index da98f5d..7ea4c54 100644 --- a/colmeia-hyperswarm-dht/src/dht.rs +++ b/colmeia-hyperswarm-dht/src/dht.rs @@ -1,6 +1,7 @@ use std::{io, net::SocketAddr}; use async_std::net::UdpSocket; +use futures::StreamExt; use hyperswarm_dht::{DhtConfig, HyperDht}; pub struct Config { From 5ba53bb6d1627c96b08df0189e7465e39eea1822 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Thu, 13 May 2021 01:57:30 -0300 Subject: [PATCH 07/16] Remove dbg//side-effect --- colmeia-hyperswarm-dht/src/announcer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colmeia-hyperswarm-dht/src/announcer.rs b/colmeia-hyperswarm-dht/src/announcer.rs index db6c77b..7de8e22 100644 --- a/colmeia-hyperswarm-dht/src/announcer.rs +++ b/colmeia-hyperswarm-dht/src/announcer.rs @@ -97,7 +97,7 @@ impl Announcer { pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; let query = query.port(1000); // TODO: port - dbg!(self.swarm.write().await.announce(query)); // TODO: spawn await on io pool + self.swarm.write().await.announce(query); // TODO: spawn await on io pool self.topics.write().await.insert(topic.to_vec()); Ok(()) } From b989a4225f338cc53a4776e0f9d717c110a50807 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Thu, 13 May 2021 02:02:02 -0300 Subject: [PATCH 08/16] Point hyperswarm-dht to version with patches --- Cargo.lock | 2 +- colmeia-bins/Cargo.toml | 2 +- colmeia-hyperswarm-dht/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7a2075..e0f623a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1518,7 +1518,7 @@ dependencies = [ [[package]] name = "hyperswarm-dht" version = "0.1.0" -source = "git+https://github.com/bltavares/hyperswarm-dht?branch=update-ed25519-dalek#3646ee540205c15ca3869c635f6187307df49cc2" +source = "git+https://github.com/bltavares/hyperswarm-dht?branch=wip#0677030b7aafc30cec464b0cf31d8df3f2496cf9" dependencies = [ "anyhow", "arrayvec 0.5.2", diff --git a/colmeia-bins/Cargo.toml b/colmeia-bins/Cargo.toml index 94cc36b..b6fe355 100644 --- a/colmeia-bins/Cargo.toml +++ b/colmeia-bins/Cargo.toml @@ -19,7 +19,7 @@ git = 'https://github.com/Frando/hypercore-protocol-rs' [dependencies.hyperswarm-dht] git = 'https://github.com/bltavares/hyperswarm-dht' -branch = 'update-ed25519-dalek' +branch = 'wip' [dependencies.colmeia-hyperswarm-mdns] path = '../colmeia-hyperswarm-mdns' diff --git a/colmeia-hyperswarm-dht/Cargo.toml b/colmeia-hyperswarm-dht/Cargo.toml index 0a155a2..0160753 100644 --- a/colmeia-hyperswarm-dht/Cargo.toml +++ b/colmeia-hyperswarm-dht/Cargo.toml @@ -11,7 +11,7 @@ log = '0.4.14' [dependencies.hyperswarm-dht] git = 'https://github.com/bltavares/hyperswarm-dht' -branch = 'update-ed25519-dalek' +branch = 'wip' [dependencies.async-std] version = '1.9.0' From 359dac512d75c5f1be2da189cdebaca1bf75bafd Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 16 May 2021 21:54:59 -0300 Subject: [PATCH 09/16] Fix warnings, clippy and todos on dht --- .../src/bin/colmeia-hyperswarm-dht.rs | 13 ++++--- colmeia-hyperdrive/src/network.rs | 4 +-- colmeia-hyperswarm-dht/src/announcer.rs | 35 ++++++++++++------- colmeia-hyperswarm-dht/src/dht.rs | 12 ++++--- colmeia-hyperswarm-dht/src/lib.rs | 14 ++++++-- colmeia-hyperswarm-dht/src/locator.rs | 22 ++++++++---- colmeia-hyperswarm-mdns/src/lib.rs | 1 + 7 files changed, 67 insertions(+), 34 deletions(-) diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs index ff76fe4..16296c0 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -23,7 +23,7 @@ fn main() { .collect() }); - let _duration = env::args() + let duration = env::args() .nth(3) .unwrap_or_else(|| "10".into()) .parse::() @@ -33,17 +33,22 @@ fn main() { let key = hyper_hash.parse_from_hash().expect("could not parse hash"); - let config = Config { bootstrap_servers }; + let config = Config { + bootstrap_servers, + ..Default::default() + }; + + let port = 2323; task::block_on(async move { log::info!("Starting up"); let topic = hypercore_protocol::discovery_key(key.as_bytes()); - let announcer = Announcer::new(&config) + let announcer = Announcer::listen(&config, duration, port) .await .expect("could not start announcer"); - let mut locator = Locator::new(&config) + let mut locator = Locator::listen(&config, duration) .await .expect("Could not start locator"); diff --git a/colmeia-hyperdrive/src/network.rs b/colmeia-hyperdrive/src/network.rs index 1ef7723..d33e0b7 100644 --- a/colmeia-hyperdrive/src/network.rs +++ b/colmeia-hyperdrive/src/network.rs @@ -68,7 +68,7 @@ pub async fn replicate_hyperdrive( } } HyperdriveEvents::Client(Ok(proto::Event::Channel(channel))) => { - // TODO don't rely on channel event oerder - check the keys to see if they match + // TODO don't rely on channel event order - check the keys to see if they match if let Some(JobHolder::Sender(sender)) = metadata_job.take() { log::debug!("initializing metadata feed"); let feed = hyperdrive.read().await.metadata.clone(); @@ -101,7 +101,7 @@ pub async fn replicate_hyperdrive( HyperdriveEvents::Client(Err(_)) => { break; } - // TODO listen to metadata ondata evnt to initialize content feed + // TODO listen to metadata ondata event to initialize content feed HyperdriveEvents::Metadata(_) => { if let Some(JobHolder::Sender(_)) = &content_job { // Initialize the content feed if we have no job started diff --git a/colmeia-hyperswarm-dht/src/announcer.rs b/colmeia-hyperswarm-dht/src/announcer.rs index 7de8e22..d14e5a3 100644 --- a/colmeia-hyperswarm-dht/src/announcer.rs +++ b/colmeia-hyperswarm-dht/src/announcer.rs @@ -1,4 +1,4 @@ -use async_std::{future, sync::RwLock, task}; +use async_std::{sync::RwLock, task}; use futures::{channel::mpsc, FutureExt, SinkExt, Stream, StreamExt}; use hyperswarm_dht::{HyperDht, QueryOpts}; use std::{ @@ -17,20 +17,24 @@ use crate::dht::{dht, Config}; pub struct Announcer { swarm: Arc>, topics: Arc>>>, - _listener_task: task::JoinHandle<()>, + port: u16, receiver: mpsc::UnboundedReceiver<(Vec, SocketAddr)>, + _job: task::JoinHandle<()>, } -// TODO impl Drop unnanaounce +// TODO impl Drop unnanaounce (async drop) impl Announcer { - pub async fn new(config: &Config) -> io::Result { + /// # Errors + /// + /// Will return `Err` if it failed to bind to the socket on config + pub async fn listen(config: &Config, duration: Duration, port: u16) -> io::Result { let swarm = dht(config).await?; let swarm = Arc::new(RwLock::new(swarm)); - let topics: Arc>>> = Default::default(); + let topics: Arc>>> = Arc::default(); let (mut sender, receiver) = mpsc::unbounded(); - let _listener_task = { + let job = { let swarm = swarm.clone(); let topics = topics.clone(); task::spawn(async move { @@ -70,13 +74,11 @@ impl Announcer { } } - // TODO config - if timer.elapsed() > Duration::from_secs(10) { + if timer.elapsed() > duration { log::debug!("Broadcasting new announcement of current topics"); for topic in topics.read().await.iter() { if let Ok(query) = QueryOpts::try_from(&topic[..]) { - // TODO config - let query = query.port(1000); + let query = query.port(u32::from(port)); swarm.write().await.announce(query); } } @@ -89,22 +91,29 @@ impl Announcer { Ok(Self { topics, swarm, - _listener_task, + port, receiver, + _job: job, }) } + /// # Errors + /// + /// Will return `Err` it failed to register the topics due to concurrent writes pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; - let query = query.port(1000); // TODO: port + let query = query.port(u32::from(self.port)); self.swarm.write().await.announce(query); // TODO: spawn await on io pool self.topics.write().await.insert(topic.to_vec()); Ok(()) } + /// # Errors + /// + /// Will return `Err` it failed to remove the topics due to concurrent writes pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; - let query = query.port(1000); // TODO: port + let query = query.port(u32::from(self.port)); self.swarm.write().await.unannounce(query); // TODO: spawn await on io pool self.topics.write().await.remove(topic); Ok(()) diff --git a/colmeia-hyperswarm-dht/src/dht.rs b/colmeia-hyperswarm-dht/src/dht.rs index 7ea4c54..f9e89be 100644 --- a/colmeia-hyperswarm-dht/src/dht.rs +++ b/colmeia-hyperswarm-dht/src/dht.rs @@ -1,11 +1,14 @@ -use std::{io, net::SocketAddr}; +use std::{ + io, + net::{Ipv4Addr, SocketAddr, SocketAddrV4}, +}; use async_std::net::UdpSocket; -use futures::StreamExt; use hyperswarm_dht::{DhtConfig, HyperDht}; pub struct Config { pub bootstrap_servers: Vec, + pub bind_address: SocketAddr, } impl Default for Config { @@ -15,14 +18,13 @@ impl Default for Config { .iter() .map(|&z| z.to_owned()) .collect(), + bind_address: SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0).into(), } } } pub(crate) async fn dht(config: &Config) -> io::Result { - // TODO config - let bind_address: SocketAddr = ([0, 0, 0, 0], 0).into(); - let socket = UdpSocket::bind(bind_address).await?; + let socket = UdpSocket::bind(config.bind_address).await?; let dht_config = DhtConfig::default() .set_socket(socket) .set_bootstrap_nodes(&config.bootstrap_servers) diff --git a/colmeia-hyperswarm-dht/src/lib.rs b/colmeia-hyperswarm-dht/src/lib.rs index 8f0a9a1..3ab6c58 100644 --- a/colmeia-hyperswarm-dht/src/lib.rs +++ b/colmeia-hyperswarm-dht/src/lib.rs @@ -20,7 +20,9 @@ pub struct DHTDiscovery { config: Config, } +// TODO Optmize to share swarm client across both announcer & locator impl DHTDiscovery { + #[must_use] pub fn new(config: Config) -> Self { Self { config, @@ -30,17 +32,20 @@ impl DHTDiscovery { } pub async fn with_announcer(&mut self, port: u16, duration: Duration) -> &mut Self { - let announcer = Announcer::new(&self.config).await; + let announcer = Announcer::listen(&self.config, duration, port).await; self.announce = announcer.ok(); self } pub async fn with_locator(&mut self, duration: Duration) -> &mut Self { - let locator = Locator::new(&self.config).await; + let locator = Locator::listen(&self.config, duration).await; self.locate = locator.ok(); self } + /// # Errors + /// + /// Will return `Err` it failed to register the topics due to concurrent writes pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { if let Some(announcer) = &self.announce { announcer.add_topic(topic).await?; @@ -51,6 +56,9 @@ impl DHTDiscovery { Ok(()) } + /// # Errors + /// + /// Will return `Err` it failed to remove the topics due to concurrent writes pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { if let Some(announcer) = &self.announce { announcer.remove_topic(topic).await?; @@ -67,7 +75,7 @@ impl Stream for DHTDiscovery { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { if let Some(ref mut announcer) = &mut self.announce { - let _ = announcer.poll_next_unpin(cx); + let _announcer = announcer.poll_next_unpin(cx); }; if let Some(ref mut locate) = &mut self.locate { diff --git a/colmeia-hyperswarm-dht/src/locator.rs b/colmeia-hyperswarm-dht/src/locator.rs index 3baec04..ecf6a8b 100644 --- a/colmeia-hyperswarm-dht/src/locator.rs +++ b/colmeia-hyperswarm-dht/src/locator.rs @@ -16,20 +16,23 @@ use crate::dht::{dht, Config}; pub struct Locator { topics: Arc>>>, - _job: task::JoinHandle<()>, swarm: Arc>, receiver: mpsc::UnboundedReceiver<(Vec, SocketAddr)>, + _job: task::JoinHandle<()>, } impl Locator { - pub async fn new(config: &Config) -> io::Result { + /// # Errors + /// + /// Will return `Err` if it failed to bind to the socket on config + pub async fn listen(config: &Config, duration: Duration) -> io::Result { let swarm = dht(config).await?; let swarm = Arc::new(RwLock::new(swarm)); - let topics: Arc>>> = Default::default(); + let topics: Arc>>> = Arc::default(); let (mut sender, receiver) = mpsc::unbounded(); - let _job = { + let job = { let swarm = swarm.clone(); let topics = topics.clone(); task::spawn(async move { @@ -55,8 +58,7 @@ impl Locator { } } - // TODO config - if timer.elapsed() > Duration::from_secs(10) { + if timer.elapsed() > duration { log::debug!("Broadcasting new lookup of current topics"); for topic in topics.read().await.iter() { if let Ok(query) = QueryOpts::try_from(&topic[..]) { @@ -72,11 +74,14 @@ impl Locator { Ok(Self { topics, swarm, - _job, receiver, + _job: job, }) } + /// # Errors + /// + /// Will return `Err` it failed to register the topics due to concurrent writes pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; self.swarm.write().await.lookup(query); @@ -84,6 +89,9 @@ impl Locator { Ok(()) } + /// # Errors + /// + /// Will return `Err` it failed to remove the topics due to concurrent writes pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { self.topics.write().await.remove(topic); Ok(()) diff --git a/colmeia-hyperswarm-mdns/src/lib.rs b/colmeia-hyperswarm-mdns/src/lib.rs index 533bda8..ce38629 100644 --- a/colmeia-hyperswarm-mdns/src/lib.rs +++ b/colmeia-hyperswarm-mdns/src/lib.rs @@ -61,6 +61,7 @@ pub struct MdnsDiscovery { locate: Arc>>, } +// TODO Optmize to share socket across both announcer & locator impl MdnsDiscovery { pub fn new() -> Self { Self { From d791cb85e5684cdc3023565925fca1e98b342c4c Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 16 May 2021 22:06:41 -0300 Subject: [PATCH 10/16] Fix other clippy warnings --- colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs | 3 ++- colmeia-bins/src/bin/colmeia-url-meta.rs | 2 +- colmeia-hypercore/src/network.rs | 11 ++++++++--- colmeia-hyperdrive/src/schema.rs | 2 +- colmeia-hyperstack/src/hyperstack.rs | 3 +-- colmeia-hyperswarm-mdns/src/locator.rs | 6 +++--- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs index 16296c0..b71e90e 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -28,6 +28,7 @@ fn main() { .unwrap_or_else(|| "10".into()) .parse::() .expect("Could not parse duration into a number"); + let duration = Duration::from_secs(duration); env_logger::init(); @@ -48,7 +49,7 @@ fn main() { .await .expect("could not start announcer"); - let mut locator = Locator::listen(&config, duration) + let mut locator = Locator::listen(&config, Duration::from_secs(1)) .await .expect("Could not start locator"); diff --git a/colmeia-bins/src/bin/colmeia-url-meta.rs b/colmeia-bins/src/bin/colmeia-url-meta.rs index a00715c..0f73144 100644 --- a/colmeia-bins/src/bin/colmeia-url-meta.rs +++ b/colmeia-bins/src/bin/colmeia-url-meta.rs @@ -20,7 +20,7 @@ fn main() { } } -fn invalid_public_key(e: HashParserError) -> () { +fn invalid_public_key(e: HashParserError) { match e { HashParserError::InvalidHexHash(_) => { eprintln!("Invalid hyper url"); diff --git a/colmeia-hypercore/src/network.rs b/colmeia-hypercore/src/network.rs index d8c14ef..001fda8 100644 --- a/colmeia-hypercore/src/network.rs +++ b/colmeia-hypercore/src/network.rs @@ -53,7 +53,7 @@ where nodes: message .nodes .iter() - .map(|node| hypercore::Node::new(node.index, node.hash.to_vec(), node.size)) + .map(|node| hypercore::Node::new(node.index, node.hash.clone(), node.size)) .collect(), signature: message .signature @@ -88,6 +88,7 @@ where // self.remoteLength = self.remoteBitfield.last() + 1; } } else { + #[allow(clippy::cast_possible_truncation)] let mut start = message.start as usize; let len = message.length.unwrap_or(1); for _ in 0..len { @@ -108,7 +109,7 @@ where for index in 0..=message.start { let request = proto::schema::Request { index, - ..Default::default() + ..proto::schema::Request::default() }; self.channel.request(request).await?; } @@ -129,10 +130,11 @@ where // where this is contained in let have = proto::schema::Have { start: feed_length as u64, - ..Default::default() + ..proto::schema::Have::default() }; self.channel.have(have).await?; } + #[allow(clippy::cast_possible_truncation)] let rle = self .feed .read() @@ -149,6 +151,9 @@ where Ok(()) } + /// # Errors + /// + /// Returns the error if any of the protocol operations fail pub async fn replicate( &mut self, mut rx: impl futures::Sink + Unpin + Send + 'static, diff --git a/colmeia-hyperdrive/src/schema.rs b/colmeia-hyperdrive/src/schema.rs index c02c661..766b108 100644 --- a/colmeia-hyperdrive/src/schema.rs +++ b/colmeia-hyperdrive/src/schema.rs @@ -6,7 +6,7 @@ #![allow(clippy::all)] #![allow(unused_attributes)] -#![rustfmt::skip] +#![cfg_attr(rustfmt, rustfmt_skip)] #![allow(box_pointers)] #![allow(dead_code)] diff --git a/colmeia-hyperstack/src/hyperstack.rs b/colmeia-hyperstack/src/hyperstack.rs index 6eee675..1392e21 100644 --- a/colmeia-hyperstack/src/hyperstack.rs +++ b/colmeia-hyperstack/src/hyperstack.rs @@ -6,7 +6,6 @@ use async_std::{ task, }; use colmeia_hyperdrive::Hyperdrive; -use colmeia_hyperswarm_dht::Config; use ed25519_dalek::PublicKey; use futures::{Future, Stream, StreamExt}; use hypercore_protocol::ProtocolBuilder; @@ -72,7 +71,7 @@ where let mut mdns = colmeia_hyperswarm_mdns::MdnsDiscovery::new(); mdns.with_announcer(self.listen_address.port()) .with_locator(Duration::from_secs(60)); // TODO: config - mdns.add_topic(&hypercore_protocol::discovery_key(self.key.as_bytes())) + mdns.add_topic(hypercore_protocol::discovery_key(self.key.as_bytes())) .await?; Ok(mdns) } diff --git a/colmeia-hyperswarm-mdns/src/locator.rs b/colmeia-hyperswarm-mdns/src/locator.rs index 4568a05..a839526 100644 --- a/colmeia-hyperswarm-mdns/src/locator.rs +++ b/colmeia-hyperswarm-mdns/src/locator.rs @@ -160,10 +160,10 @@ fn select_ip_from_hyperswarm_mdns_response( let port = srv_data.port(); if srv_data.target() == &*crate::UNSPECIFIED_NAME { return Some(SocketAddr::new(IpAddr::V4(*origin_ip), port)); - } else { - let target_ipv4 = srv_data.target().to_utf8().parse::().ok()?; - return Some(SocketAddr::new(IpAddr::V4(target_ipv4), port)); } + + let target_ipv4 = srv_data.target().to_utf8().parse::().ok()?; + return Some(SocketAddr::new(IpAddr::V4(target_ipv4), port)); } None } From 05a254b2bef9882522afa7e3f256ec1418af9baf Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 16 May 2021 22:24:44 -0300 Subject: [PATCH 11/16] Change default timer on helper bin to avoid spamming dht --- colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs index b71e90e..9a60489 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -25,7 +25,7 @@ fn main() { let duration = env::args() .nth(3) - .unwrap_or_else(|| "10".into()) + .unwrap_or_else(|| "30".into()) .parse::() .expect("Could not parse duration into a number"); let duration = Duration::from_secs(duration); @@ -49,7 +49,7 @@ fn main() { .await .expect("could not start announcer"); - let mut locator = Locator::listen(&config, Duration::from_secs(1)) + let mut locator = Locator::listen(&config, Duration::from_secs(10)) .await .expect("Could not start locator"); @@ -66,7 +66,7 @@ fn main() { .expect("Could not exec find topic"); let result = locator.next().await; - log::debug!("Found peer: {:?}", result); + log::info!("Found peer: {:?}", result); log::info!("Remove topic"); announcer From eab2440f23bbecb2cbe6d1317f2e5d7dda0d54da Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 16 May 2021 22:36:07 -0300 Subject: [PATCH 12/16] Add logs to troubleshoot dht --- colmeia-hyperstack/src/hyperstack.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/colmeia-hyperstack/src/hyperstack.rs b/colmeia-hyperstack/src/hyperstack.rs index 1392e21..a13fea0 100644 --- a/colmeia-hyperstack/src/hyperstack.rs +++ b/colmeia-hyperstack/src/hyperstack.rs @@ -114,12 +114,15 @@ where let discovery = match discovery { Some(mut discovery) => task::spawn(async move { while let Some((_, peer)) = discovery.next().await { + log::debug!("Attempting to connect to {:?}", peer); + if !discovery_connected_peers.read().await.contains(&peer) { let driver = discovery_driver.clone(); let connected_peers = discovery_connected_peers.clone(); task::spawn(async move { if let Ok(tcp_stream) = TcpStream::connect(peer).await { + log::debug!("Connected to {:?} successfully", peer); connected_peers.write().await.insert(peer); let client = ProtocolBuilder::new(true).connect(tcp_stream); colmeia_hyperdrive::replicate_hyperdrive( @@ -144,6 +147,8 @@ where if let Ok(listener) = listener { loop { if let Ok((tcp_stream, remote_addrs)) = listener.accept().await { + log::debug!("Received connection from {:?}", remote_addrs); + let driver = listen_driver.clone(); let connected_peers = listen_connected_peers.clone(); if !connected_peers.read().await.contains(&remote_addrs) { From f70f3b9bd1a12a9b85f5950c9f87f5563624dd91 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 16 May 2021 22:38:15 -0300 Subject: [PATCH 13/16] Doc update --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d90a59f..4f9d259 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Uses NOISE protocol and a different handshake. Start the web service using `colmeiad`: ```sh -cargo run -p colmeiad -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 +RUST_LOG=debug cargo run -p colmeiad -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 ``` You be able to get the information about the blocks on `/` @@ -138,13 +138,13 @@ RUST_LOG=debug cargo run --bin colmeia-clone -- 192.168.15.173:3282 dat://6268b9 #### MDNS ```sh -cargo run --bin colmeia-hyperswarm-mdns -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 8000 +RUST_LOG=debug cargo run --bin colmeia-hyperswarm-mdns -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 8000 ``` #### DHT ```sh -cargo run --bin colmeia-hyperswarm-dht -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 +RUST_LOG=debug cargo run --bin colmeia-hyperswarm-dht -- b45eca0cdf33195821b94dc3836460065864ebd621c9a05aa8c54698c8b388b6 ``` ## Platforms From 3b73e37032c170a84df9e090099b358903d40c27 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 23 May 2021 01:20:41 -0300 Subject: [PATCH 14/16] Use a single swarm to both announcer and locator --- Cargo.lock | 22 +++- .../src/bin/colmeia-hyperswarm-dht.rs | 19 ++- colmeia-hyperstack/src/hyperstack.rs | 7 +- colmeia-hyperswarm-dht/Cargo.toml | 1 + colmeia-hyperswarm-dht/src/announcer.rs | 57 ++++----- colmeia-hyperswarm-dht/src/dht.rs | 110 +++++++++++++++++- colmeia-hyperswarm-dht/src/lib.rs | 33 +++--- colmeia-hyperswarm-dht/src/locator.rs | 36 +++--- 8 files changed, 194 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0f623a..b67b166 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -169,6 +169,17 @@ dependencies = [ "syn", ] +[[package]] +name = "async-broadcast" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8501c1102158e8cf7a73cab03102be0d2651b0f574a33a749ebc3aec72fcde9d" +dependencies = [ + "easy-parallel", + "event-listener", + "futures-core", +] + [[package]] name = "async-channel" version = "1.5.1" @@ -733,6 +744,7 @@ name = "colmeia-hyperswarm-dht" version = "0.1.0" dependencies = [ "anyhow", + "async-broadcast", "async-std", "futures", "hyperswarm-dht", @@ -961,6 +973,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" +[[package]] +name = "easy-parallel" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd4afd79212583ff429b913ad6605242ed7eec277e950b1438f300748f948f4" + [[package]] name = "ed25519" version = "1.0.3" @@ -1142,9 +1160,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.12" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" +checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" [[package]] name = "futures-executor" diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs index 9a60489..2b6cd95 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -1,6 +1,6 @@ use async_std::{prelude::StreamExt, task}; use colmeia_hyperstack::utils::PublicKeyExt; -use colmeia_hyperswarm_dht::{announcer::Announcer, dht::Config, locator::Locator}; +use colmeia_hyperswarm_dht::{dht::Config, DHTDiscovery}; use std::{env, time::Duration}; // 7e5998407b3d9dbb94db21ff50ad6f1b1d2c79e476fbaf9856c342eb4382e7f5 @@ -45,31 +45,28 @@ fn main() { log::info!("Starting up"); let topic = hypercore_protocol::discovery_key(key.as_bytes()); - let announcer = Announcer::listen(&config, duration, port) - .await - .expect("could not start announcer"); - let mut locator = Locator::listen(&config, Duration::from_secs(10)) - .await - .expect("Could not start locator"); + let swarm = DHTDiscovery::listen(config).await; + let mut swarm = swarm.expect("Could not bind socket"); + swarm.with_announcer(port, duration).with_locator(duration); log::info!("Adding topic"); - announcer + swarm .add_topic(&topic) .await .expect("could not write topic"); log::info!("Finding topic"); - locator + swarm .add_topic(&topic) .await .expect("Could not exec find topic"); - let result = locator.next().await; + let result = swarm.next().await; log::info!("Found peer: {:?}", result); log::info!("Remove topic"); - announcer + swarm .remove_topic(&topic) .await .expect("could not remove topic"); diff --git a/colmeia-hyperstack/src/hyperstack.rs b/colmeia-hyperstack/src/hyperstack.rs index a13fea0..4cd487d 100644 --- a/colmeia-hyperstack/src/hyperstack.rs +++ b/colmeia-hyperstack/src/hyperstack.rs @@ -6,6 +6,7 @@ use async_std::{ task, }; use colmeia_hyperdrive::Hyperdrive; +use colmeia_hyperswarm_dht::Config; use ed25519_dalek::PublicKey; use futures::{Future, Stream, StreamExt}; use hypercore_protocol::ProtocolBuilder; @@ -77,11 +78,9 @@ where } pub async fn dht(&self) -> anyhow::Result, SocketAddr)>> { - let mut dht = colmeia_hyperswarm_dht::DHTDiscovery::default(); + let mut dht = colmeia_hyperswarm_dht::DHTDiscovery::listen(Config::default()).await?; dht.with_announcer(self.listen_address.port(), Duration::from_secs(60)) - .await - .with_locator(Duration::from_secs(60)) // TODO: config - .await; + .with_locator(Duration::from_secs(60)); // TODO: config dht.add_topic(&hypercore_protocol::discovery_key(self.key.as_bytes())) .await?; Ok(dht) diff --git a/colmeia-hyperswarm-dht/Cargo.toml b/colmeia-hyperswarm-dht/Cargo.toml index 0160753..b8ab238 100644 --- a/colmeia-hyperswarm-dht/Cargo.toml +++ b/colmeia-hyperswarm-dht/Cargo.toml @@ -8,6 +8,7 @@ edition = '2018' anyhow = '1.0.38' futures = '0.3.12' log = '0.4.14' +async-broadcast = '0.3.1' [dependencies.hyperswarm-dht] git = 'https://github.com/bltavares/hyperswarm-dht' diff --git a/colmeia-hyperswarm-dht/src/announcer.rs b/colmeia-hyperswarm-dht/src/announcer.rs index d14e5a3..847bc9f 100644 --- a/colmeia-hyperswarm-dht/src/announcer.rs +++ b/colmeia-hyperswarm-dht/src/announcer.rs @@ -1,10 +1,9 @@ use async_std::{sync::RwLock, task}; -use futures::{channel::mpsc, FutureExt, SinkExt, Stream, StreamExt}; -use hyperswarm_dht::{HyperDht, QueryOpts}; +use futures::{channel::mpsc, SinkExt, Stream, StreamExt}; +use hyperswarm_dht::QueryOpts; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, - io, net::SocketAddr, pin::Pin, sync::Arc, @@ -12,42 +11,33 @@ use std::{ time::{Duration, Instant}, }; -use crate::dht::{dht, Config}; +use crate::dht::{BroadcastChannel, Outbound}; pub struct Announcer { - swarm: Arc>, + channel: BroadcastChannel, topics: Arc>>>, port: u16, receiver: mpsc::UnboundedReceiver<(Vec, SocketAddr)>, - _job: task::JoinHandle<()>, } // TODO impl Drop unnanaounce (async drop) impl Announcer { - /// # Errors - /// - /// Will return `Err` if it failed to bind to the socket on config - pub async fn listen(config: &Config, duration: Duration, port: u16) -> io::Result { - let swarm = dht(config).await?; - let swarm = Arc::new(RwLock::new(swarm)); + pub fn listen_to_channel(channel: BroadcastChannel, duration: Duration, port: u16) -> Self { let topics: Arc>>> = Arc::default(); let (mut sender, receiver) = mpsc::unbounded(); - let job = { - let swarm = swarm.clone(); + let _job = { let topics = topics.clone(); + let mut messages = channel.receive.activate_cloned(); + let send = channel.send.clone(); task::spawn(async move { let mut timer = std::time::Instant::now(); loop { - if let Some(Some(event)) = swarm.write().await.next().now_or_never() { + if let Ok(event) = messages.recv().await { match event { - hyperswarm_dht::HyperDhtEvent::AnnounceResult { - peers, - topic, - query_id, - } => { + crate::dht::Inbound::Announce { peers, topic } => { let topic = topic.to_vec(); for peer in peers .iter() @@ -59,14 +49,10 @@ impl Announcer { log::warn!("Could not send peer: {:?}", e); } } - log::debug!("announced {:?}", (peers, topic, query_id)); + log::debug!("announced {:?}", (peers, topic)); } - hyperswarm_dht::HyperDhtEvent::UnAnnounceResult { - peers, - topic, - query_id, - } => { - log::debug!("un-announced {:?}", (peers, topic, query_id)); + crate::dht::Inbound::UnAnnounce { peers, topic } => { + log::debug!("un-announced {:?}", (peers, topic)); } e => { log::debug!("another event {:?}", e); @@ -79,7 +65,8 @@ impl Announcer { for topic in topics.read().await.iter() { if let Ok(query) = QueryOpts::try_from(&topic[..]) { let query = query.port(u32::from(port)); - swarm.write().await.announce(query); + let result = send.broadcast(Outbound::Announce(query)).await; + log::debug!("broadcast {:?}", result); } } timer = Instant::now(); @@ -88,13 +75,12 @@ impl Announcer { }) }; - Ok(Self { + Self { topics, - swarm, + channel, port, receiver, - _job: job, - }) + } } /// # Errors @@ -103,7 +89,7 @@ impl Announcer { pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; let query = query.port(u32::from(self.port)); - self.swarm.write().await.announce(query); // TODO: spawn await on io pool + self.channel.send.broadcast(Outbound::Announce(query)).await?; self.topics.write().await.insert(topic.to_vec()); Ok(()) } @@ -114,7 +100,10 @@ impl Announcer { pub async fn remove_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; let query = query.port(u32::from(self.port)); - self.swarm.write().await.unannounce(query); // TODO: spawn await on io pool + self.channel + .send + .broadcast(Outbound::UnAnnounce(query)) + .await?; self.topics.write().await.remove(topic); Ok(()) } diff --git a/colmeia-hyperswarm-dht/src/dht.rs b/colmeia-hyperswarm-dht/src/dht.rs index f9e89be..6c2ed9b 100644 --- a/colmeia-hyperswarm-dht/src/dht.rs +++ b/colmeia-hyperswarm-dht/src/dht.rs @@ -1,10 +1,13 @@ use std::{ io, net::{Ipv4Addr, SocketAddr, SocketAddrV4}, + sync::Arc, }; -use async_std::net::UdpSocket; -use hyperswarm_dht::{DhtConfig, HyperDht}; +use async_broadcast::{broadcast, InactiveReceiver, Sender}; +use async_std::{net::UdpSocket, sync::RwLock, task}; +use futures::{FutureExt, StreamExt}; +use hyperswarm_dht::{DhtConfig, HyperDht, HyperDhtEvent, QueryOpts}; pub struct Config { pub bootstrap_servers: Vec, @@ -31,5 +34,108 @@ pub(crate) async fn dht(config: &Config) -> io::Result { .adaptive() // Becomes non-ephemeral after 30m .ephemeral(); // ephemeral defaults to true in discovery but defaults to false in dht let swarm = HyperDht::with_config(dht_config).await?; + // let bootstrap_result = swarm.next().await; + // log::debug!("Bootstrap result {:?}", bootstrap_result); Ok(swarm) } + +const BUFFER_SIZE: usize = 999; +#[derive(Debug, Clone)] +pub enum Outbound { + Lookup(QueryOpts), + Announce(QueryOpts), + UnAnnounce(QueryOpts), +} + +#[derive(Debug, Clone)] +pub enum Inbound { + Lookup(hyperswarm_dht::Lookup), + Announce { + peers: Vec, + topic: hyperswarm_dht::IdBytes, + }, + UnAnnounce { + peers: Vec, + topic: hyperswarm_dht::IdBytes, + }, +} + +#[derive(Debug, Clone)] +pub struct BroadcastChannel { + pub send: Sender, + pub receive: InactiveReceiver, +} + +impl BroadcastChannel { + pub async fn listen(config: &Config) -> io::Result { + let dht = dht(config).await?; + let swarm = Arc::new(RwLock::new(dht)); + + let (outbound_sender, mut outbound_receiver) = broadcast::(BUFFER_SIZE); + let _outbound = { + let swarm = swarm.clone(); + task::spawn(async move { + loop { + if let Ok(outbound) = outbound_receiver.recv().await { + log::error!("looping"); + + match outbound { + Outbound::Lookup(query) => { + swarm.write().await.lookup(query); + } + Outbound::Announce(query) => { + swarm.write().await.announce(query); + } + Outbound::UnAnnounce(query) => { + swarm.write().await.unannounce(query); + } + } + } + } + }) + }; + + let (receiver_sender, receiver_receiver) = broadcast::(BUFFER_SIZE); + let _inbound = { + task::spawn(async move { + loop { + let event = swarm.write().await.next().now_or_never(); + if let Some(Some(event)) = event { + log::warn!("looping"); + + match event { + HyperDhtEvent::Bootstrapped { stats } => { + log::debug!("Swarm bootstrapped {:?}", stats) + } + HyperDhtEvent::AnnounceResult { peers, topic, .. } => { + let result = receiver_sender + .broadcast(Inbound::Announce { peers, topic }) + .await; + log::trace!("AnnounceResult: {:?}", result); + } + HyperDhtEvent::LookupResult { lookup, .. } => { + let result = + receiver_sender.broadcast(Inbound::Lookup(lookup)).await; + log::trace!("LookupResult: {:?}", result); + } + HyperDhtEvent::UnAnnounceResult { peers, topic, .. } => { + let result = receiver_sender + .broadcast(Inbound::UnAnnounce { peers, topic }) + .await; + log::trace!("UnAnnounceResult: {:?}", result); + } + e => { + log::debug!("unexpected event received: {:?}", e); + } + } + } + } + }) + }; + + Ok(Self { + send: outbound_sender, + receive: receiver_receiver.deactivate(), + }) + } +} diff --git a/colmeia-hyperswarm-dht/src/lib.rs b/colmeia-hyperswarm-dht/src/lib.rs index 3ab6c58..f0d7ff5 100644 --- a/colmeia-hyperswarm-dht/src/lib.rs +++ b/colmeia-hyperswarm-dht/src/lib.rs @@ -1,5 +1,7 @@ +use dht::BroadcastChannel; use futures::{Stream, StreamExt}; use std::{ + io, net::SocketAddr, pin::Pin, task::{Context, Poll}, @@ -17,29 +19,30 @@ pub mod locator; pub struct DHTDiscovery { announce: Option, locate: Option, - config: Config, + channel: BroadcastChannel, } -// TODO Optmize to share swarm client across both announcer & locator impl DHTDiscovery { #[must_use] - pub fn new(config: Config) -> Self { - Self { - config, + pub async fn listen(config: Config) -> io::Result { + let channel = BroadcastChannel::listen(&config).await?; + + Ok(Self { announce: None, locate: None, - } + channel, + }) } - pub async fn with_announcer(&mut self, port: u16, duration: Duration) -> &mut Self { - let announcer = Announcer::listen(&self.config, duration, port).await; - self.announce = announcer.ok(); + pub fn with_announcer(&mut self, port: u16, duration: Duration) -> &mut Self { + let announcer = Announcer::listen_to_channel(self.channel.clone(), duration, port); + self.announce = Some(announcer); self } - pub async fn with_locator(&mut self, duration: Duration) -> &mut Self { - let locator = Locator::listen(&self.config, duration).await; - self.locate = locator.ok(); + pub fn with_locator(&mut self, duration: Duration) -> &mut Self { + let locator = Locator::listen_to_channel(self.channel.clone(), duration); + self.locate = Some(locator); self } @@ -85,9 +88,3 @@ impl Stream for DHTDiscovery { Poll::Pending } } - -impl Default for DHTDiscovery { - fn default() -> Self { - Self::new(Config::default()) - } -} diff --git a/colmeia-hyperswarm-dht/src/locator.rs b/colmeia-hyperswarm-dht/src/locator.rs index ecf6a8b..8fae979 100644 --- a/colmeia-hyperswarm-dht/src/locator.rs +++ b/colmeia-hyperswarm-dht/src/locator.rs @@ -1,10 +1,9 @@ use async_std::{sync::RwLock, task}; -use futures::{channel::mpsc, FutureExt, SinkExt, Stream, StreamExt}; +use futures::{channel::mpsc, SinkExt, Stream, StreamExt}; use hyperswarm_dht::QueryOpts; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, - io, net::SocketAddr, pin::Pin, sync::Arc, @@ -12,36 +11,34 @@ use std::{ time::{Duration, Instant}, }; -use crate::dht::{dht, Config}; +use crate::dht::{BroadcastChannel, Inbound, Outbound}; pub struct Locator { topics: Arc>>>, - swarm: Arc>, + channel: BroadcastChannel, receiver: mpsc::UnboundedReceiver<(Vec, SocketAddr)>, - _job: task::JoinHandle<()>, } impl Locator { /// # Errors /// /// Will return `Err` if it failed to bind to the socket on config - pub async fn listen(config: &Config, duration: Duration) -> io::Result { - let swarm = dht(config).await?; - let swarm = Arc::new(RwLock::new(swarm)); + pub fn listen_to_channel(channel: BroadcastChannel, duration: Duration) -> Self { let topics: Arc>>> = Arc::default(); let (mut sender, receiver) = mpsc::unbounded(); - let job = { - let swarm = swarm.clone(); + let _job = { let topics = topics.clone(); + let mut messages = channel.receive.activate_cloned(); + let send = channel.send.clone(); task::spawn(async move { let mut timer = std::time::Instant::now(); loop { - if let Some(Some(event)) = swarm.write().await.next().now_or_never() { + if let Ok(event) = messages.recv().await { match event { - hyperswarm_dht::HyperDhtEvent::LookupResult { lookup, query_id } => { + Inbound::Lookup(lookup) => { let topic = lookup.topic.to_vec(); for peer in lookup.all_peers().copied() { let result = sender.send((topic.clone(), peer)).await; @@ -49,8 +46,7 @@ impl Locator { log::warn!("Could not send peer: {:?}", e); } } - - log::debug!("lookup {:?}", (lookup, query_id)); + log::debug!("lookup {:?}", lookup); } e => { log::debug!("another event {:?}", e); @@ -62,7 +58,8 @@ impl Locator { log::debug!("Broadcasting new lookup of current topics"); for topic in topics.read().await.iter() { if let Ok(query) = QueryOpts::try_from(&topic[..]) { - swarm.write().await.lookup(query); + let result = send.broadcast(Outbound::Lookup(query)); + log::debug!("broadcast result {:?}", result); } } timer = Instant::now(); @@ -71,12 +68,11 @@ impl Locator { }) }; - Ok(Self { + Self { topics, - swarm, + channel, receiver, - _job: job, - }) + } } /// # Errors @@ -84,7 +80,7 @@ impl Locator { /// Will return `Err` it failed to register the topics due to concurrent writes pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; - self.swarm.write().await.lookup(query); + self.channel.send.broadcast(Outbound::Lookup(query)).await?; self.topics.write().await.insert(topic.to_vec()); Ok(()) } From 9b003928ca69a814202b9bef2fb97df7f4447262 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 23 May 2021 02:25:55 -0300 Subject: [PATCH 15/16] Fix dht bugs introduced on the optmiziation --- Cargo.lock | 3 +-- colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs | 9 +++------ colmeia-hyperswarm-dht/Cargo.toml | 5 ++++- colmeia-hyperswarm-dht/src/announcer.rs | 9 ++++++--- colmeia-hyperswarm-dht/src/dht.rs | 6 +----- colmeia-hyperswarm-dht/src/locator.rs | 6 +++--- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b67b166..d6a5fa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,8 +172,7 @@ dependencies = [ [[package]] name = "async-broadcast" version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8501c1102158e8cf7a73cab03102be0d2651b0f574a33a749ebc3aec72fcde9d" +source = "git+https://github.com/bltavares/async-broadcast?branch=master#7a7d8ca7014726a44f0047653d1b653a72d12b52" dependencies = [ "easy-parallel", "event-listener", diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs index 2b6cd95..1cee784 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -48,7 +48,9 @@ fn main() { let swarm = DHTDiscovery::listen(config).await; let mut swarm = swarm.expect("Could not bind socket"); - swarm.with_announcer(port, duration).with_locator(duration); + swarm + .with_announcer(port, duration) + .with_locator(Duration::from_secs(10)); log::info!("Adding topic"); swarm @@ -57,11 +59,6 @@ fn main() { .expect("could not write topic"); log::info!("Finding topic"); - swarm - .add_topic(&topic) - .await - .expect("Could not exec find topic"); - let result = swarm.next().await; log::info!("Found peer: {:?}", result); diff --git a/colmeia-hyperswarm-dht/Cargo.toml b/colmeia-hyperswarm-dht/Cargo.toml index b8ab238..b18a77d 100644 --- a/colmeia-hyperswarm-dht/Cargo.toml +++ b/colmeia-hyperswarm-dht/Cargo.toml @@ -8,7 +8,6 @@ edition = '2018' anyhow = '1.0.38' futures = '0.3.12' log = '0.4.14' -async-broadcast = '0.3.1' [dependencies.hyperswarm-dht] git = 'https://github.com/bltavares/hyperswarm-dht' @@ -18,3 +17,7 @@ branch = 'wip' version = '1.9.0' features = ['unstable'] +[dependencies.async-broadcast] +git = "https://github.com/bltavares/async-broadcast" +branch = "master" + diff --git a/colmeia-hyperswarm-dht/src/announcer.rs b/colmeia-hyperswarm-dht/src/announcer.rs index 847bc9f..5a0ade3 100644 --- a/colmeia-hyperswarm-dht/src/announcer.rs +++ b/colmeia-hyperswarm-dht/src/announcer.rs @@ -35,7 +35,7 @@ impl Announcer { let mut timer = std::time::Instant::now(); loop { - if let Ok(event) = messages.recv().await { + if let Ok(event) = messages.try_recv() { match event { crate::dht::Inbound::Announce { peers, topic } => { let topic = topic.to_vec(); @@ -66,7 +66,7 @@ impl Announcer { if let Ok(query) = QueryOpts::try_from(&topic[..]) { let query = query.port(u32::from(port)); let result = send.broadcast(Outbound::Announce(query)).await; - log::debug!("broadcast {:?}", result); + log::trace!("broadcast {:?}", result); } } timer = Instant::now(); @@ -89,7 +89,10 @@ impl Announcer { pub async fn add_topic(&self, topic: &[u8]) -> anyhow::Result<()> { let query: QueryOpts = topic.try_into()?; let query = query.port(u32::from(self.port)); - self.channel.send.broadcast(Outbound::Announce(query)).await?; + self.channel + .send + .broadcast(Outbound::Announce(query)) + .await?; self.topics.write().await.insert(topic.to_vec()); Ok(()) } diff --git a/colmeia-hyperswarm-dht/src/dht.rs b/colmeia-hyperswarm-dht/src/dht.rs index 6c2ed9b..264d09c 100644 --- a/colmeia-hyperswarm-dht/src/dht.rs +++ b/colmeia-hyperswarm-dht/src/dht.rs @@ -39,7 +39,7 @@ pub(crate) async fn dht(config: &Config) -> io::Result { Ok(swarm) } -const BUFFER_SIZE: usize = 999; +const BUFFER_SIZE: usize = 1; #[derive(Debug, Clone)] pub enum Outbound { Lookup(QueryOpts), @@ -77,8 +77,6 @@ impl BroadcastChannel { task::spawn(async move { loop { if let Ok(outbound) = outbound_receiver.recv().await { - log::error!("looping"); - match outbound { Outbound::Lookup(query) => { swarm.write().await.lookup(query); @@ -101,8 +99,6 @@ impl BroadcastChannel { loop { let event = swarm.write().await.next().now_or_never(); if let Some(Some(event)) = event { - log::warn!("looping"); - match event { HyperDhtEvent::Bootstrapped { stats } => { log::debug!("Swarm bootstrapped {:?}", stats) diff --git a/colmeia-hyperswarm-dht/src/locator.rs b/colmeia-hyperswarm-dht/src/locator.rs index 8fae979..2c039f0 100644 --- a/colmeia-hyperswarm-dht/src/locator.rs +++ b/colmeia-hyperswarm-dht/src/locator.rs @@ -36,7 +36,7 @@ impl Locator { let mut timer = std::time::Instant::now(); loop { - if let Ok(event) = messages.recv().await { + if let Ok(event) = messages.try_recv() { match event { Inbound::Lookup(lookup) => { let topic = lookup.topic.to_vec(); @@ -58,8 +58,8 @@ impl Locator { log::debug!("Broadcasting new lookup of current topics"); for topic in topics.read().await.iter() { if let Ok(query) = QueryOpts::try_from(&topic[..]) { - let result = send.broadcast(Outbound::Lookup(query)); - log::debug!("broadcast result {:?}", result); + let result = send.broadcast(Outbound::Lookup(query)).await; + log::trace!("broadcast result {:?}", result); } } timer = Instant::now(); From c97474678da433e14ebf0b5c67edc7f6e9e6faf5 Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Sun, 23 May 2021 02:26:07 -0300 Subject: [PATCH 16/16] Adjust the bins to log info by default --- colmeia-bins/src/bin/colmeia-clone.rs | 2 +- colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs | 10 ++++------ colmeia-bins/src/bin/colmeia-hyperswarm-mdns.rs | 2 +- colmeia-bins/src/bin/colmeia-nc.rs | 2 +- colmeia-bins/src/bin/colmeia-sync.rs | 2 +- colmeia-bins/src/bin/dht-bootstrap.rs | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/colmeia-bins/src/bin/colmeia-clone.rs b/colmeia-bins/src/bin/colmeia-clone.rs index 16ccd54..6c6e1db 100644 --- a/colmeia-bins/src/bin/colmeia-clone.rs +++ b/colmeia-bins/src/bin/colmeia-clone.rs @@ -24,7 +24,7 @@ fn address() -> SocketAddr { // } fn main() { - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let key = name(); let address = address(); diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs index 1cee784..29275ea 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -25,12 +25,12 @@ fn main() { let duration = env::args() .nth(3) - .unwrap_or_else(|| "30".into()) + .unwrap_or_else(|| "10".into()) .parse::() .expect("Could not parse duration into a number"); let duration = Duration::from_secs(duration); - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let key = hyper_hash.parse_from_hash().expect("could not parse hash"); @@ -39,8 +39,6 @@ fn main() { ..Default::default() }; - let port = 2323; - task::block_on(async move { log::info!("Starting up"); @@ -49,8 +47,8 @@ fn main() { let swarm = DHTDiscovery::listen(config).await; let mut swarm = swarm.expect("Could not bind socket"); swarm - .with_announcer(port, duration) - .with_locator(Duration::from_secs(10)); + // .with_announcer(2323, duration) + .with_locator(duration); log::info!("Adding topic"); swarm diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-mdns.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-mdns.rs index f847949..c98a177 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-mdns.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-mdns.rs @@ -25,7 +25,7 @@ fn main() { .parse::() .expect("Could not parse duration into a number"); - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let key = hyper_hash.parse_from_hash().expect("could not parse hash"); diff --git a/colmeia-bins/src/bin/colmeia-nc.rs b/colmeia-bins/src/bin/colmeia-nc.rs index 184a12a..68c886e 100644 --- a/colmeia-bins/src/bin/colmeia-nc.rs +++ b/colmeia-bins/src/bin/colmeia-nc.rs @@ -20,7 +20,7 @@ fn main() { // 1. receive ip:port as argument (eg: hashs and 192.168.137.1:58906) // 2. try to connect and hadhsake (with hypercore-protocol) (eg: 7e5998407b3d9dbb94db21ff50ad6f1b1d2c79e476fbaf9856c342eb4382e7f5) // 3. Finalize with all working - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let key = name(); let address = address(); diff --git a/colmeia-bins/src/bin/colmeia-sync.rs b/colmeia-bins/src/bin/colmeia-sync.rs index f69d6b0..c247bf9 100644 --- a/colmeia-bins/src/bin/colmeia-sync.rs +++ b/colmeia-bins/src/bin/colmeia-sync.rs @@ -14,7 +14,7 @@ fn name() -> String { // } fn main() { - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); let key = name(); let hash = key.parse_from_hash().expect("invalid dat argument"); diff --git a/colmeia-bins/src/bin/dht-bootstrap.rs b/colmeia-bins/src/bin/dht-bootstrap.rs index da9bfc8..2e3804f 100644 --- a/colmeia-bins/src/bin/dht-bootstrap.rs +++ b/colmeia-bins/src/bin/dht-bootstrap.rs @@ -2,7 +2,7 @@ use async_std::{prelude::StreamExt, task}; use hyperswarm_dht::{DhtConfig, HyperDht}; fn main() { - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); task::block_on(async move { let config = DhtConfig::default().ephemeral().empty_bootstrap_nodes();