From d3199f75a66acc4732bb0565823c68b061e7f21e Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 20 Mar 2023 18:32:16 -0700 Subject: [PATCH 01/32] init --- rust-server/.gitignore | 1 + rust-server/Cargo.lock | 3819 +++++++++++++++++++++++++++++++++++++++ rust-server/Cargo.toml | 15 + rust-server/src/main.rs | 80 + 4 files changed, 3915 insertions(+) create mode 100644 rust-server/.gitignore create mode 100644 rust-server/Cargo.lock create mode 100644 rust-server/Cargo.toml create mode 100644 rust-server/src/main.rs diff --git a/rust-server/.gitignore b/rust-server/.gitignore new file mode 100644 index 00000000..9f970225 --- /dev/null +++ b/rust-server/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock new file mode 100644 index 00000000..78b2026e --- /dev/null +++ b/rust-server/Cargo.lock @@ -0,0 +1,3819 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aead" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +dependencies = [ + "generic-array", +] + +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array", + "rand_core 0.6.4", +] + +[[package]] +name = "aead" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c192eb8f11fc081b0fe4259ba5af04217d4e0faddd02417310a927911abd7c8" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" +dependencies = [ + "aes-soft", + "aesni", + "cipher 0.2.5", +] + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures", + "opaque-debug", +] + +[[package]] +name = "aes" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +dependencies = [ + "aead 0.4.3", + "aes 0.7.5", + "cipher 0.3.0", + "ctr 0.8.0", + "ghash 0.4.4", + "subtle", +] + +[[package]] +name = "aes-gcm" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c" +dependencies = [ + "aead 0.5.1", + "aes 0.8.2", + "cipher 0.4.4", + "ctr 0.9.2", + "ghash 0.5.0", + "subtle", +] + +[[package]] +name = "aes-soft" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +dependencies = [ + "cipher 0.2.5", + "opaque-debug", +] + +[[package]] +name = "aesni" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" +dependencies = [ + "cipher 0.2.5", + "opaque-debug", +] + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.8", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" + +[[package]] +name = "arc-swap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "asn1-rs" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" +dependencies = [ + "asn1-rs-derive 0.1.0", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" +dependencies = [ + "asn1-rs-derive 0.4.0", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "async-io" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +dependencies = [ + "async-lock", + "autocfg", + "concurrent-queue", + "futures-lite", + "libc", + "log", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "windows-sys 0.42.0", +] + +[[package]] +name = "async-lock" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-trait" +version = "0.1.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.4", +] + +[[package]] +name = "asynchronous-codec" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +dependencies = [ + "bytes", + "futures-sink", + "futures-util", + "memchr", + "pin-project-lite", +] + +[[package]] +name = "atomic-waker" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-modes" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" +dependencies = [ + "block-padding", + "cipher 0.2.5", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "ccm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" +dependencies = [ + "aead 0.3.2", + "cipher 0.2.5", + "subtle", +] + +[[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.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +dependencies = [ + "aead 0.4.3", + "chacha20", + "cipher 0.3.0", + "poly1305", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "concurrent-queue" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher 0.3.0", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "4.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +dependencies = [ + "cfg-if", + "fiat-crypto", + "packed_simd_2", + "platforms", + "subtle", + "zeroize", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "data-encoding-macro" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" +dependencies = [ + "data-encoding", + "data-encoding-macro-internal", +] + +[[package]] +name = "data-encoding-macro-internal" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" +dependencies = [ + "data-encoding", + "syn 1.0.109", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "der-parser" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" +dependencies = [ + "asn1-rs 0.3.1", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der-parser" +version = "8.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" +dependencies = [ + "asn1-rs 0.5.2", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "derive_builder" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "dtoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "hkdf", + "pem-rfc7468", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "enum-as-inner" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ace6ec7cc19c8ed33a32eaa9ea692d7faea05006b5356b9e2b668ec4bc3955" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" + +[[package]] +name = "futures-executor" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-macro" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "futures-rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" +dependencies = [ + "futures-io", + "rustls 0.20.8", + "webpki 0.22.0", +] + +[[package]] +name = "futures-sink" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" + +[[package]] +name = "futures-task" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "ghash" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +dependencies = [ + "opaque-debug", + "polyval 0.5.3", +] + +[[package]] +name = "ghash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +dependencies = [ + "opaque-debug", + "polyval 0.6.0", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex_fmt" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" + +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac 0.12.1", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "if-addrs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "if-watch" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7abdbb86e485125dad06c2691e1e393bf3b08c7b743b43aa162a00fd39062e" +dependencies = [ + "async-io", + "core-foundation", + "fnv", + "futures", + "if-addrs", + "ipnet", + "log", + "rtnetlink", + "system-configuration", + "tokio", + "windows", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "interceptor" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" +dependencies = [ + "async-trait", + "bytes", + "log", + "rand 0.8.5", + "rtcp", + "rtp", + "thiserror", + "tokio", + "waitgroup", + "webrtc-srtp", + "webrtc-util", +] + +[[package]] +name = "ipconfig" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +dependencies = [ + "socket2", + "widestring", + "winapi", + "winreg", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" + +[[package]] +name = "libm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" + +[[package]] +name = "libp2p" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e068bb83ef4e0bed45de5ca4a4118018ac1f70ea3ecb1f4878742d08a97473" +dependencies = [ + "bytes", + "futures", + "futures-timer", + "getrandom 0.2.8", + "instant", + "libp2p-core", + "libp2p-dns", + "libp2p-gossipsub", + "libp2p-identity", + "libp2p-mdns", + "libp2p-metrics", + "libp2p-quic", + "libp2p-swarm", + "libp2p-tcp", + "libp2p-webrtc", + "multiaddr", + "pin-project", +] + +[[package]] +name = "libp2p-core" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7f8b7d65c070a5a1b5f8f0510648189da08f787b8963f8e21219e0710733af" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-identity", + "log", + "multiaddr", + "multihash", + "multistream-select", + "once_cell", + "parking_lot 0.12.1", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink", + "smallvec", + "thiserror", + "unsigned-varint", + "void", +] + +[[package]] +name = "libp2p-dns" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +dependencies = [ + "futures", + "libp2p-core", + "log", + "parking_lot 0.12.1", + "smallvec", + "trust-dns-resolver", +] + +[[package]] +name = "libp2p-gossipsub" +version = "0.44.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "708235886ca7c8f3792a8683ef81f9b7fb0a952bbd15fe5038b7610689a88390" +dependencies = [ + "asynchronous-codec", + "base64 0.21.0", + "byteorder", + "bytes", + "fnv", + "futures", + "hex_fmt", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "prometheus-client", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "regex", + "sha2 0.10.6", + "smallvec", + "thiserror", + "unsigned-varint", + "wasm-timer", +] + +[[package]] +name = "libp2p-identity" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a8ea433ae0cea7e3315354305237b9897afe45278b2118a7a57ca744e70fd27" +dependencies = [ + "bs58", + "ed25519-dalek", + "log", + "multiaddr", + "multihash", + "prost", + "quick-protobuf", + "rand 0.8.5", + "thiserror", + "zeroize", +] + +[[package]] +name = "libp2p-mdns" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "687a0b54ee8f7106be36f012b32bd30faceeb4cd857ebad96e512566886ffea5" +dependencies = [ + "data-encoding", + "futures", + "if-watch", + "libp2p-core", + "libp2p-swarm", + "log", + "rand 0.8.5", + "smallvec", + "socket2", + "tokio", + "trust-dns-proto", + "void", +] + +[[package]] +name = "libp2p-metrics" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" +dependencies = [ + "libp2p-core", + "libp2p-gossipsub", + "libp2p-swarm", + "prometheus-client", +] + +[[package]] +name = "libp2p-noise" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c87c2803deffeae94108072a0387f8c9ff494af68a4908454c11c811e27b5e5" +dependencies = [ + "bytes", + "curve25519-dalek 3.2.0", + "futures", + "libp2p-core", + "libp2p-identity", + "log", + "once_cell", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", + "snow", + "static_assertions", + "thiserror", + "x25519-dalek 1.1.1", + "zeroize", +] + +[[package]] +name = "libp2p-quic" +version = "0.7.0-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" +dependencies = [ + "bytes", + "futures", + "futures-timer", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-tls", + "log", + "parking_lot 0.12.1", + "quinn-proto", + "rand 0.8.5", + "rustls 0.20.8", + "thiserror", + "tokio", +] + +[[package]] +name = "libp2p-swarm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c22a83d70703d140092c969c1ca06ecdffff8ca7ce8ac2fd3b7eb2c1f0da86" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-swarm-derive", + "log", + "pin-project", + "rand 0.8.5", + "smallvec", + "thiserror", + "tokio", + "void", +] + +[[package]] +name = "libp2p-swarm-derive" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +dependencies = [ + "heck", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "libp2p-tcp" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +dependencies = [ + "futures", + "futures-timer", + "if-watch", + "libc", + "libp2p-core", + "log", + "socket2", + "tokio", +] + +[[package]] +name = "libp2p-tls" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" +dependencies = [ + "futures", + "futures-rustls", + "libp2p-core", + "libp2p-identity", + "rcgen 0.10.0", + "ring", + "rustls 0.20.8", + "thiserror", + "webpki 0.22.0", + "x509-parser 0.14.0", + "yasna", +] + +[[package]] +name = "libp2p-webrtc" +version = "0.4.0-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffd0c3af5921e3bdd5fecdf3eef3be5a197def64c1d23cd3ea79abcadbd461f7" +dependencies = [ + "async-trait", + "asynchronous-codec", + "bytes", + "futures", + "futures-timer", + "hex", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-noise", + "log", + "multihash", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "rcgen 0.9.3", + "serde", + "stun", + "thiserror", + "tinytemplate", + "tokio", + "tokio-util", + "webrtc", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "md-5" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.45.0", +] + +[[package]] +name = "multiaddr" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b53e0cc5907a5c216ba6584bf74be8ab47d6d6289f72793b2dddbf15dc3bf8c" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "multibase", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multibase" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +dependencies = [ + "base-x", + "data-encoding", + "data-encoding-macro", +] + +[[package]] +name = "multihash" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +dependencies = [ + "core2", + "digest 0.10.6", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multistream-select" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint", +] + +[[package]] +name = "netlink-packet-core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297" +dependencies = [ + "anyhow", + "byteorder", + "libc", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-route" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" +dependencies = [ + "anyhow", + "bitflags", + "byteorder", + "libc", + "netlink-packet-core", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-utils" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" +dependencies = [ + "anyhow", + "byteorder", + "paste", + "thiserror", +] + +[[package]] +name = "netlink-proto" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" +dependencies = [ + "bytes", + "futures", + "log", + "netlink-packet-core", + "netlink-sys", + "thiserror", + "tokio", +] + +[[package]] +name = "netlink-sys" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" +dependencies = [ + "bytes", + "futures", + "libc", + "log", + "tokio", +] + +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "oid-registry" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" +dependencies = [ + "asn1-rs 0.3.1", +] + +[[package]] +name = "oid-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" +dependencies = [ + "asn1-rs 0.5.2", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "p384" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "packed_simd_2" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" +dependencies = [ + "cfg-if", + "libm", +] + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.7", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + +[[package]] +name = "pem-rfc7468" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "platforms" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" + +[[package]] +name = "polling" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e1f879b2998099c2d69ab9605d145d5b661195627eccc680002c4918a7fb6fa" +dependencies = [ + "autocfg", + "bitflags", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.45.0", +] + +[[package]] +name = "poly1305" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash 0.4.1", +] + +[[package]] +name = "polyval" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash 0.4.1", +] + +[[package]] +name = "polyval" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash 0.5.0", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prometheus-client" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" +dependencies = [ + "dtoa", + "itoa", + "parking_lot 0.12.1", + "prometheus-client-derive-encode", +] + +[[package]] +name = "prometheus-client-derive-encode" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "prost" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quick-protobuf" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + +[[package]] +name = "quick-protobuf-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + +[[package]] +name = "quinn-proto" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9" +dependencies = [ + "bytes", + "rand 0.8.5", + "ring", + "rustc-hash", + "rustls 0.20.8", + "slab", + "thiserror", + "tinyvec", + "tracing", + "webpki 0.22.0", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.8", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rcgen" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" +dependencies = [ + "pem", + "ring", + "time", + "x509-parser 0.13.2", + "yasna", +] + +[[package]] +name = "rcgen" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" +dependencies = [ + "pem", + "ring", + "time", + "yasna", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac 0.12.1", + "zeroize", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rtcp" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" +dependencies = [ + "bytes", + "thiserror", + "webrtc-util", +] + +[[package]] +name = "rtnetlink" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" +dependencies = [ + "futures", + "log", + "netlink-packet-route", + "netlink-proto", + "nix", + "thiserror", + "tokio", +] + +[[package]] +name = "rtp" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" +dependencies = [ + "async-trait", + "bytes", + "rand 0.8.5", + "serde", + "thiserror", + "webrtc-util", +] + +[[package]] +name = "rust-libp2p-webrtc-server" +version = "0.1.0" +dependencies = [ + "anyhow", + "futures", + "libp2p", + "rand 0.8.5", + "tokio", + "tokio-util", + "webrtc", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64 0.13.1", + "log", + "ring", + "sct 0.6.1", + "webpki 0.21.4", +] + +[[package]] +name = "rustls" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +dependencies = [ + "log", + "ring", + "sct 0.7.0", + "webpki 0.22.0", +] + +[[package]] +name = "rw-stream-sink" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sdp" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" +dependencies = [ + "rand 0.8.5", + "substring", + "thiserror", + "url", +] + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" + +[[package]] +name = "serde" +version = "1.0.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.4", +] + +[[package]] +name = "serde_json" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core 0.6.4", +] + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "snow" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" +dependencies = [ + "aes-gcm 0.9.4", + "blake2", + "chacha20poly1305", + "curve25519-dalek 4.0.0-rc.1", + "rand_core 0.6.4", + "ring", + "rustc_version", + "sha2 0.10.6", + "subtle", +] + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "stun" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" +dependencies = [ + "base64 0.13.1", + "crc", + "lazy_static", + "md-5", + "rand 0.8.5", + "ring", + "subtle", + "thiserror", + "tokio", + "url", + "webrtc-util", +] + +[[package]] +name = "substring" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" +dependencies = [ + "autocfg", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c622ae390c9302e214c31013517c2061ecb2699935882c60a9b37f82f8625ae" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + +[[package]] +name = "system-configuration" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75182f12f490e953596550b65ee31bda7c8e043d9386174b353bda50838c3fd" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.4", +] + +[[package]] +name = "time" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +dependencies = [ + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +dependencies = [ + "time-core", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot 0.12.1", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tokio-util" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +dependencies = [ + "bytes", + "futures-core", + "futures-io", + "futures-sink", + "futures-util", + "hashbrown", + "pin-project-lite", + "slab", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "trust-dns-proto" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.2.3", + "ipnet", + "lazy_static", + "rand 0.8.5", + "smallvec", + "socket2", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" +dependencies = [ + "cfg-if", + "futures-util", + "ipconfig", + "lazy_static", + "lru-cache", + "parking_lot 0.12.1", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", + "trust-dns-proto", +] + +[[package]] +name = "turn" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" +dependencies = [ + "async-trait", + "base64 0.13.1", + "futures", + "log", + "md-5", + "rand 0.8.5", + "ring", + "stun", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "universal-hash" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "universal-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +dependencies = [ + "asynchronous-codec", + "bytes", +] + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna 0.3.0", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" +dependencies = [ + "getrandom 0.2.8", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "waitgroup" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" +dependencies = [ + "atomic-waker", +] + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "wasm-timer" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" +dependencies = [ + "futures", + "js-sys", + "parking_lot 0.11.2", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webrtc" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" +dependencies = [ + "arc-swap", + "async-trait", + "bytes", + "hex", + "interceptor", + "lazy_static", + "log", + "pem", + "rand 0.8.5", + "rcgen 0.9.3", + "regex", + "ring", + "rtcp", + "rtp", + "rustls 0.19.1", + "sdp", + "serde", + "serde_json", + "sha2 0.10.6", + "stun", + "thiserror", + "time", + "tokio", + "turn", + "url", + "waitgroup", + "webrtc-data", + "webrtc-dtls", + "webrtc-ice", + "webrtc-mdns", + "webrtc-media", + "webrtc-sctp", + "webrtc-srtp", + "webrtc-util", +] + +[[package]] +name = "webrtc-data" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" +dependencies = [ + "bytes", + "derive_builder", + "log", + "thiserror", + "tokio", + "webrtc-sctp", + "webrtc-util", +] + +[[package]] +name = "webrtc-dtls" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" +dependencies = [ + "aes 0.6.0", + "aes-gcm 0.10.1", + "async-trait", + "bincode", + "block-modes", + "byteorder", + "ccm", + "curve25519-dalek 3.2.0", + "der-parser 8.2.0", + "elliptic-curve", + "hkdf", + "hmac 0.12.1", + "log", + "oid-registry 0.6.1", + "p256", + "p384", + "pem", + "rand 0.8.5", + "rand_core 0.6.4", + "rcgen 0.9.3", + "ring", + "rustls 0.19.1", + "sec1", + "serde", + "sha1", + "sha2 0.10.6", + "signature", + "subtle", + "thiserror", + "tokio", + "webpki 0.21.4", + "webrtc-util", + "x25519-dalek 2.0.0-pre.1", + "x509-parser 0.13.2", +] + +[[package]] +name = "webrtc-ice" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" +dependencies = [ + "arc-swap", + "async-trait", + "crc", + "log", + "rand 0.8.5", + "serde", + "serde_json", + "stun", + "thiserror", + "tokio", + "turn", + "url", + "uuid", + "waitgroup", + "webrtc-mdns", + "webrtc-util", +] + +[[package]] +name = "webrtc-mdns" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" +dependencies = [ + "log", + "socket2", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-media" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a3c157a040324e5049bcbd644ffc9079e6738fa2cfab2bcff64e5cc4c00d7" +dependencies = [ + "byteorder", + "bytes", + "derive_builder", + "displaydoc", + "rand 0.8.5", + "rtp", + "thiserror", + "webrtc-util", +] + +[[package]] +name = "webrtc-sctp" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" +dependencies = [ + "arc-swap", + "async-trait", + "bytes", + "crc", + "log", + "rand 0.8.5", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-srtp" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" +dependencies = [ + "aead 0.4.3", + "aes 0.7.5", + "aes-gcm 0.9.4", + "async-trait", + "byteorder", + "bytes", + "ctr 0.8.0", + "hmac 0.11.0", + "log", + "rtcp", + "rtp", + "sha-1", + "subtle", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-util" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" +dependencies = [ + "async-trait", + "bitflags", + "bytes", + "cc", + "ipnet", + "lazy_static", + "libc", + "log", + "nix", + "rand 0.8.5", + "thiserror", + "tokio", + "winapi", +] + +[[package]] +name = "widestring" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45296b64204227616fdbf2614cefa4c236b98ee64dfaaaa435207ed99fe7829f" +dependencies = [ + "windows_aarch64_msvc 0.34.0", + "windows_i686_gnu 0.34.0", + "windows_i686_msvc 0.34.0", + "windows_x86_64_gnu 0.34.0", + "windows_x86_64_msvc 0.34.0", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek 3.2.0", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "x25519-dalek" +version = "2.0.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +dependencies = [ + "curve25519-dalek 3.2.0", + "rand_core 0.6.4", + "zeroize", +] + +[[package]] +name = "x509-parser" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" +dependencies = [ + "asn1-rs 0.3.1", + "base64 0.13.1", + "data-encoding", + "der-parser 7.0.0", + "lazy_static", + "nom", + "oid-registry 0.4.0", + "ring", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "x509-parser" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" +dependencies = [ + "asn1-rs 0.5.2", + "base64 0.13.1", + "data-encoding", + "der-parser 8.2.0", + "lazy_static", + "nom", + "oid-registry 0.6.1", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "yasna" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4" +dependencies = [ + "time", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml new file mode 100644 index 00000000..f7dfddcd --- /dev/null +++ b/rust-server/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "rust-libp2p-webrtc-server" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0" +futures = "0.3.27" +libp2p = {version="0.51.1", features = ["tokio", "gossipsub", "webrtc", "macros"]} +rand = "0.8.5" +tokio = { version= "1.26.0", features=["full"] } +tokio-util = { version = "0.7", features = ["full"] } +webrtc = { version = "0.6.0", optional = true } diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs new file mode 100644 index 00000000..18a49b7e --- /dev/null +++ b/rust-server/src/main.rs @@ -0,0 +1,80 @@ +use anyhow::Result; +use futures::StreamExt; +use libp2p::{ + core::{muxing::StreamMuxerBox}, + gossipsub, + identity, + PeerId, + swarm::{NetworkBehaviour, Swarm, SwarmBuilder}, + Transport, + webrtc, +}; +use rand::thread_rng; +use std::collections::hash_map::DefaultHasher; +use std::hash::{Hash, Hasher}; +use std::time::Duration; + +/// An example WebRTC server that will accept connections and run the ping protocol on them. +#[tokio::main] +async fn main() -> Result<()> { + let mut swarm = create_swarm()?; + + swarm.listen_on("/ip4/127.0.0.1/udp/0/webrtc".parse()?)?; + + loop { + let event = swarm.next().await.unwrap(); + eprintln!("New event: {event:?}") + } +} + +// We create a custom network behaviour with Gossipsub +#[derive(NetworkBehaviour)] +struct Behaviour { + gossipsub: gossipsub::Behaviour, +} + +fn create_swarm() -> Result> { + let local_key = identity::Keypair::generate_ed25519(); + let local_peer_id = PeerId::from(local_key.public()); + println!("Local peer id: {local_peer_id}"); + + // To content-address message, we can take the hash of message and use it as an ID. + let message_id_fn = |message: &gossipsub::Message| { + let mut s = DefaultHasher::new(); + message.data.hash(&mut s); + gossipsub::MessageId::from(s.finish().to_string()) + }; + + // Set a custom gossipsub configuration + let gossipsub_config = gossipsub::ConfigBuilder::default() + .heartbeat_interval(Duration::from_secs(10)) // This is set to aid debugging by not cluttering the log space + .validation_mode(gossipsub::ValidationMode::Strict) // This sets the kind of message validation. The default is Strict (enforce message signing) + .message_id_fn(message_id_fn) // content-address messages. No two messages of the same content will be propagated. + .build() + .expect("Valid config"); + + // build a gossipsub network behaviour + let mut gossipsub = gossipsub::Behaviour::new( + gossipsub::MessageAuthenticity::Signed(local_key.clone()), + gossipsub_config, + ) + .expect("Correct configuration"); + + // Create a Gossipsub topic + let topic = gossipsub::IdentTopic::new("universal-connectivity"); + + // subscribes to our topic + gossipsub.subscribe(&topic)?; + + let transport = webrtc::tokio::Transport::new( + local_key.clone(), + webrtc::tokio::Certificate::generate(&mut thread_rng())?, + ); + + let transport = transport + .map(|(local_peer_id, conn), _| (local_peer_id, StreamMuxerBox::new(conn))) + .boxed(); + + let behaviour = Behaviour { gossipsub }; + Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) +} From f1ce94a77a9ae987c88443e69923f75912a1ecfe Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 20 Mar 2023 19:04:51 -0700 Subject: [PATCH 02/32] add kad --- rust-server/Cargo.lock | 54 +++++++++++++++++++++++++++++++++++++++++ rust-server/Cargo.toml | 2 +- rust-server/src/main.rs | 31 ++++++++++++++++++++--- 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index 78b2026e..dcefa430 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -151,6 +151,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + [[package]] name = "asn1-rs" version = "0.3.1" @@ -544,6 +550,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-bigint" version = "0.4.9" @@ -1339,6 +1351,7 @@ dependencies = [ "libp2p-dns", "libp2p-gossipsub", "libp2p-identity", + "libp2p-kad", "libp2p-mdns", "libp2p-metrics", "libp2p-quic", @@ -1439,6 +1452,34 @@ dependencies = [ "zeroize", ] +[[package]] +name = "libp2p-kad" +version = "0.43.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bc57e02d7ad49a63792370f24b829af38f34982ff56556e59e4cb325a4dbf6b" +dependencies = [ + "arrayvec", + "asynchronous-codec", + "bytes", + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", + "smallvec", + "thiserror", + "uint", + "unsigned-varint", + "void", +] + [[package]] name = "libp2p-mdns" version = "0.43.0" @@ -1467,6 +1508,7 @@ checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" dependencies = [ "libp2p-core", "libp2p-gossipsub", + "libp2p-kad", "libp2p-swarm", "prometheus-client", ] @@ -3121,6 +3163,18 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.13" diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index f7dfddcd..3b79d468 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0" futures = "0.3.27" -libp2p = {version="0.51.1", features = ["tokio", "gossipsub", "webrtc", "macros"]} +libp2p = {version="0.51.1", features = ["tokio", "gossipsub", "webrtc", "macros", "kad"]} rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 18a49b7e..744f4366 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -4,6 +4,8 @@ use libp2p::{ core::{muxing::StreamMuxerBox}, gossipsub, identity, + kad::record::store::MemoryStore, + kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, PeerId, swarm::{NetworkBehaviour, Swarm, SwarmBuilder}, Transport, @@ -14,7 +16,15 @@ use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::time::Duration; -/// An example WebRTC server that will accept connections and run the ping protocol on them. +// replace with our private bootstrap node +const BOOTNODES: [&str; 1] = [ + "QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", + // "QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", + // "QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", + // "QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", +]; + +/// An example WebRTC server that will accept connections #[tokio::main] async fn main() -> Result<()> { let mut swarm = create_swarm()?; @@ -27,10 +37,11 @@ async fn main() -> Result<()> { } } -// We create a custom network behaviour with Gossipsub +// We create a custom network behaviour with Gossipsub & Kademlia #[derive(NetworkBehaviour)] struct Behaviour { - gossipsub: gossipsub::Behaviour, + gossipsub: gossipsub::Behaviour + // kademlia: Kademlia::Behaviour, } fn create_swarm() -> Result> { @@ -38,6 +49,19 @@ fn create_swarm() -> Result> { let local_peer_id = PeerId::from(local_key.public()); println!("Local peer id: {local_peer_id}"); + // Create a Kademlia behaviour. + let mut cfg = KademliaConfig::default(); + cfg.set_query_timeout(Duration::from_secs(5 * 60)); + let store = MemoryStore::new(local_peer_id); + let mut kad_behaviour = Kademlia::with_config(local_peer_id, store, cfg); + + // Add the bootnodes to the local routing table. `libp2p-dns` built + // into the `transport` resolves the `dnsaddr` when Kademlia tries + // to dial these nodes. + for peer in &BOOTNODES { + kad_behaviour.add_address(&peer.parse()?, "/dnsaddr/bootstrap.libp2p.io".parse()?); + } + // To content-address message, we can take the hash of message and use it as an ID. let message_id_fn = |message: &gossipsub::Message| { let mut s = DefaultHasher::new(); @@ -76,5 +100,6 @@ fn create_swarm() -> Result> { .boxed(); let behaviour = Behaviour { gossipsub }; + // let behaviour = Behaviour { gossipsub, kad_behaviour }; Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) } From f62e4a57967a2f5c914b1bd14011f7e02436e190 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 20 Mar 2023 21:09:45 -0700 Subject: [PATCH 03/32] add kad behaviour --- rust-server/src/main.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 744f4366..2d581b05 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -4,7 +4,7 @@ use libp2p::{ core::{muxing::StreamMuxerBox}, gossipsub, identity, - kad::record::store::MemoryStore, + kad::record::store::{RecordStore, MemoryStore}, kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, PeerId, swarm::{NetworkBehaviour, Swarm, SwarmBuilder}, @@ -16,7 +16,7 @@ use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::time::Duration; -// replace with our private bootstrap node +// TODO: replace with our private bootstrap node const BOOTNODES: [&str; 1] = [ "QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", // "QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", @@ -27,7 +27,7 @@ const BOOTNODES: [&str; 1] = [ /// An example WebRTC server that will accept connections #[tokio::main] async fn main() -> Result<()> { - let mut swarm = create_swarm()?; + let mut swarm = create_swarm::()?; swarm.listen_on("/ip4/127.0.0.1/udp/0/webrtc".parse()?)?; @@ -37,14 +37,13 @@ async fn main() -> Result<()> { } } -// We create a custom network behaviour with Gossipsub & Kademlia #[derive(NetworkBehaviour)] -struct Behaviour { - gossipsub: gossipsub::Behaviour - // kademlia: Kademlia::Behaviour, +struct Behaviour { + gossipsub: gossipsub::Behaviour, + kademlia: Kademlia, } -fn create_swarm() -> Result> { +fn create_swarm() -> Result>> { let local_key = identity::Keypair::generate_ed25519(); let local_peer_id = PeerId::from(local_key.public()); println!("Local peer id: {local_peer_id}"); @@ -59,6 +58,7 @@ fn create_swarm() -> Result> { // into the `transport` resolves the `dnsaddr` when Kademlia tries // to dial these nodes. for peer in &BOOTNODES { + // TODO: update this kad_behaviour.add_address(&peer.parse()?, "/dnsaddr/bootstrap.libp2p.io".parse()?); } @@ -99,7 +99,6 @@ fn create_swarm() -> Result> { .map(|(local_peer_id, conn), _| (local_peer_id, StreamMuxerBox::new(conn))) .boxed(); - let behaviour = Behaviour { gossipsub }; - // let behaviour = Behaviour { gossipsub, kad_behaviour }; + let behaviour = Behaviour { gossipsub, kademlia: kad_behaviour }; Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) } From d806f679260704bfa7c9e5249d90521243d7bd87 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Tue, 21 Mar 2023 14:43:01 +0100 Subject: [PATCH 04/32] feat: add ability to connect to multiaddr --- packages/frontend/src/lib/libp2p.ts | 14 +++++++ packages/frontend/src/pages/index.tsx | 56 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/packages/frontend/src/lib/libp2p.ts b/packages/frontend/src/lib/libp2p.ts index 71b393b0..e7065aab 100644 --- a/packages/frontend/src/lib/libp2p.ts +++ b/packages/frontend/src/lib/libp2p.ts @@ -148,6 +148,20 @@ export const connectToMultiaddrs = return conns } +// Attempt to connect to an array of multiaddrs +export const connectToMultiaddr = + (libp2p: Libp2p) => async (multiaddr: Multiaddr) => { + console.log(`dialling: ${multiaddr.toString()}`) + try { + const conn = await libp2p.dial(multiaddr) + console.info('connected to', conn.remotePeer, 'on', conn.remoteAddr) + return conn + } catch (e) { + console.error(e) + throw e + } + } + /** * Returns a filtered list of public multiaddrs of a specific protocol * diff --git a/packages/frontend/src/pages/index.tsx b/packages/frontend/src/pages/index.tsx index 5bfb31fe..9fdea3d1 100644 --- a/packages/frontend/src/pages/index.tsx +++ b/packages/frontend/src/pages/index.tsx @@ -6,6 +6,7 @@ import { useCallback, useState } from 'react' import { useInterval } from 'usehooks-ts' import { + connectToMultiaddr, connectToMultiaddrs, filterPublicMultiaddrs, getPeerMultiaddrs, @@ -23,6 +24,7 @@ export default function Home() { const { libp2p } = useLibp2pContext() const [isConnected, setIsConnected] = useState(false) const [peerID, setPeerID] = useState(DEFAULT_APP_PEER) + const [maddr, setMultiaddr] = useState('') const [peers, setPeers] = useState([]) const [connections, setConnections] = useState([]) const [latency, setLatency] = useState() @@ -131,6 +133,32 @@ export default function Home() { [libp2p, multiaddrs, peerID], ) + const handleConnectToMultiaddr = useCallback( + async (e: React.MouseEvent) => { + if (!maddr) { + return + } + + try { + const connection = await connectToMultiaddr(libp2p)(multiaddr(maddr)) + console.log('connection: ', connection) + return connection + } catch (e) { + console.error(e) + } + }, + [libp2p, maddr], + ) + + // handleConnectToMultiaddr + + const handleMultiaddrChange = useCallback( + (e: React.ChangeEvent) => { + setMultiaddr(e.target.value) + }, + [setMultiaddr], + ) + const handlePeerIdChange = useCallback( (e: React.ChangeEvent) => { setPeerID(e.target.value) @@ -193,6 +221,7 @@ export default function Home() { Get Multiaddrs +
{multiaddrs && multiaddrs.length > 0 ? ( <> @@ -217,6 +246,33 @@ export default function Home() { ) : null}
+
+ +
+ +
+ +

Connected:{' '} {isConnected ? ( From 093ddee58eaf0e0e6583d5ec9cce9878361c9c6d Mon Sep 17 00:00:00 2001 From: Daniel Norman <1992255+2color@users.noreply.github.com> Date: Tue, 21 Mar 2023 19:44:12 +0100 Subject: [PATCH 05/32] Update rust-server/Cargo.toml Co-authored-by: Max Inden --- rust-server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index 3b79d468..85c5763d 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0" futures = "0.3.27" -libp2p = {version="0.51.1", features = ["tokio", "gossipsub", "webrtc", "macros", "kad"]} +libp2p = {version="0.51.1", features = ["tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } From ada67baaae276c534c97a643e64406d5b4a6e92b Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Tue, 21 Mar 2023 12:30:05 -0700 Subject: [PATCH 06/32] add ping and keep alive --- rust-server/Cargo.lock | 27 +++++++++++++++++++++++++++ rust-server/Cargo.toml | 2 +- rust-server/src/main.rs | 7 +++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index dcefa430..4409ab2f 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -224,6 +224,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "asn1_der" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" + [[package]] name = "async-io" version = "1.12.0" @@ -1354,6 +1360,7 @@ dependencies = [ "libp2p-kad", "libp2p-mdns", "libp2p-metrics", + "libp2p-ping", "libp2p-quic", "libp2p-swarm", "libp2p-tcp", @@ -1440,6 +1447,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a8ea433ae0cea7e3315354305237b9897afe45278b2118a7a57ca744e70fd27" dependencies = [ + "asn1_der", "bs58", "ed25519-dalek", "log", @@ -1448,6 +1456,7 @@ dependencies = [ "prost", "quick-protobuf", "rand 0.8.5", + "ring", "thiserror", "zeroize", ] @@ -1509,6 +1518,7 @@ dependencies = [ "libp2p-core", "libp2p-gossipsub", "libp2p-kad", + "libp2p-ping", "libp2p-swarm", "prometheus-client", ] @@ -1536,6 +1546,23 @@ dependencies = [ "zeroize", ] +[[package]] +name = "libp2p-ping" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" +dependencies = [ + "either", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-swarm", + "log", + "rand 0.8.5", + "void", +] + [[package]] name = "libp2p-quic" version = "0.7.0-alpha.3" diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index 85c5763d..ab6a5f9c 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0" futures = "0.3.27" -libp2p = {version="0.51.1", features = ["tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} +libp2p = {version="0.51.1", features = ["ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 2d581b05..47b263fe 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -7,7 +7,8 @@ use libp2p::{ kad::record::store::{RecordStore, MemoryStore}, kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, PeerId, - swarm::{NetworkBehaviour, Swarm, SwarmBuilder}, + ping, + swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder}, Transport, webrtc, }; @@ -41,6 +42,8 @@ async fn main() -> Result<()> { struct Behaviour { gossipsub: gossipsub::Behaviour, kademlia: Kademlia, + keep_alive: keep_alive::Behaviour, + ping: ping::Behaviour, } fn create_swarm() -> Result>> { @@ -99,6 +102,6 @@ fn create_swarm() -> Result Date: Tue, 21 Mar 2023 12:33:03 -0700 Subject: [PATCH 07/32] ValidationMode permissive --- rust-server/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 47b263fe..f2a27988 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -75,7 +75,7 @@ fn create_swarm() -> Result Date: Tue, 21 Mar 2023 22:09:42 -0500 Subject: [PATCH 08/32] refactored to use dialProtocol + added ping --- package-lock.json | 2 +- packages/frontend/src/lib/libp2p.ts | 7 ++++--- packages/frontend/src/pages/index.tsx | 10 ++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75d31a63..a8541192 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12088,7 +12088,7 @@ "@libp2p/delegated-peer-routing": "^4.0.0", "@libp2p/kad-dht": "^7.0.0", "@libp2p/peer-id": "^2.0.1", - "@libp2p/webrtc": "*", + "@libp2p/webrtc": "^1.0.4", "@libp2p/websockets": "^5.0.3", "@libp2p/webtransport": "^1.0.7", "@types/node": "18.14.6", diff --git a/packages/frontend/src/lib/libp2p.ts b/packages/frontend/src/lib/libp2p.ts index e7065aab..087f94f6 100644 --- a/packages/frontend/src/lib/libp2p.ts +++ b/packages/frontend/src/lib/libp2p.ts @@ -84,6 +84,7 @@ export async function startLibp2p(options: {} = {}) { libp2p.pubsub.subscribe(CHAT_TOPIC) console.log(`this nodes peerID: ${libp2p.peerId.toString()}`) + return libp2p } @@ -153,9 +154,9 @@ export const connectToMultiaddr = (libp2p: Libp2p) => async (multiaddr: Multiaddr) => { console.log(`dialling: ${multiaddr.toString()}`) try { - const conn = await libp2p.dial(multiaddr) - console.info('connected to', conn.remotePeer, 'on', conn.remoteAddr) - return conn + const stream = await libp2p.dialProtocol(multiaddr, ["/meshsub/1.1.0", "/ipfs/ping/1.0.0"]) + console.info('connected to', stream) + return stream } catch (e) { console.error(e) throw e diff --git a/packages/frontend/src/pages/index.tsx b/packages/frontend/src/pages/index.tsx index 9fdea3d1..245f0f5a 100644 --- a/packages/frontend/src/pages/index.tsx +++ b/packages/frontend/src/pages/index.tsx @@ -40,11 +40,13 @@ export default function Home() { const ping = async () => { if (isConnected) { - return await libp2p.ping(peerIdFromString(peerID)) + return libp2p.ping(multiaddr(maddr)) } } + ping() .then((lat) => { + console.log('latency: ', lat) setLatency(lat) }) .catch((e) => { @@ -140,9 +142,9 @@ export default function Home() { } try { - const connection = await connectToMultiaddr(libp2p)(multiaddr(maddr)) - console.log('connection: ', connection) - return connection + const stream = await connectToMultiaddr(libp2p)(multiaddr(maddr)) + console.log('multiaddr stream: ', stream) + return stream } catch (e) { console.error(e) } From 6cadfaf6d70b155e0f21f24bf8556da8a151673c Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Tue, 21 Mar 2023 20:41:23 -0700 Subject: [PATCH 09/32] disable creating topic --- rust-server/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index f2a27988..a422279c 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -87,11 +87,11 @@ fn create_swarm() -> Result Date: Wed, 22 Mar 2023 14:56:30 +0100 Subject: [PATCH 10/32] Apply suggestions from code review Co-authored-by: Max Inden --- rust-server/Cargo.toml | 1 + rust-server/src/main.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index ab6a5f9c..229b3cbc 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] anyhow = "1.0" +env_logger = "0.10.0" futures = "0.3.27" libp2p = {version="0.51.1", features = ["ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} rand = "0.8.5" diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index a422279c..69939b7f 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -28,6 +28,8 @@ const BOOTNODES: [&str; 1] = [ /// An example WebRTC server that will accept connections #[tokio::main] async fn main() -> Result<()> { + env_logger::init(); + let mut swarm = create_swarm::()?; swarm.listen_on("/ip4/127.0.0.1/udp/0/webrtc".parse()?)?; From bb43fcdf928e4b6f20e82f0df53f81b77119028f Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 15:08:36 +0100 Subject: [PATCH 11/32] chore: update packages --- rust-server/Cargo.lock | 110 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index 4409ab2f..cf64c34f 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -883,6 +883,40 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -1138,6 +1172,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -1189,6 +1229,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "ident_case" version = "1.0.1" @@ -1282,6 +1328,17 @@ dependencies = [ "webrtc-util", ] +[[package]] +name = "io-lifetimes" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.45.0", +] + [[package]] name = "ipconfig" version = "0.3.1" @@ -1300,6 +1357,18 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +[[package]] +name = "is-terminal" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -1690,6 +1759,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "lock_api" version = "0.4.9" @@ -1966,7 +2041,7 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -2568,6 +2643,7 @@ name = "rust-libp2p-webrtc-server" version = "0.1.0" dependencies = [ "anyhow", + "env_logger", "futures", "libp2p", "rand 0.8.5", @@ -2600,6 +2676,20 @@ dependencies = [ "nom", ] +[[package]] +name = "rustix" +version = "0.36.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + [[package]] name = "rustls" version = "0.19.1" @@ -2957,6 +3047,15 @@ dependencies = [ "libc", ] +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.40" @@ -3671,6 +3770,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" From 592cb52391f30f023b2d7d840dcf7741ea22b871 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 15:42:58 +0100 Subject: [PATCH 12/32] log full p2p address and fixes from pair with max --- rust-server/src/main.rs | 44 +++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 69939b7f..3402c3df 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -1,16 +1,14 @@ use anyhow::Result; use futures::StreamExt; use libp2p::{ - core::{muxing::StreamMuxerBox}, - gossipsub, - identity, - kad::record::store::{RecordStore, MemoryStore}, + core::muxing::StreamMuxerBox, + gossipsub, identity, + kad::record::store::{MemoryStore, RecordStore}, kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, - PeerId, + multiaddr::Protocol, ping, - swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder}, - Transport, - webrtc, + swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent}, + webrtc, PeerId, Transport, }; use rand::thread_rng; use std::collections::hash_map::DefaultHasher; @@ -30,25 +28,32 @@ const BOOTNODES: [&str; 1] = [ async fn main() -> Result<()> { env_logger::init(); - let mut swarm = create_swarm::()?; + let mut swarm = create_swarm()?; swarm.listen_on("/ip4/127.0.0.1/udp/0/webrtc".parse()?)?; loop { let event = swarm.next().await.unwrap(); - eprintln!("New event: {event:?}") + eprintln!("New event: {event:?}"); + match event { + SwarmEvent::NewListenAddr { address, .. } => { + let p2p_address = address.with(Protocol::P2p((*swarm.local_peer_id()).into())); + eprintln!("p2p address: {p2p_address:?}") + } + _ => {} + } } } #[derive(NetworkBehaviour)] -struct Behaviour { +struct Behaviour { gossipsub: gossipsub::Behaviour, - kademlia: Kademlia, + kademlia: Kademlia, keep_alive: keep_alive::Behaviour, ping: ping::Behaviour, } -fn create_swarm() -> Result>> { +fn create_swarm() -> Result> { let local_key = identity::Keypair::generate_ed25519(); let local_peer_id = PeerId::from(local_key.public()); println!("Local peer id: {local_peer_id}"); @@ -63,7 +68,7 @@ fn create_swarm() -> Result() -> Result() -> Result Date: Wed, 22 Mar 2023 07:58:57 -0700 Subject: [PATCH 13/32] . --- rust-server/Cargo.lock | 57 +++++++++++++++++++++++++++++++++++++++-- rust-server/Cargo.toml | 2 +- rust-server/src/main.rs | 30 +++++++++++++++++++--- 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index cf64c34f..f956a07e 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -124,6 +124,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.20" @@ -1154,7 +1165,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", ] [[package]] @@ -1425,6 +1445,7 @@ dependencies = [ "libp2p-core", "libp2p-dns", "libp2p-gossipsub", + "libp2p-identify", "libp2p-identity", "libp2p-kad", "libp2p-mdns", @@ -1510,6 +1531,28 @@ dependencies = [ "wasm-timer", ] +[[package]] +name = "libp2p-identify" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d1da1f75baf824cfdc80f6aced51f7cbf8dc14e32363e9443570a80d4ee337" +dependencies = [ + "asynchronous-codec", + "either", + "futures", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "lru", + "quick-protobuf", + "quick-protobuf-codec", + "smallvec", + "thiserror", + "void", +] + [[package]] name = "libp2p-identity" version = "0.1.1" @@ -1586,6 +1629,7 @@ checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" dependencies = [ "libp2p-core", "libp2p-gossipsub", + "libp2p-identify", "libp2p-kad", "libp2p-ping", "libp2p-swarm", @@ -1784,6 +1828,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "lru-cache" version = "0.1.2" @@ -3170,7 +3223,7 @@ dependencies = [ "futures-io", "futures-sink", "futures-util", - "hashbrown", + "hashbrown 0.12.3", "pin-project-lite", "slab", "tokio", diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index 229b3cbc..97a046d1 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0" env_logger = "0.10.0" futures = "0.3.27" -libp2p = {version="0.51.1", features = ["ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} +libp2p = {version="0.51.1", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 3402c3df..b2ebb5da 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -1,9 +1,17 @@ use anyhow::Result; use futures::StreamExt; use libp2p::{ +<<<<<<< HEAD core::muxing::StreamMuxerBox, gossipsub, identity, kad::record::store::{MemoryStore, RecordStore}, +======= + core::{muxing::StreamMuxerBox}, + gossipsub, + identity, + identify, + kad::record::store::{RecordStore, MemoryStore}, +>>>>>>> 9aa0cbc (add identify) kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, multiaddr::Protocol, ping, @@ -48,9 +56,15 @@ async fn main() -> Result<()> { #[derive(NetworkBehaviour)] struct Behaviour { gossipsub: gossipsub::Behaviour, +<<<<<<< HEAD kademlia: Kademlia, +======= + identify: identify::Behaviour, + kademlia: Kademlia, +>>>>>>> 9aa0cbc (add identify) keep_alive: keep_alive::Behaviour, - ping: ping::Behaviour, + // ping: ping::Behaviour, + } fn create_swarm() -> Result> { @@ -84,6 +98,9 @@ fn create_swarm() -> Result> { .heartbeat_interval(Duration::from_secs(10)) // This is set to aid debugging by not cluttering the log space .validation_mode(gossipsub::ValidationMode::Permissive) // This sets the kind of message validation. The default is Strict (enforce message signing) .message_id_fn(message_id_fn) // content-address messages. No two messages of the same content will be propagated. + .mesh_outbound_min(1) + .mesh_n_low(1) + // .mesh_n(1) .build() .expect("Valid config"); @@ -94,10 +111,10 @@ fn create_swarm() -> Result> { ) .expect("Correct configuration"); - // // Create a Gossipsub topic + // Create a Gossipsub topic let topic = gossipsub::IdentTopic::new("universal-connectivity"); - // // subscribes to our topic + // subscribes to our topic gossipsub.subscribe(&topic)?; let transport = webrtc::tokio::Transport::new( @@ -105,6 +122,11 @@ fn create_swarm() -> Result> { webrtc::tokio::Certificate::generate(&mut thread_rng())?, ); + let identify_config = identify::Behaviour::new(identify::Config::new( + "/ipfs/0.1.0".into(), + local_key.public().clone(), + )); + let transport = transport .map(|(local_peer_id, conn), _| (local_peer_id, StreamMuxerBox::new(conn))) .boxed(); @@ -115,5 +137,7 @@ fn create_swarm() -> Result> { keep_alive: keep_alive::Behaviour::default(), ping: ping::Behaviour::default(), }; + // let behaviour = Behaviour { gossipsub, identify: identify_config, kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default(), ping: ping::Behaviour::default() }; + let behaviour = Behaviour { gossipsub, identify: identify_config, kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default() }; Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) } From d1af50ea5760613a6799dabd13ccb570dd610efb Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Wed, 22 Mar 2023 08:06:28 -0700 Subject: [PATCH 14/32] fix merge conflicts --- rust-server/src/main.rs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index b2ebb5da..3978eaa4 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -1,17 +1,11 @@ use anyhow::Result; use futures::StreamExt; use libp2p::{ -<<<<<<< HEAD - core::muxing::StreamMuxerBox, - gossipsub, identity, - kad::record::store::{MemoryStore, RecordStore}, -======= core::{muxing::StreamMuxerBox}, gossipsub, identity, identify, kad::record::store::{RecordStore, MemoryStore}, ->>>>>>> 9aa0cbc (add identify) kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, multiaddr::Protocol, ping, @@ -56,15 +50,10 @@ async fn main() -> Result<()> { #[derive(NetworkBehaviour)] struct Behaviour { gossipsub: gossipsub::Behaviour, -<<<<<<< HEAD - kademlia: Kademlia, -======= identify: identify::Behaviour, - kademlia: Kademlia, ->>>>>>> 9aa0cbc (add identify) + kademlia: Kademlia, keep_alive: keep_alive::Behaviour, // ping: ping::Behaviour, - } fn create_swarm() -> Result> { @@ -131,12 +120,6 @@ fn create_swarm() -> Result> { .map(|(local_peer_id, conn), _| (local_peer_id, StreamMuxerBox::new(conn))) .boxed(); - let behaviour = Behaviour { - gossipsub, - kademlia: kad_behaviour, - keep_alive: keep_alive::Behaviour::default(), - ping: ping::Behaviour::default(), - }; // let behaviour = Behaviour { gossipsub, identify: identify_config, kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default(), ping: ping::Behaviour::default() }; let behaviour = Behaviour { gossipsub, identify: identify_config, kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default() }; Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) From 2c6f8f0d0a650f9ca68cd7a784f5c0d4ea36a210 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 16:35:33 +0100 Subject: [PATCH 15/32] enable ping and increase idle timeout --- rust-server/src/main.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 3978eaa4..5c97984d 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -1,11 +1,9 @@ use anyhow::Result; use futures::StreamExt; use libp2p::{ - core::{muxing::StreamMuxerBox}, - gossipsub, - identity, - identify, - kad::record::store::{RecordStore, MemoryStore}, + core::muxing::StreamMuxerBox, + gossipsub, identify, identity, + kad::record::store::{MemoryStore, RecordStore}, kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, multiaddr::Protocol, ping, @@ -53,7 +51,7 @@ struct Behaviour { identify: identify::Behaviour, kademlia: Kademlia, keep_alive: keep_alive::Behaviour, - // ping: ping::Behaviour, + ping: ping::Behaviour, } fn create_swarm() -> Result> { @@ -88,6 +86,7 @@ fn create_swarm() -> Result> { .validation_mode(gossipsub::ValidationMode::Permissive) // This sets the kind of message validation. The default is Strict (enforce message signing) .message_id_fn(message_id_fn) // content-address messages. No two messages of the same content will be propagated. .mesh_outbound_min(1) + .idle_timeout(Duration::from_secs(360)) .mesh_n_low(1) // .mesh_n(1) .build() @@ -121,6 +120,12 @@ fn create_swarm() -> Result> { .boxed(); // let behaviour = Behaviour { gossipsub, identify: identify_config, kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default(), ping: ping::Behaviour::default() }; - let behaviour = Behaviour { gossipsub, identify: identify_config, kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default() }; + let behaviour = Behaviour { + gossipsub, + identify: identify_config, + kademlia: kad_behaviour, + keep_alive: keep_alive::Behaviour::default(), + ping: ping::Behaviour::default(), + }; Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) } From 03dcb3d1ca7aaf719ab5f572188951ea84a42bdd Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 16:44:17 +0100 Subject: [PATCH 16/32] updates to frontend and js-libp2p --- packages/frontend/src/lib/libp2p.ts | 37 ++++++++++++--------------- packages/frontend/src/pages/index.tsx | 9 +++---- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/packages/frontend/src/lib/libp2p.ts b/packages/frontend/src/lib/libp2p.ts index 087f94f6..d3c2a9f2 100644 --- a/packages/frontend/src/lib/libp2p.ts +++ b/packages/frontend/src/lib/libp2p.ts @@ -39,8 +39,7 @@ export async function startLibp2p(options: {} = {}) { // libp2p is the networking layer that underpins Helia const libp2p = await createLibp2p({ - // connectionManager: { autoDial: false }, - dht: kadDHT(), + // dht: kadDHT(), datastore, transports: [webTransport(), webSockets(), webRTC()], connectionEncryption: [noise()], @@ -57,27 +56,23 @@ export async function startLibp2p(options: {} = {}) { // }, // }, peerDiscovery: [ - bootstrap({ - list: [ - '/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN', - '/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa', - '/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt', - '/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb', - // '/dns4/am6.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb', - // '/dnsaddr/ny5.bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa', - // '/dns4/ny5.bootstrap.libp2p.io/tcp/443/wss/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa', - - // '/dns4/node0.preload.ipfs.io/tcp/443/wss/p2p/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic', - // '/dns4/node1.preload.ipfs.io/tcp/443/wss/p2p/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6', - // '/dns4/node2.preload.ipfs.io/tcp/443/wss/p2p/QmV7gnbW5VTcJ3oyM2Xk1rdFBJ3kTkvxc87UFGsun29STS', - // '/dns4/node3.preload.ipfs.io/tcp/443/wss/p2p/QmY7JB6MQXhxHvq7dBDh4HpbH29v4yE9JRadAVpndvzySN', - ], - }), + // bootstrap({ + // list: [ + // // '/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN', + // // '/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa', + // // '/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt', + // // '/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb', + // ], + // }), ], pubsub: gossipsub({ allowPublishToZeroPeers: true, allowedTopics: [CHAT_TOPIC], }), + // connectionManager: { + // minConnections: 0, + // maxConnections: 3, + // }, // peerRouters: [delegatedPeerRouting(client)], }) @@ -154,9 +149,9 @@ export const connectToMultiaddr = (libp2p: Libp2p) => async (multiaddr: Multiaddr) => { console.log(`dialling: ${multiaddr.toString()}`) try { - const stream = await libp2p.dialProtocol(multiaddr, ["/meshsub/1.1.0", "/ipfs/ping/1.0.0"]) - console.info('connected to', stream) - return stream + const conn = await libp2p.dial(multiaddr) + console.info('connected to', conn.remotePeer, 'on', conn.remoteAddr) + return conn } catch (e) { console.error(e) throw e diff --git a/packages/frontend/src/pages/index.tsx b/packages/frontend/src/pages/index.tsx index 245f0f5a..9b7a87c5 100644 --- a/packages/frontend/src/pages/index.tsx +++ b/packages/frontend/src/pages/index.tsx @@ -39,14 +39,13 @@ export default function Home() { } const ping = async () => { - if (isConnected) { + if(maddr) { return libp2p.ping(multiaddr(maddr)) } } ping() .then((lat) => { - console.log('latency: ', lat) setLatency(lat) }) .catch((e) => { @@ -142,9 +141,9 @@ export default function Home() { } try { - const stream = await connectToMultiaddr(libp2p)(multiaddr(maddr)) - console.log('multiaddr stream: ', stream) - return stream + const connection = await connectToMultiaddr(libp2p)(multiaddr(maddr)) + console.log('connection: ', connection) + return connection } catch (e) { console.error(e) } From f9995a8c51503603df5d8be038bd2e6e1bacbfaf Mon Sep 17 00:00:00 2001 From: Prithvi Shahi <50885601+p-shahi@users.noreply.github.com> Date: Wed, 22 Mar 2023 10:30:31 -0700 Subject: [PATCH 17/32] Update rust-server/Cargo.toml Co-authored-by: Max Inden --- rust-server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index 97a046d1..7525856f 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0" env_logger = "0.10.0" futures = "0.3.27" -libp2p = {version="0.51.1", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} +libp2p = {git = "https://github.com/vnermolaev/rust-libp2p.git", branch = "deprecate/gossipsub-close-event", version="0.51.1", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } From 446db906b5809b566058f4dd62ff96ce387109fc Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:27:41 +0100 Subject: [PATCH 18/32] add dockerfile --- rust-server/.dockerignore | 1 + rust-server/Dockerfile | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 rust-server/.dockerignore create mode 100644 rust-server/Dockerfile diff --git a/rust-server/.dockerignore b/rust-server/.dockerignore new file mode 100644 index 00000000..2f7896d1 --- /dev/null +++ b/rust-server/.dockerignore @@ -0,0 +1 @@ +target/ diff --git a/rust-server/Dockerfile b/rust-server/Dockerfile new file mode 100644 index 00000000..adcbb079 --- /dev/null +++ b/rust-server/Dockerfile @@ -0,0 +1,9 @@ +FROM rust:1.68 as builder +WORKDIR /usr/src/universal-chat +COPY . . +RUN cargo install --path . + +FROM debian:bullseye-slim +RUN apt-get update && apt-get install && rm -rf /var/lib/apt/lists/* +COPY --from=builder /usr/local/cargo/bin/rust-libp2p-webrtc-server /usr/local/bin/rust-libp2p-webrtc-server +CMD ["rust-libp2p-webrtc-server"] \ No newline at end of file From 390d557b1fb811ed7c599b2519e899956160cdf4 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:43:19 +0100 Subject: [PATCH 19/32] deploy to fly --- .github/workflows/fly.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/fly.yml diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml new file mode 100644 index 00000000..76abc079 --- /dev/null +++ b/.github/workflows/fly.yml @@ -0,0 +1,18 @@ +name: Fly Deploy +on: + push: + branches: + - main +jobs: + deploy: + name: Deploy app + runs-on: ubuntu-latest + defaults: + run: + working-directory: rust-server + steps: + - uses: actions/checkout@v3 + - uses: superfly/flyctl-actions/setup-flyctl@master + - run: flyctl deploy --remote-only + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} From d96f54c4441202abf1fb79b479da80ef1a7c53a2 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:54:53 +0100 Subject: [PATCH 20/32] add fly config --- rust-server/fly.toml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 rust-server/fly.toml diff --git a/rust-server/fly.toml b/rust-server/fly.toml new file mode 100644 index 00000000..fb9e43ff --- /dev/null +++ b/rust-server/fly.toml @@ -0,0 +1,37 @@ +# fly.toml file generated for universal-chat on 2023-03-22T19:29:53+01:00 + +app = "universal-chat" +kill_signal = "SIGINT" +kill_timeout = 5 +processes = [] + +[env] + +[experimental] + auto_rollback = true + +[[services]] + http_checks = [] + internal_port = 8080 + processes = ["app"] + protocol = "tcp" + script_checks = [] + [services.concurrency] + hard_limit = 25 + soft_limit = 20 + type = "connections" + + [[services.ports]] + force_https = true + handlers = ["http"] + port = 80 + + [[services.ports]] + handlers = ["tls", "http"] + port = 443 + + [[services.tcp_checks]] + grace_period = "1s" + interval = "15s" + restart_limit = 0 + timeout = "2s" From 680c8bd659e35e05e4758128c9fb1458a1a1e414 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:58:13 +0100 Subject: [PATCH 21/32] listen and bind on port 5888 --- rust-server/fly.toml | 21 ++++----------------- rust-server/src/main.rs | 2 +- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/rust-server/fly.toml b/rust-server/fly.toml index fb9e43ff..25eb37da 100644 --- a/rust-server/fly.toml +++ b/rust-server/fly.toml @@ -11,27 +11,14 @@ processes = [] auto_rollback = true [[services]] - http_checks = [] - internal_port = 8080 + internal_port = 5888 processes = ["app"] - protocol = "tcp" + protocol = "udp" script_checks = [] [services.concurrency] - hard_limit = 25 - soft_limit = 20 + hard_limit = 200 type = "connections" [[services.ports]] - force_https = true - handlers = ["http"] - port = 80 + port = 5888 - [[services.ports]] - handlers = ["tls", "http"] - port = 443 - - [[services.tcp_checks]] - grace_period = "1s" - interval = "15s" - restart_limit = 0 - timeout = "2s" diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 5c97984d..b8f015ef 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -30,7 +30,7 @@ async fn main() -> Result<()> { let mut swarm = create_swarm()?; - swarm.listen_on("/ip4/127.0.0.1/udp/0/webrtc".parse()?)?; + swarm.listen_on("/ip4/127.0.0.1/udp/5888/webrtc".parse()?)?; loop { let event = swarm.next().await.unwrap(); From 38bb908afd16e47dcae6cff11fddb68ebbfba1be Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 20:02:17 +0100 Subject: [PATCH 22/32] enable manual deployment --- .github/workflows/fly.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml index 76abc079..5c0070e6 100644 --- a/.github/workflows/fly.yml +++ b/.github/workflows/fly.yml @@ -3,6 +3,9 @@ on: push: branches: - main + - rust-server + workflow_dispatch: + jobs: deploy: name: Deploy app From bf1be775a862d25bda6ddbf48bbaa6f0228b4e04 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Wed, 22 Mar 2023 20:21:00 +0100 Subject: [PATCH 23/32] enable logging --- rust-server/fly.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/rust-server/fly.toml b/rust-server/fly.toml index 25eb37da..60a29c63 100644 --- a/rust-server/fly.toml +++ b/rust-server/fly.toml @@ -6,6 +6,7 @@ kill_timeout = 5 processes = [] [env] + RUST_LOG="debug" [experimental] auto_rollback = true From 153192968ced50b2250ed564058ae3d39ad854d5 Mon Sep 17 00:00:00 2001 From: chad Date: Wed, 22 Mar 2023 15:29:37 -0500 Subject: [PATCH 24/32] integrated explicit peer adding for gossipsub + added recurring messages from rust-server --- packages/frontend/src/components/chat.tsx | 11 ++- packages/frontend/src/pages/index.tsx | 6 +- rust-server/Cargo.lock | 108 ++++++++++++---------- rust-server/src/main.rs | 39 +++++++- 4 files changed, 102 insertions(+), 62 deletions(-) diff --git a/packages/frontend/src/components/chat.tsx b/packages/frontend/src/components/chat.tsx index 78cd7723..d112620b 100644 --- a/packages/frontend/src/components/chat.tsx +++ b/packages/frontend/src/components/chat.tsx @@ -40,10 +40,14 @@ export default function ChatContainer() { const sendMessage = useCallback(async () => { if (input === '') return + console.log('peers in gossip:', libp2p.pubsub.getSubscribers(CHAT_TOPIC).toString()) + const res = await libp2p.pubsub.publish( CHAT_TOPIC, new TextEncoder().encode(input), ) + console.log('sent message to: ', res) + setMessages([...messages, { msg: input, from: 'me' }]) setInput('') }, [input, messages, setInput, libp2p]) @@ -79,7 +83,7 @@ export default function ChatContainer() {

- {/* disable + {/* disable (
  • {msg} diff --git a/packages/frontend/src/pages/index.tsx b/packages/frontend/src/pages/index.tsx index 9b7a87c5..6ba89b1e 100644 --- a/packages/frontend/src/pages/index.tsx +++ b/packages/frontend/src/pages/index.tsx @@ -39,7 +39,7 @@ export default function Home() { } const ping = async () => { - if(maddr) { + if (maddr) { return libp2p.ping(multiaddr(maddr)) } } @@ -54,7 +54,7 @@ export default function Home() { getConnectedPeers().then((peers) => { // If one of the connected peers matches the one in input we're connected - if (peers.some((pID) => peerID === pID.toString())) { + if (peers.some((pID) => multiaddr(maddr).getPeerId() === pID.toString())) { setIsConnected(true) } setPeers(peers) @@ -63,7 +63,7 @@ export default function Home() { // If one of the connected peers matches the one in input we're connected setConnections(conns) }) - }, 1000) + }, 10000) // Effect hook to connect to a specific peer when the page loads // useEffect(() => { diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index f956a07e..2c6415b9 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -1433,15 +1433,16 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "libp2p" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e068bb83ef4e0bed45de5ca4a4118018ac1f70ea3ecb1f4878742d08a97473" +version = "0.51.2" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "futures", "futures-timer", "getrandom 0.2.8", "instant", + "libp2p-allow-block-list", + "libp2p-connection-limits", "libp2p-core", "libp2p-dns", "libp2p-gossipsub", @@ -1459,11 +1460,32 @@ dependencies = [ "pin-project", ] +[[package]] +name = "libp2p-allow-block-list" +version = "0.1.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.1.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + [[package]] name = "libp2p-core" version = "0.39.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7f8b7d65c070a5a1b5f8f0510648189da08f787b8963f8e21219e0710733af" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "either", "fnv", @@ -1490,11 +1512,11 @@ dependencies = [ [[package]] name = "libp2p-dns" version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.1", "smallvec", @@ -1504,8 +1526,7 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" version = "0.44.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "708235886ca7c8f3792a8683ef81f9b7fb0a952bbd15fe5038b7610689a88390" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asynchronous-codec", "base64 0.21.0", @@ -1528,14 +1549,14 @@ dependencies = [ "smallvec", "thiserror", "unsigned-varint", + "void", "wasm-timer", ] [[package]] name = "libp2p-identify" version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40d1da1f75baf824cfdc80f6aced51f7cbf8dc14e32363e9443570a80d4ee337" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asynchronous-codec", "either", @@ -1556,8 +1577,7 @@ dependencies = [ [[package]] name = "libp2p-identity" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a8ea433ae0cea7e3315354305237b9897afe45278b2118a7a57ca744e70fd27" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asn1_der", "bs58", @@ -1576,8 +1596,7 @@ dependencies = [ [[package]] name = "libp2p-kad" version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc57e02d7ad49a63792370f24b829af38f34982ff56556e59e4cb325a4dbf6b" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "arrayvec", "asynchronous-codec", @@ -1604,13 +1623,13 @@ dependencies = [ [[package]] name = "libp2p-mdns" version = "0.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "687a0b54ee8f7106be36f012b32bd30faceeb4cd857ebad96e512566886ffea5" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "data-encoding", "futures", "if-watch", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -1624,12 +1643,12 @@ dependencies = [ [[package]] name = "libp2p-metrics" version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "libp2p-core", "libp2p-gossipsub", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-ping", "libp2p-swarm", @@ -1639,8 +1658,7 @@ dependencies = [ [[package]] name = "libp2p-noise" version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c87c2803deffeae94108072a0387f8c9ff494af68a4908454c11c811e27b5e5" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -1662,14 +1680,14 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "either", "futures", "futures-timer", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -1679,8 +1697,7 @@ dependencies = [ [[package]] name = "libp2p-quic" version = "0.7.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "futures", @@ -1700,9 +1717,8 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c22a83d70703d140092c969c1ca06ecdffff8ca7ce8ac2fd3b7eb2c1f0da86" +version = "0.42.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "either", "fnv", @@ -1710,12 +1726,11 @@ dependencies = [ "futures-timer", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm-derive", "log", - "pin-project", "rand 0.8.5", "smallvec", - "thiserror", "tokio", "void", ] @@ -1723,25 +1738,24 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "heck", "quote", - "syn 1.0.109", + "syn 2.0.4", ] [[package]] name = "libp2p-tcp" version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "futures-timer", "if-watch", "libc", "libp2p-core", + "libp2p-identity", "log", "socket2", "tokio", @@ -1750,8 +1764,7 @@ dependencies = [ [[package]] name = "libp2p-tls" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "futures-rustls", @@ -1762,15 +1775,14 @@ dependencies = [ "rustls 0.20.8", "thiserror", "webpki 0.22.0", - "x509-parser 0.14.0", + "x509-parser 0.15.0", "yasna", ] [[package]] name = "libp2p-webrtc" -version = "0.4.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffd0c3af5921e3bdd5fecdf3eef3be5a197def64c1d23cd3ea79abcadbd461f7" +version = "0.4.0-alpha.4" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "async-trait", "asynchronous-codec", @@ -1959,8 +1971,7 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "futures", @@ -2456,8 +2467,7 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asynchronous-codec", "bytes", @@ -2771,8 +2781,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "pin-project", @@ -4014,12 +4023,11 @@ dependencies = [ [[package]] name = "x509-parser" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" +checksum = "bab0c2f54ae1d92f4fcb99c0b7ccf0b1e3451cbd395e5f115ccbdbcb18d4f634" dependencies = [ "asn1-rs 0.5.2", - "base64 0.13.1", "data-encoding", "der-parser 8.2.0", "lazy_static", diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index b8f015ef..1d37c3db 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -8,7 +8,7 @@ use libp2p::{ multiaddr::Protocol, ping, swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent}, - webrtc, PeerId, Transport, + webrtc, Multiaddr, PeerId, Transport, }; use rand::thread_rng; use std::collections::hash_map::DefaultHasher; @@ -29,8 +29,13 @@ async fn main() -> Result<()> { env_logger::init(); let mut swarm = create_swarm()?; + let port = std::env::var("PORT").unwrap_or("0".to_string()); - swarm.listen_on("/ip4/127.0.0.1/udp/5888/webrtc".parse()?)?; + swarm.listen_on(format!("/ip4/127.0.0.1/udp/{port}/webrtc").parse()?)?; + if let Some(address) = std::env::var("ADDRESS").ok() { + print!("Dialing {address}... "); + swarm.dial(address.parse::()?)?; + } loop { let event = swarm.next().await.unwrap(); @@ -40,8 +45,27 @@ async fn main() -> Result<()> { let p2p_address = address.with(Protocol::P2p((*swarm.local_peer_id()).into())); eprintln!("p2p address: {p2p_address:?}") } + SwarmEvent::ConnectionEstablished { + peer_id, + endpoint, + num_established, + concurrent_dial_errors, + established_in, + } => { + swarm.behaviour_mut().gossipsub.add_explicit_peer(&peer_id); + } _ => {} } + let peers: Vec<_> = swarm.behaviour().gossipsub.all_peers().collect(); + eprintln!("Peers: {peers:?}"); + + let message = "Hello world!".to_owned() + &rand::random::().to_string(); + let topic = gossipsub::IdentTopic::new("universal-connectivity"); + + dbg!(swarm + .behaviour_mut() + .gossipsub + .publish(topic, message.as_bytes())); } } @@ -82,12 +106,11 @@ fn create_swarm() -> Result> { // Set a custom gossipsub configuration let gossipsub_config = gossipsub::ConfigBuilder::default() - .heartbeat_interval(Duration::from_secs(10)) // This is set to aid debugging by not cluttering the log space .validation_mode(gossipsub::ValidationMode::Permissive) // This sets the kind of message validation. The default is Strict (enforce message signing) .message_id_fn(message_id_fn) // content-address messages. No two messages of the same content will be propagated. .mesh_outbound_min(1) - .idle_timeout(Duration::from_secs(360)) .mesh_n_low(1) + .flood_publish(true) // .mesh_n(1) .build() .expect("Valid config"); @@ -119,7 +142,6 @@ fn create_swarm() -> Result> { .map(|(local_peer_id, conn), _| (local_peer_id, StreamMuxerBox::new(conn))) .boxed(); - // let behaviour = Behaviour { gossipsub, identify: identify_config, kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default(), ping: ping::Behaviour::default() }; let behaviour = Behaviour { gossipsub, identify: identify_config, @@ -127,5 +149,12 @@ fn create_swarm() -> Result> { keep_alive: keep_alive::Behaviour::default(), ping: ping::Behaviour::default(), }; + // let behaviour = Behaviour { + // gossipsub, + // identify: identify_config, + // kademlia: kad_behaviour, + // keep_alive: keep_alive::Behaviour::default(), + // ping: ping::Behaviour::default(), + // }; Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) } From 6f251c937286fa178b63b68708a336a2709c4bd8 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Thu, 23 Mar 2023 14:57:47 +0100 Subject: [PATCH 25/32] remove fly from pipeline --- .github/workflows/fly.yml | 21 --------------------- rust-server/fly.toml | 25 ------------------------- 2 files changed, 46 deletions(-) delete mode 100644 .github/workflows/fly.yml delete mode 100644 rust-server/fly.toml diff --git a/.github/workflows/fly.yml b/.github/workflows/fly.yml deleted file mode 100644 index 5c0070e6..00000000 --- a/.github/workflows/fly.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Fly Deploy -on: - push: - branches: - - main - - rust-server - workflow_dispatch: - -jobs: - deploy: - name: Deploy app - runs-on: ubuntu-latest - defaults: - run: - working-directory: rust-server - steps: - - uses: actions/checkout@v3 - - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/rust-server/fly.toml b/rust-server/fly.toml deleted file mode 100644 index 60a29c63..00000000 --- a/rust-server/fly.toml +++ /dev/null @@ -1,25 +0,0 @@ -# fly.toml file generated for universal-chat on 2023-03-22T19:29:53+01:00 - -app = "universal-chat" -kill_signal = "SIGINT" -kill_timeout = 5 -processes = [] - -[env] - RUST_LOG="debug" - -[experimental] - auto_rollback = true - -[[services]] - internal_port = 5888 - processes = ["app"] - protocol = "udp" - script_checks = [] - [services.concurrency] - hard_limit = 200 - type = "connections" - - [[services.ports]] - port = 5888 - From 074b3769bc9a8d2c062bc0c939373e7c6fe440aa Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Fri, 24 Mar 2023 09:05:42 -0700 Subject: [PATCH 26/32] publish at even intervals --- rust-server/Cargo.lock | 22 ------------ rust-server/Cargo.toml | 2 +- rust-server/src/main.rs | 76 +++++++++++------------------------------ 3 files changed, 20 insertions(+), 80 deletions(-) diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index 2c6415b9..e1581e27 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -1434,7 +1434,6 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "libp2p" version = "0.51.2" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "futures", @@ -1463,7 +1462,6 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "libp2p-core", "libp2p-identity", @@ -1474,7 +1472,6 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "libp2p-core", "libp2p-identity", @@ -1485,7 +1482,6 @@ dependencies = [ [[package]] name = "libp2p-core" version = "0.39.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "either", "fnv", @@ -1512,7 +1508,6 @@ dependencies = [ [[package]] name = "libp2p-dns" version = "0.39.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "libp2p-core", @@ -1526,7 +1521,6 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" version = "0.44.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asynchronous-codec", "base64 0.21.0", @@ -1556,7 +1550,6 @@ dependencies = [ [[package]] name = "libp2p-identify" version = "0.42.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asynchronous-codec", "either", @@ -1577,7 +1570,6 @@ dependencies = [ [[package]] name = "libp2p-identity" version = "0.1.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asn1_der", "bs58", @@ -1596,7 +1588,6 @@ dependencies = [ [[package]] name = "libp2p-kad" version = "0.43.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "arrayvec", "asynchronous-codec", @@ -1623,7 +1614,6 @@ dependencies = [ [[package]] name = "libp2p-mdns" version = "0.43.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "data-encoding", "futures", @@ -1643,7 +1633,6 @@ dependencies = [ [[package]] name = "libp2p-metrics" version = "0.12.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "libp2p-core", "libp2p-gossipsub", @@ -1658,7 +1647,6 @@ dependencies = [ [[package]] name = "libp2p-noise" version = "0.42.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -1680,7 +1668,6 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.42.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "either", "futures", @@ -1697,7 +1684,6 @@ dependencies = [ [[package]] name = "libp2p-quic" version = "0.7.0-alpha.3" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "futures", @@ -1718,7 +1704,6 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.42.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "either", "fnv", @@ -1738,7 +1723,6 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" version = "0.32.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "heck", "quote", @@ -1748,7 +1732,6 @@ dependencies = [ [[package]] name = "libp2p-tcp" version = "0.39.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "futures-timer", @@ -1764,7 +1747,6 @@ dependencies = [ [[package]] name = "libp2p-tls" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "futures-rustls", @@ -1782,7 +1764,6 @@ dependencies = [ [[package]] name = "libp2p-webrtc" version = "0.4.0-alpha.4" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "async-trait", "asynchronous-codec", @@ -1971,7 +1952,6 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.12.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "bytes", "futures", @@ -2467,7 +2447,6 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "asynchronous-codec", "bytes", @@ -2781,7 +2760,6 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.3.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#fef9751ee6567eb82f7ea3db7ef1effe82564e3d" dependencies = [ "futures", "pin-project", diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index 7525856f..c519b67f 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0" env_logger = "0.10.0" futures = "0.3.27" -libp2p = {git = "https://github.com/vnermolaev/rust-libp2p.git", branch = "deprecate/gossipsub-close-event", version="0.51.1", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} +libp2p = {path = "/Users/prithvi/lab/vner/libp2p", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 1d37c3db..9ff5b13a 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -3,8 +3,6 @@ use futures::StreamExt; use libp2p::{ core::muxing::StreamMuxerBox, gossipsub, identify, identity, - kad::record::store::{MemoryStore, RecordStore}, - kad::{GetClosestPeersError, Kademlia, KademliaConfig, KademliaEvent, QueryResult}, multiaddr::Protocol, ping, swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent}, @@ -13,15 +11,9 @@ use libp2p::{ use rand::thread_rng; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; -use std::time::Duration; +use std::io; +use std::time::{Duration, Instant}; -// TODO: replace with our private bootstrap node -const BOOTNODES: [&str; 1] = [ - "QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", - // "QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", - // "QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", - // "QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", -]; /// An example WebRTC server that will accept connections #[tokio::main] @@ -29,14 +21,9 @@ async fn main() -> Result<()> { env_logger::init(); let mut swarm = create_swarm()?; - let port = std::env::var("PORT").unwrap_or("0".to_string()); - - swarm.listen_on(format!("/ip4/127.0.0.1/udp/{port}/webrtc").parse()?)?; - if let Some(address) = std::env::var("ADDRESS").ok() { - print!("Dialing {address}... "); - swarm.dial(address.parse::()?)?; - } + swarm.listen_on(format!("/ip4/127.0.0.1/udp/0/webrtc").parse()?)?; + let now = Instant::now(); loop { let event = swarm.next().await.unwrap(); eprintln!("New event: {event:?}"); @@ -44,28 +31,26 @@ async fn main() -> Result<()> { SwarmEvent::NewListenAddr { address, .. } => { let p2p_address = address.with(Protocol::P2p((*swarm.local_peer_id()).into())); eprintln!("p2p address: {p2p_address:?}") - } - SwarmEvent::ConnectionEstablished { - peer_id, - endpoint, - num_established, - concurrent_dial_errors, - established_in, - } => { - swarm.behaviour_mut().gossipsub.add_explicit_peer(&peer_id); - } + }, _ => {} } let peers: Vec<_> = swarm.behaviour().gossipsub.all_peers().collect(); eprintln!("Peers: {peers:?}"); + let peers: Vec<_> = swarm.behaviour().gossipsub.all_mesh_peers().collect(); + eprintln!("Mesh peers: {peers:?}"); + + + let elapsed_secs = now.elapsed().as_secs(); + eprintln!("elapsed seconds: {}", elapsed_secs); - let message = "Hello world!".to_owned() + &rand::random::().to_string(); - let topic = gossipsub::IdentTopic::new("universal-connectivity"); + let message = "Hello world! sent at : ".to_owned() + &elapsed_secs.clone().to_string() + " seconds."; - dbg!(swarm - .behaviour_mut() - .gossipsub - .publish(topic, message.as_bytes())); + if elapsed_secs % 2 == 0 { + dbg!(swarm + .behaviour_mut() + .gossipsub + .publish(gossipsub::IdentTopic::new("universal-connectivity"), message.as_bytes())); + } } } @@ -73,7 +58,7 @@ async fn main() -> Result<()> { struct Behaviour { gossipsub: gossipsub::Behaviour, identify: identify::Behaviour, - kademlia: Kademlia, + // kademlia: Kademlia, keep_alive: keep_alive::Behaviour, ping: ping::Behaviour, } @@ -83,20 +68,6 @@ fn create_swarm() -> Result> { let local_peer_id = PeerId::from(local_key.public()); println!("Local peer id: {local_peer_id}"); - // Create a Kademlia behaviour. - let mut cfg = KademliaConfig::default(); - cfg.set_query_timeout(Duration::from_secs(5 * 60)); - let store = MemoryStore::new(local_peer_id); - let mut kad_behaviour = Kademlia::with_config(local_peer_id, store, cfg); - - // Add the bootnodes to the local routing table. `libp2p-dns` built - // into the `transport` resolves the `dnsaddr` when Kademlia tries - // to dial these nodes. - for peer in &BOOTNODES { - // TODO: update this - kad_behaviour.add_address(&peer.parse()?, "/dnsaddr/bootstrap.libp2p.io".parse()?); - } - // To content-address message, we can take the hash of message and use it as an ID. let message_id_fn = |message: &gossipsub::Message| { let mut s = DefaultHasher::new(); @@ -111,7 +82,6 @@ fn create_swarm() -> Result> { .mesh_outbound_min(1) .mesh_n_low(1) .flood_publish(true) - // .mesh_n(1) .build() .expect("Valid config"); @@ -145,16 +115,8 @@ fn create_swarm() -> Result> { let behaviour = Behaviour { gossipsub, identify: identify_config, - kademlia: kad_behaviour, keep_alive: keep_alive::Behaviour::default(), ping: ping::Behaviour::default(), }; - // let behaviour = Behaviour { - // gossipsub, - // identify: identify_config, - // kademlia: kad_behaviour, - // keep_alive: keep_alive::Behaviour::default(), - // ping: ping::Behaviour::default(), - // }; Ok(SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()) } From 0780b582a4fa672ab7b6b809255ffe3f5e1e0c55 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Fri, 24 Mar 2023 09:40:16 -0700 Subject: [PATCH 27/32] fix toml --- rust-server/Cargo.lock | 22 ++++++++++++++++++++++ rust-server/Cargo.toml | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index e1581e27..0e18e011 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -1434,6 +1434,7 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "libp2p" version = "0.51.2" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "bytes", "futures", @@ -1462,6 +1463,7 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" version = "0.1.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "libp2p-core", "libp2p-identity", @@ -1472,6 +1474,7 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" version = "0.1.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "libp2p-core", "libp2p-identity", @@ -1482,6 +1485,7 @@ dependencies = [ [[package]] name = "libp2p-core" version = "0.39.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "either", "fnv", @@ -1508,6 +1512,7 @@ dependencies = [ [[package]] name = "libp2p-dns" version = "0.39.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "futures", "libp2p-core", @@ -1521,6 +1526,7 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" version = "0.44.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "asynchronous-codec", "base64 0.21.0", @@ -1550,6 +1556,7 @@ dependencies = [ [[package]] name = "libp2p-identify" version = "0.42.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "asynchronous-codec", "either", @@ -1570,6 +1577,7 @@ dependencies = [ [[package]] name = "libp2p-identity" version = "0.1.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "asn1_der", "bs58", @@ -1588,6 +1596,7 @@ dependencies = [ [[package]] name = "libp2p-kad" version = "0.43.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "arrayvec", "asynchronous-codec", @@ -1614,6 +1623,7 @@ dependencies = [ [[package]] name = "libp2p-mdns" version = "0.43.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "data-encoding", "futures", @@ -1633,6 +1643,7 @@ dependencies = [ [[package]] name = "libp2p-metrics" version = "0.12.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "libp2p-core", "libp2p-gossipsub", @@ -1647,6 +1658,7 @@ dependencies = [ [[package]] name = "libp2p-noise" version = "0.42.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -1668,6 +1680,7 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.42.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "either", "futures", @@ -1684,6 +1697,7 @@ dependencies = [ [[package]] name = "libp2p-quic" version = "0.7.0-alpha.3" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "bytes", "futures", @@ -1704,6 +1718,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.42.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "either", "fnv", @@ -1723,6 +1738,7 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" version = "0.32.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "heck", "quote", @@ -1732,6 +1748,7 @@ dependencies = [ [[package]] name = "libp2p-tcp" version = "0.39.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "futures", "futures-timer", @@ -1747,6 +1764,7 @@ dependencies = [ [[package]] name = "libp2p-tls" version = "0.1.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "futures", "futures-rustls", @@ -1764,6 +1782,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc" version = "0.4.0-alpha.4" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "async-trait", "asynchronous-codec", @@ -1952,6 +1971,7 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.12.1" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "bytes", "futures", @@ -2447,6 +2467,7 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" version = "0.1.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "asynchronous-codec", "bytes", @@ -2760,6 +2781,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.3.0" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" dependencies = [ "futures", "pin-project", diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index c519b67f..43143c3f 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0" env_logger = "0.10.0" futures = "0.3.27" -libp2p = {path = "/Users/prithvi/lab/vner/libp2p", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} +libp2p = {git = "https://github.com/vnermolaev/rust-libp2p.git", branch = "deprecate/gossipsub-close-event", version="0.51.2", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } From a7a038452541eb5d174f0f62b32d6df6125ed1e9 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Fri, 24 Mar 2023 10:50:48 -0700 Subject: [PATCH 28/32] add message id function --- packages/frontend/src/components/chat.tsx | 3 +- packages/frontend/src/lib/libp2p.ts | 41 ++++++++++++++--------- rust-server/src/main.rs | 18 +++++----- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/packages/frontend/src/components/chat.tsx b/packages/frontend/src/components/chat.tsx index d112620b..2c0f856a 100644 --- a/packages/frontend/src/components/chat.tsx +++ b/packages/frontend/src/components/chat.tsx @@ -21,9 +21,10 @@ export default function ChatContainer() { // Effect hook to subscribe to pubsub events and update the message state hook useEffect(() => { const messageCB = (message: CustomEvent) => { + console.log("gossipsub console log", message) const { topic, data } = message.detail const msg = new TextDecoder().decode(data) - console.log(`${topic}: ${msg}`) + console.error(`${topic}: ${msg}`) // Append new message setMessages([...messages, { msg, from: 'other' }]) } diff --git a/packages/frontend/src/lib/libp2p.ts b/packages/frontend/src/lib/libp2p.ts index d3c2a9f2..df773bc6 100644 --- a/packages/frontend/src/lib/libp2p.ts +++ b/packages/frontend/src/lib/libp2p.ts @@ -12,13 +12,15 @@ import { protocols, Protocol, } from '@multiformats/multiaddr' +import { sha256 } from 'multiformats/hashes/sha2' +import type { Message } from '@libp2p/interface-pubsub' import { LevelDatastore } from 'datastore-level' import isIPPrivate from 'private-ip' import { delegatedPeerRouting } from '@libp2p/delegated-peer-routing' import { create as KuboClient } from 'kubo-rpc-client' import { gossipsub } from '@chainsafe/libp2p-gossipsub' import { webSockets } from '@libp2p/websockets' -import { webTransport } from '@libp2p/webtransport' +// import { webTransport } from '@libp2p/webtransport' import { webRTC } from '@libp2p/webrtc' import { PeerId } from 'kubo-rpc-client/dist/src/types' import { CHAT_TOPIC } from './constants' @@ -41,7 +43,8 @@ export async function startLibp2p(options: {} = {}) { const libp2p = await createLibp2p({ // dht: kadDHT(), datastore, - transports: [webTransport(), webSockets(), webRTC()], + // transports: [webTransport(), webSockets(), webRTC()], + transports: [webRTC()], connectionEncryption: [noise()], streamMuxers: [yamux()], // connectionGater: { @@ -67,7 +70,8 @@ export async function startLibp2p(options: {} = {}) { ], pubsub: gossipsub({ allowPublishToZeroPeers: true, - allowedTopics: [CHAT_TOPIC], + // allowedTopics: [CHAT_TOPIC], + msgIdFn: msgIdFnStrictNoSign, }), // connectionManager: { // minConnections: 0, @@ -83,6 +87,13 @@ export async function startLibp2p(options: {} = {}) { return libp2p } +// message IDs are used to dedup inbound messages +// every agent in network should use the same message id function +// messages could be perceived as duplicate if this isnt added (as opposed to rust server which has unique message ids) +export async function msgIdFnStrictNoSign(msg: Message): Promise { + return await sha256.encode(msg.data) +} + // Curried function to get multiaddresses for a peer by looking up dht export const getPeerMultiaddrs = (libp2p: Libp2p) => @@ -126,18 +137,18 @@ export const connectToMultiaddrs = const conns = [] const errs = [] - for (let multiaddr of publicWebTransportMultiaddrs) { - multiaddr = addPeerIdToWebTransportMultiAddr(multiaddr, peerId) - console.log(`dialling: ${multiaddr.toString()}`) - try { - const conn = await libp2p.dial(multiaddr) - conns.push(conn) - console.info('connected to', conn.remotePeer, 'on', conn.remoteAddr) - } catch (e) { - errs.push(e) - console.error(e) - } - } + // for (let multiaddr of publicWebTransportMultiaddrs) { + // multiaddr = addPeerIdToWebTransportMultiAddr(multiaddr, peerId) + // console.log(`dialling: ${multiaddr.toString()}`) + // try { + // const conn = await libp2p.dial(multiaddr) + // conns.push(conn) + // console.info('connected to', conn.remotePeer, 'on', conn.remoteAddr) + // } catch (e) { + // errs.push(e) + // console.error(e) + // } + // } if (conns.length === 0) { throw new Libp2pDialError('Failed to connect to peer', errs) } diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 9ff5b13a..4a732cf5 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -34,23 +34,23 @@ async fn main() -> Result<()> { }, _ => {} } - let peers: Vec<_> = swarm.behaviour().gossipsub.all_peers().collect(); - eprintln!("Peers: {peers:?}"); - let peers: Vec<_> = swarm.behaviour().gossipsub.all_mesh_peers().collect(); - eprintln!("Mesh peers: {peers:?}"); + // let peers: Vec<_> = swarm.behaviour().gossipsub.all_peers().collect(); + // eprintln!("Peers: {peers:?}"); + // let peers: Vec<_> = swarm.behaviour().gossipsub.all_mesh_peers().collect(); + // eprintln!("Mesh peers: {peers:?}"); let elapsed_secs = now.elapsed().as_secs(); - eprintln!("elapsed seconds: {}", elapsed_secs); + // eprintln!("elapsed seconds: {}", elapsed_secs); let message = "Hello world! sent at : ".to_owned() + &elapsed_secs.clone().to_string() + " seconds."; - if elapsed_secs % 2 == 0 { - dbg!(swarm + // if elapsed_secs % 2 == 0 { + swarm .behaviour_mut() .gossipsub - .publish(gossipsub::IdentTopic::new("universal-connectivity"), message.as_bytes())); - } + .publish(gossipsub::IdentTopic::new("universal-connectivity"), message.as_bytes()); + // } } } From f40128c9b9390843ffcc56a934919b91c10b81b9 Mon Sep 17 00:00:00 2001 From: chad Date: Fri, 24 Mar 2023 17:52:21 -0500 Subject: [PATCH 29/32] forcefully add mesh peers to subscribers in js-gossipsub --- package-lock.json | 13 ++++++------- packages/frontend/package.json | 2 +- packages/frontend/src/components/chat.tsx | 4 ++-- packages/frontend/src/lib/constants.ts | 2 +- packages/frontend/src/lib/libp2p.ts | 1 + 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index a8541192..9d6b081d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -93,8 +93,8 @@ }, "node_modules/@chainsafe/libp2p-gossipsub": { "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-gossipsub/-/libp2p-gossipsub-6.2.0.tgz", - "integrity": "sha512-b3xEgjaatCmzJgNyE7qbTl/JBIymcNWbLUtW1nGA9a0n9Y0IjnNLyUmHH0y3xe22trVTAf6o7qpAdkbXILU9sg==", + "resolved": "git+ssh://git@github.com/maschad/js-libp2p-gossipsub.git#7dfe78394e6ede17ae87d1d7d7f3f2005b16ce1d", + "license": "Apache-2.0", "dependencies": { "@libp2p/crypto": "^1.0.3", "@libp2p/interface-connection": "^3.0.1", @@ -7037,7 +7037,7 @@ "packages/frontend": { "name": "universal-connectivity-browser", "dependencies": { - "@chainsafe/libp2p-gossipsub": "^6.2.0", + "@chainsafe/libp2p-gossipsub": "github:maschad/js-libp2p-gossipsub#fix/add-mesh-peers-to-sub", "@chainsafe/libp2p-noise": "^11.0.0", "@chainsafe/libp2p-yamux": "^3.0.5", "@headlessui/react": "^1.7.13", @@ -7336,9 +7336,8 @@ "integrity": "sha512-nqSJ8u2a1Rv9FYbyI8qpDhTYujaKEyLknNrTejLYoSWmdeg+2WB7R6BZqPZYfrJzDxVi3rl6ZQuoaEvpKRZWgQ==" }, "@chainsafe/libp2p-gossipsub": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-gossipsub/-/libp2p-gossipsub-6.2.0.tgz", - "integrity": "sha512-b3xEgjaatCmzJgNyE7qbTl/JBIymcNWbLUtW1nGA9a0n9Y0IjnNLyUmHH0y3xe22trVTAf6o7qpAdkbXILU9sg==", + "version": "git+ssh://git@github.com/maschad/js-libp2p-gossipsub.git#7dfe78394e6ede17ae87d1d7d7f3f2005b16ce1d", + "from": "@chainsafe/libp2p-gossipsub@github:maschad/js-libp2p-gossipsub#fix/add-mesh-peers-to-sub", "requires": { "@libp2p/crypto": "^1.0.3", "@libp2p/interface-connection": "^3.0.1", @@ -12079,7 +12078,7 @@ "universal-connectivity-browser": { "version": "file:packages/frontend", "requires": { - "@chainsafe/libp2p-gossipsub": "^6.2.0", + "@chainsafe/libp2p-gossipsub": "github:maschad/js-libp2p-gossipsub#fix/add-mesh-peers-to-sub", "@chainsafe/libp2p-noise": "^11.0.0", "@chainsafe/libp2p-yamux": "^3.0.5", "@headlessui/react": "^1.7.13", diff --git a/packages/frontend/package.json b/packages/frontend/package.json index e16c1398..1fc17e45 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -7,7 +7,7 @@ "lint": "next lint" }, "dependencies": { - "@chainsafe/libp2p-gossipsub": "^6.2.0", + "@chainsafe/libp2p-gossipsub": "github:maschad/js-libp2p-gossipsub#fix/add-mesh-peers-to-sub", "@chainsafe/libp2p-noise": "^11.0.0", "@chainsafe/libp2p-yamux": "^3.0.5", "@headlessui/react": "^1.7.13", diff --git a/packages/frontend/src/components/chat.tsx b/packages/frontend/src/components/chat.tsx index 2c0f856a..4b62dc82 100644 --- a/packages/frontend/src/components/chat.tsx +++ b/packages/frontend/src/components/chat.tsx @@ -24,7 +24,7 @@ export default function ChatContainer() { console.log("gossipsub console log", message) const { topic, data } = message.detail const msg = new TextDecoder().decode(data) - console.error(`${topic}: ${msg}`) + console.log(`${topic}: ${msg}`) // Append new message setMessages([...messages, { msg, from: 'other' }]) } @@ -47,7 +47,7 @@ export default function ChatContainer() { CHAT_TOPIC, new TextEncoder().encode(input), ) - console.log('sent message to: ', res) + console.log('sent message to: ', res.recipients.map((peerId) => peerId.toString())) setMessages([...messages, { msg: input, from: 'me' }]) setInput('') diff --git a/packages/frontend/src/lib/constants.ts b/packages/frontend/src/lib/constants.ts index 9c70069c..dd2cf47f 100644 --- a/packages/frontend/src/lib/constants.ts +++ b/packages/frontend/src/lib/constants.ts @@ -1,4 +1,4 @@ -export const CHAT_TOPIC = 'universal-connectivity' +export const CHAT_TOPIC = "universal-connectivity" // export const DEFAULT_APP_PEER = '12D3KooWBdmLJjhpgJ9KZgLM3f894ff9xyBfPvPjFNn7MKJpyrC2' export const DEFAULT_APP_PEER = '12D3KooWRBy97UB99e3J6hiPesre1MZeuNQvfan4gBziswrRJsNK' diff --git a/packages/frontend/src/lib/libp2p.ts b/packages/frontend/src/lib/libp2p.ts index df773bc6..769f8472 100644 --- a/packages/frontend/src/lib/libp2p.ts +++ b/packages/frontend/src/lib/libp2p.ts @@ -72,6 +72,7 @@ export async function startLibp2p(options: {} = {}) { allowPublishToZeroPeers: true, // allowedTopics: [CHAT_TOPIC], msgIdFn: msgIdFnStrictNoSign, + ignoreDuplicatePublishError: true, }), // connectionManager: { // minConnections: 0, From a8c18c84e5dcc6a76d22d3ec5bbd4e7af4d3a3d0 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 27 Mar 2023 08:15:11 -0700 Subject: [PATCH 30/32] reenable webtransport --- packages/frontend/src/lib/libp2p.ts | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/frontend/src/lib/libp2p.ts b/packages/frontend/src/lib/libp2p.ts index 769f8472..679e904a 100644 --- a/packages/frontend/src/lib/libp2p.ts +++ b/packages/frontend/src/lib/libp2p.ts @@ -20,7 +20,7 @@ import { delegatedPeerRouting } from '@libp2p/delegated-peer-routing' import { create as KuboClient } from 'kubo-rpc-client' import { gossipsub } from '@chainsafe/libp2p-gossipsub' import { webSockets } from '@libp2p/websockets' -// import { webTransport } from '@libp2p/webtransport' +import { webTransport } from '@libp2p/webtransport' import { webRTC } from '@libp2p/webrtc' import { PeerId } from 'kubo-rpc-client/dist/src/types' import { CHAT_TOPIC } from './constants' @@ -43,8 +43,8 @@ export async function startLibp2p(options: {} = {}) { const libp2p = await createLibp2p({ // dht: kadDHT(), datastore, - // transports: [webTransport(), webSockets(), webRTC()], - transports: [webRTC()], + transports: [webTransport(), webSockets(), webRTC()], + // transports: [webRTC()], connectionEncryption: [noise()], streamMuxers: [yamux()], // connectionGater: { @@ -138,18 +138,18 @@ export const connectToMultiaddrs = const conns = [] const errs = [] - // for (let multiaddr of publicWebTransportMultiaddrs) { - // multiaddr = addPeerIdToWebTransportMultiAddr(multiaddr, peerId) - // console.log(`dialling: ${multiaddr.toString()}`) - // try { - // const conn = await libp2p.dial(multiaddr) - // conns.push(conn) - // console.info('connected to', conn.remotePeer, 'on', conn.remoteAddr) - // } catch (e) { - // errs.push(e) - // console.error(e) - // } - // } + for (let multiaddr of publicWebTransportMultiaddrs) { + multiaddr = addPeerIdToWebTransportMultiAddr(multiaddr, peerId) + console.log(`dialling: ${multiaddr.toString()}`) + try { + const conn = await libp2p.dial(multiaddr) + conns.push(conn) + console.info('connected to', conn.remotePeer, 'on', conn.remoteAddr) + } catch (e) { + errs.push(e) + console.error(e) + } + } if (conns.length === 0) { throw new Libp2pDialError('Failed to connect to peer', errs) } From 1faaaa5f5dec709011be01d256540b82e958ff28 Mon Sep 17 00:00:00 2001 From: Prithvi Shahi Date: Mon, 27 Mar 2023 11:39:09 -0700 Subject: [PATCH 31/32] revert custom js-libp2p-gossipsub branch --- package-lock.json | 242 +++++++++++++++++++++++----------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9d6b081d..db8e598a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,70 +91,6 @@ "resolved": "https://registry.npmjs.org/@chainsafe/is-ip/-/is-ip-2.0.1.tgz", "integrity": "sha512-nqSJ8u2a1Rv9FYbyI8qpDhTYujaKEyLknNrTejLYoSWmdeg+2WB7R6BZqPZYfrJzDxVi3rl6ZQuoaEvpKRZWgQ==" }, - "node_modules/@chainsafe/libp2p-gossipsub": { - "version": "6.2.0", - "resolved": "git+ssh://git@github.com/maschad/js-libp2p-gossipsub.git#7dfe78394e6ede17ae87d1d7d7f3f2005b16ce1d", - "license": "Apache-2.0", - "dependencies": { - "@libp2p/crypto": "^1.0.3", - "@libp2p/interface-connection": "^3.0.1", - "@libp2p/interface-connection-manager": "^1.3.0", - "@libp2p/interface-keys": "^1.0.3", - "@libp2p/interface-peer-id": "^2.0.0", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-pubsub": "^3.0.0", - "@libp2p/interface-registrar": "^2.0.3", - "@libp2p/interfaces": "^3.2.0", - "@libp2p/logger": "^2.0.0", - "@libp2p/peer-id": "^2.0.0", - "@libp2p/peer-record": "^5.0.0", - "@libp2p/pubsub": "^6.0.0", - "@libp2p/topology": "^4.0.0", - "@multiformats/multiaddr": "^11.0.0", - "abortable-iterator": "^4.0.2", - "denque": "^1.5.0", - "it-length-prefixed": "^8.0.2", - "it-pipe": "^2.0.4", - "it-pushable": "^3.1.0", - "multiformats": "^11.0.0", - "protobufjs": "^6.11.2", - "uint8arraylist": "^2.3.2", - "uint8arrays": "^4.0.2" - }, - "engines": { - "npm": ">=8.7.0" - } - }, - "node_modules/@chainsafe/libp2p-gossipsub/node_modules/long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, - "node_modules/@chainsafe/libp2p-gossipsub/node_modules/protobufjs": { - "version": "6.11.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", - "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", - "hasInstallScript": true, - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": ">=13.7.0", - "long": "^4.0.0" - }, - "bin": { - "pbjs": "bin/pbjs", - "pbts": "bin/pbts" - } - }, "node_modules/@chainsafe/libp2p-noise": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-noise/-/libp2p-noise-11.0.1.tgz", @@ -7073,6 +7009,70 @@ "tailwindcss": "^3.2.7" } }, + "packages/frontend/node_modules/@chainsafe/libp2p-gossipsub": { + "version": "6.2.0", + "resolved": "git+ssh://git@github.com/maschad/js-libp2p-gossipsub.git#7dfe78394e6ede17ae87d1d7d7f3f2005b16ce1d", + "license": "Apache-2.0", + "dependencies": { + "@libp2p/crypto": "^1.0.3", + "@libp2p/interface-connection": "^3.0.1", + "@libp2p/interface-connection-manager": "^1.3.0", + "@libp2p/interface-keys": "^1.0.3", + "@libp2p/interface-peer-id": "^2.0.0", + "@libp2p/interface-peer-store": "^1.2.2", + "@libp2p/interface-pubsub": "^3.0.0", + "@libp2p/interface-registrar": "^2.0.3", + "@libp2p/interfaces": "^3.2.0", + "@libp2p/logger": "^2.0.0", + "@libp2p/peer-id": "^2.0.0", + "@libp2p/peer-record": "^5.0.0", + "@libp2p/pubsub": "^6.0.0", + "@libp2p/topology": "^4.0.0", + "@multiformats/multiaddr": "^11.0.0", + "abortable-iterator": "^4.0.2", + "denque": "^1.5.0", + "it-length-prefixed": "^8.0.2", + "it-pipe": "^2.0.4", + "it-pushable": "^3.1.0", + "multiformats": "^11.0.0", + "protobufjs": "^6.11.2", + "uint8arraylist": "^2.3.2", + "uint8arrays": "^4.0.2" + }, + "engines": { + "npm": ">=8.7.0" + } + }, + "packages/frontend/node_modules/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, + "packages/frontend/node_modules/protobufjs": { + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", + "hasInstallScript": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.1", + "@types/node": ">=13.7.0", + "long": "^4.0.0" + }, + "bin": { + "pbjs": "bin/pbjs", + "pbts": "bin/pbts" + } + }, "packages/nextjs": { "name": "universal-connectivity-browser", "extraneous": true, @@ -7335,63 +7335,6 @@ "resolved": "https://registry.npmjs.org/@chainsafe/is-ip/-/is-ip-2.0.1.tgz", "integrity": "sha512-nqSJ8u2a1Rv9FYbyI8qpDhTYujaKEyLknNrTejLYoSWmdeg+2WB7R6BZqPZYfrJzDxVi3rl6ZQuoaEvpKRZWgQ==" }, - "@chainsafe/libp2p-gossipsub": { - "version": "git+ssh://git@github.com/maschad/js-libp2p-gossipsub.git#7dfe78394e6ede17ae87d1d7d7f3f2005b16ce1d", - "from": "@chainsafe/libp2p-gossipsub@github:maschad/js-libp2p-gossipsub#fix/add-mesh-peers-to-sub", - "requires": { - "@libp2p/crypto": "^1.0.3", - "@libp2p/interface-connection": "^3.0.1", - "@libp2p/interface-connection-manager": "^1.3.0", - "@libp2p/interface-keys": "^1.0.3", - "@libp2p/interface-peer-id": "^2.0.0", - "@libp2p/interface-peer-store": "^1.2.2", - "@libp2p/interface-pubsub": "^3.0.0", - "@libp2p/interface-registrar": "^2.0.3", - "@libp2p/interfaces": "^3.2.0", - "@libp2p/logger": "^2.0.0", - "@libp2p/peer-id": "^2.0.0", - "@libp2p/peer-record": "^5.0.0", - "@libp2p/pubsub": "^6.0.0", - "@libp2p/topology": "^4.0.0", - "@multiformats/multiaddr": "^11.0.0", - "abortable-iterator": "^4.0.2", - "denque": "^1.5.0", - "it-length-prefixed": "^8.0.2", - "it-pipe": "^2.0.4", - "it-pushable": "^3.1.0", - "multiformats": "^11.0.0", - "protobufjs": "^6.11.2", - "uint8arraylist": "^2.3.2", - "uint8arrays": "^4.0.2" - }, - "dependencies": { - "long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, - "protobufjs": { - "version": "6.11.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", - "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", - "requires": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/long": "^4.0.1", - "@types/node": ">=13.7.0", - "long": "^4.0.0" - } - } - } - }, "@chainsafe/libp2p-noise": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-noise/-/libp2p-noise-11.0.1.tgz", @@ -12110,6 +12053,63 @@ "tailwindcss": "^3.2.7", "typescript": "4.9.5", "usehooks-ts": "^2.9.1" + }, + "dependencies": { + "@chainsafe/libp2p-gossipsub": { + "version": "git+ssh://git@github.com/maschad/js-libp2p-gossipsub.git#7dfe78394e6ede17ae87d1d7d7f3f2005b16ce1d", + "from": "@chainsafe/libp2p-gossipsub@github:maschad/js-libp2p-gossipsub#fix/add-mesh-peers-to-sub", + "requires": { + "@libp2p/crypto": "^1.0.3", + "@libp2p/interface-connection": "^3.0.1", + "@libp2p/interface-connection-manager": "^1.3.0", + "@libp2p/interface-keys": "^1.0.3", + "@libp2p/interface-peer-id": "^2.0.0", + "@libp2p/interface-peer-store": "^1.2.2", + "@libp2p/interface-pubsub": "^3.0.0", + "@libp2p/interface-registrar": "^2.0.3", + "@libp2p/interfaces": "^3.2.0", + "@libp2p/logger": "^2.0.0", + "@libp2p/peer-id": "^2.0.0", + "@libp2p/peer-record": "^5.0.0", + "@libp2p/pubsub": "^6.0.0", + "@libp2p/topology": "^4.0.0", + "@multiformats/multiaddr": "^11.0.0", + "abortable-iterator": "^4.0.2", + "denque": "^1.5.0", + "it-length-prefixed": "^8.0.2", + "it-pipe": "^2.0.4", + "it-pushable": "^3.1.0", + "multiformats": "^11.0.0", + "protobufjs": "^6.11.2", + "uint8arraylist": "^2.3.2", + "uint8arrays": "^4.0.2" + } + }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, + "protobufjs": { + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", + "requires": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.1", + "@types/node": ">=13.7.0", + "long": "^4.0.0" + } + } } }, "universal-connectivity-node": { From 4756648e65694eeadc0acb0933b5fe790058d069 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Wed, 29 Mar 2023 15:41:46 +0200 Subject: [PATCH 32/32] Fix missing SUBSCRIBE and refactor Depend on latest commits on https://github.com/libp2p/rust-libp2p/pull/3625 more specifically https://github.com/libp2p/rust-libp2p/pull/3625/commits/b5728952464f570c5636f5e6a4fa2448e28f3cbe resolving the missing SUBSCRIBE message previously not send by a rust-libp2p server. Additional refactorings: - Use clap to parse command line arguments. Among other things gives us nice help text and better error messages. - Depend on `libp2p-webrtc` directly as we will remove the re-export from `libp2p`. - Use `futures-timer` to send `Hello World` on a 2 second interval instead of on each `SwarmEvent`. - Redo logging on various levels (warn, info, debug). --- rust-server/Cargo.lock | 102 ++++++++++++++++++++++++++---------- rust-server/Cargo.toml | 4 ++ rust-server/src/main.rs | 111 ++++++++++++++++++++++++++++------------ 3 files changed, 155 insertions(+), 62 deletions(-) diff --git a/rust-server/Cargo.lock b/rust-server/Cargo.lock index 0e18e011..0efa71a5 100644 --- a/rust-server/Cargo.lock +++ b/rust-server/Cargo.lock @@ -278,7 +278,7 @@ checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.4", + "syn 2.0.10", ] [[package]] @@ -494,6 +494,42 @@ dependencies = [ "inout", ] +[[package]] +name = "clap" +version = "4.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "is-terminal", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a932373bab67b984c790ddf2c9ca295d8e3af3b7ef92de5a5bacdccdee4b09b" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.10", +] + +[[package]] +name = "clap_lex" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "concurrent-queue" version = "2.1.0" @@ -1434,7 +1470,7 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "libp2p" version = "0.51.2" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "bytes", "futures", @@ -1463,7 +1499,7 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "libp2p-core", "libp2p-identity", @@ -1474,7 +1510,7 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "libp2p-core", "libp2p-identity", @@ -1485,7 +1521,7 @@ dependencies = [ [[package]] name = "libp2p-core" version = "0.39.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "either", "fnv", @@ -1512,7 +1548,7 @@ dependencies = [ [[package]] name = "libp2p-dns" version = "0.39.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "futures", "libp2p-core", @@ -1526,7 +1562,7 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" version = "0.44.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "asynchronous-codec", "base64 0.21.0", @@ -1556,7 +1592,7 @@ dependencies = [ [[package]] name = "libp2p-identify" version = "0.42.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "asynchronous-codec", "either", @@ -1577,7 +1613,7 @@ dependencies = [ [[package]] name = "libp2p-identity" version = "0.1.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "asn1_der", "bs58", @@ -1596,7 +1632,7 @@ dependencies = [ [[package]] name = "libp2p-kad" version = "0.43.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "arrayvec", "asynchronous-codec", @@ -1623,7 +1659,7 @@ dependencies = [ [[package]] name = "libp2p-mdns" version = "0.43.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "data-encoding", "futures", @@ -1643,7 +1679,7 @@ dependencies = [ [[package]] name = "libp2p-metrics" version = "0.12.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "libp2p-core", "libp2p-gossipsub", @@ -1658,7 +1694,7 @@ dependencies = [ [[package]] name = "libp2p-noise" version = "0.42.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -1680,7 +1716,7 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.42.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "either", "futures", @@ -1697,7 +1733,7 @@ dependencies = [ [[package]] name = "libp2p-quic" version = "0.7.0-alpha.3" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "bytes", "futures", @@ -1718,7 +1754,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" version = "0.42.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "either", "fnv", @@ -1738,17 +1774,17 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" version = "0.32.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "heck", "quote", - "syn 2.0.4", + "syn 2.0.10", ] [[package]] name = "libp2p-tcp" version = "0.39.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "futures", "futures-timer", @@ -1764,7 +1800,7 @@ dependencies = [ [[package]] name = "libp2p-tls" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "futures", "futures-rustls", @@ -1782,7 +1818,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc" version = "0.4.0-alpha.4" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "async-trait", "asynchronous-codec", @@ -1971,7 +2007,7 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.12.1" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "bytes", "futures", @@ -2139,6 +2175,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "os_str_bytes" +version = "6.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" + [[package]] name = "p256" version = "0.11.1" @@ -2467,7 +2509,7 @@ dependencies = [ [[package]] name = "quick-protobuf-codec" version = "0.1.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "asynchronous-codec", "bytes", @@ -2706,9 +2748,13 @@ name = "rust-libp2p-webrtc-server" version = "0.1.0" dependencies = [ "anyhow", + "clap", "env_logger", "futures", + "futures-timer", "libp2p", + "libp2p-webrtc", + "log", "rand 0.8.5", "tokio", "tokio-util", @@ -2781,7 +2827,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.3.0" -source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#e28af538318c146d5b19ab7098d9e0017c356ec8" +source = "git+https://github.com/vnermolaev/rust-libp2p.git?branch=deprecate/gossipsub-close-event#b5728952464f570c5636f5e6a4fa2448e28f3cbe" dependencies = [ "futures", "pin-project", @@ -2869,7 +2915,7 @@ checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.4", + "syn 2.0.10", ] [[package]] @@ -3067,9 +3113,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.4" +version = "2.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c622ae390c9302e214c31013517c2061ecb2699935882c60a9b37f82f8625ae" +checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" dependencies = [ "proc-macro2", "quote", @@ -3135,7 +3181,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.4", + "syn 2.0.10", ] [[package]] diff --git a/rust-server/Cargo.toml b/rust-server/Cargo.toml index 43143c3f..eb87bb95 100644 --- a/rust-server/Cargo.toml +++ b/rust-server/Cargo.toml @@ -7,9 +7,13 @@ edition = "2021" [dependencies] anyhow = "1.0" +clap = { version = "4.1.11", features = ["derive"] } env_logger = "0.10.0" futures = "0.3.27" +futures-timer = "3.0.2" libp2p = {git = "https://github.com/vnermolaev/rust-libp2p.git", branch = "deprecate/gossipsub-close-event", version="0.51.2", features = ["identify", "ping", "tokio", "gossipsub", "webrtc", "macros", "kad", "rsa", "ed25519"]} +libp2p-webrtc = {git = "https://github.com/vnermolaev/rust-libp2p.git", branch = "deprecate/gossipsub-close-event", version="0.4.0-alpha.4", features = ["tokio"] } +log = "0.4.17" rand = "0.8.5" tokio = { version= "1.26.0", features=["full"] } tokio-util = { version = "0.7", features = ["full"] } diff --git a/rust-server/src/main.rs b/rust-server/src/main.rs index 4a732cf5..9bb9753f 100644 --- a/rust-server/src/main.rs +++ b/rust-server/src/main.rs @@ -1,4 +1,5 @@ use anyhow::Result; +use clap::Parser; use futures::StreamExt; use libp2p::{ core::muxing::StreamMuxerBox, @@ -6,51 +7,93 @@ use libp2p::{ multiaddr::Protocol, ping, swarm::{keep_alive, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent}, - webrtc, Multiaddr, PeerId, Transport, + Multiaddr, PeerId, Transport, }; +use libp2p_webrtc as webrtc; +use log::{debug, error, info, warn}; use rand::thread_rng; -use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; -use std::io; -use std::time::{Duration, Instant}; +use std::time::Instant; +use std::{collections::hash_map::DefaultHasher, time::Duration}; +const TICK_INTERVAL: Duration = Duration::from_secs(5); + +#[derive(Debug, Parser)] +#[clap(name = "universal connectivity rust server")] +struct Opt { + /// Address of a remote peer to connect to. + #[clap(long)] + remote_address: Option, +} /// An example WebRTC server that will accept connections #[tokio::main] async fn main() -> Result<()> { - env_logger::init(); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); + + let opt = Opt::parse(); let mut swarm = create_swarm()?; swarm.listen_on(format!("/ip4/127.0.0.1/udp/0/webrtc").parse()?)?; + if let Some(remote_address) = opt.remote_address { + swarm.dial(remote_address).unwrap(); + } + + let mut tick = futures_timer::Delay::new(TICK_INTERVAL); + let now = Instant::now(); loop { - let event = swarm.next().await.unwrap(); - eprintln!("New event: {event:?}"); - match event { - SwarmEvent::NewListenAddr { address, .. } => { - let p2p_address = address.with(Protocol::P2p((*swarm.local_peer_id()).into())); - eprintln!("p2p address: {p2p_address:?}") + match futures::future::select(swarm.next(), &mut tick).await { + futures::future::Either::Left((event, _)) => match event.unwrap() { + SwarmEvent::NewListenAddr { address, .. } => { + let p2p_address = address.with(Protocol::P2p((*swarm.local_peer_id()).into())); + info!("Listen address: {p2p_address:?}") + } + SwarmEvent::ConnectionEstablished { peer_id, .. } => { + info!("Connected to {peer_id}"); + } + SwarmEvent::OutgoingConnectionError { peer_id, error } => { + warn!("Failed to dial {peer_id:?}: {error}"); + } + SwarmEvent::ConnectionClosed { peer_id, cause, .. } => { + warn!("Connection to {peer_id} closed: {cause:?}"); + } + SwarmEvent::Behaviour(BehaviourEvent::Gossipsub( + libp2p::gossipsub::Event::Message { + message_id: _, + propagation_source: _, + message, + }, + )) => { + info!( + "Received message from {:?}: {}", + message.source, + String::from_utf8(message.data).unwrap() + ); + } + SwarmEvent::Behaviour(BehaviourEvent::Gossipsub( + libp2p::gossipsub::Event::Subscribed { peer_id, topic }, + )) => { + info!("{peer_id} subscribed to {topic}"); + } + event => { + debug!("{event:?}"); + } }, - _ => {} + futures::future::Either::Right(_) => { + tick = futures_timer::Delay::new(TICK_INTERVAL); + + let message = format!("Hello world! Sent at: {:4}s", now.elapsed().as_secs_f64()); + + if let Err(err) = swarm.behaviour_mut().gossipsub.publish( + gossipsub::IdentTopic::new("universal-connectivity"), + message.as_bytes(), + ) { + error!("Failed to publish periodic message: {err}") + } + } } - // let peers: Vec<_> = swarm.behaviour().gossipsub.all_peers().collect(); - // eprintln!("Peers: {peers:?}"); - // let peers: Vec<_> = swarm.behaviour().gossipsub.all_mesh_peers().collect(); - // eprintln!("Mesh peers: {peers:?}"); - - - let elapsed_secs = now.elapsed().as_secs(); - // eprintln!("elapsed seconds: {}", elapsed_secs); - - let message = "Hello world! sent at : ".to_owned() + &elapsed_secs.clone().to_string() + " seconds."; - - // if elapsed_secs % 2 == 0 { - swarm - .behaviour_mut() - .gossipsub - .publish(gossipsub::IdentTopic::new("universal-connectivity"), message.as_bytes()); - // } } } @@ -66,7 +109,7 @@ struct Behaviour { fn create_swarm() -> Result> { let local_key = identity::Keypair::generate_ed25519(); let local_peer_id = PeerId::from(local_key.public()); - println!("Local peer id: {local_peer_id}"); + debug!("Local peer id: {local_peer_id}"); // To content-address message, we can take the hash of message and use it as an ID. let message_id_fn = |message: &gossipsub::Message| { @@ -103,10 +146,10 @@ fn create_swarm() -> Result> { webrtc::tokio::Certificate::generate(&mut thread_rng())?, ); - let identify_config = identify::Behaviour::new(identify::Config::new( - "/ipfs/0.1.0".into(), - local_key.public().clone(), - )); + let identify_config = identify::Behaviour::new( + identify::Config::new("/ipfs/0.1.0".into(), local_key.public().clone()) + .with_initial_delay(Duration::ZERO), + ); let transport = transport .map(|(local_peer_id, conn), _| (local_peer_id, StreamMuxerBox::new(conn)))