diff --git a/Cargo.lock b/Cargo.lock index 4e370cbd1..f90eb8c52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,6 +209,12 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "ark-bls12-377" version = "0.4.0" @@ -538,14 +544,30 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[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 0.1.0", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + [[package]] name = "asn1-rs" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", + "asn1-rs-derive 0.5.0", + "asn1-rs-impl 0.2.0", "displaydoc", "nom", "num-traits", @@ -554,6 +576,18 @@ dependencies = [ "time", ] +[[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 0.12.6", +] + [[package]] name = "asn1-rs-derive" version = "0.5.0" @@ -563,7 +597,18 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.68", - "synstructure", + "synstructure 0.13.1", +] + +[[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]] @@ -1027,6 +1072,7 @@ dependencies = [ "libc", "libp2p", "libp2p-allow-block-list", + "libp2p-webrtc", "mockall", "multihash 0.14.0", "num", @@ -1461,6 +1507,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "blocking" version = "1.6.1" @@ -1551,6 +1606,15 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.0.104" @@ -1562,6 +1626,18 @@ dependencies = [ "once_cell", ] +[[package]] +name = "ccm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae3c82e4355234767756212c570e29833699ab63e6ffd161887314cc5b43847" +dependencies = [ + "aead", + "cipher", + "ctr", + "subtle", +] + [[package]] name = "cexpr" version = "0.6.0" @@ -1908,6 +1984,21 @@ dependencies = [ "serde", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.2" @@ -2165,16 +2256,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] +[[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 = "der-parser" version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" dependencies = [ - "asn1-rs", + "asn1-rs 0.6.1", "displaydoc", "nom", "num-bigint", @@ -2549,6 +2655,8 @@ dependencies = [ "ff", "generic-array 0.14.7", "group", + "hkdf", + "pem-rfc7468", "pkcs8", "rand_core 0.6.4", "sec1", @@ -3890,6 +3998,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ + "block-padding 0.3.3", "generic-array 0.14.7", ] @@ -3911,6 +4020,25 @@ dependencies = [ "num-traits", ] +[[package]] +name = "interceptor" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5927883184e6a819b22d5e4f5f7bc7ca134fde9b2026fbddd8d95249746ba21e" +dependencies = [ + "async-trait", + "bytes", + "log", + "rand 0.8.5", + "rtcp", + "rtp 0.9.0", + "thiserror", + "tokio", + "waitgroup", + "webrtc-srtp", + "webrtc-util", +] + [[package]] name = "io-lifetimes" version = "1.0.11" @@ -4705,7 +4833,7 @@ dependencies = [ "rustls 0.23.10", "rustls-webpki 0.101.7", "thiserror", - "x509-parser", + "x509-parser 0.16.0", "yasna", ] @@ -4725,6 +4853,58 @@ dependencies = [ "void", ] +[[package]] +name = "libp2p-webrtc" +version = "0.7.1-alpha" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9af8ced4eb617353ebf941724be74564c99fa2e0a42a54e8009bcd97613b08c" +dependencies = [ + "async-trait", + "bytes", + "futures", + "futures-timer", + "hex", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-noise", + "libp2p-webrtc-utils", + "multihash 0.19.1", + "rand 0.8.5", + "rcgen", + "serde", + "stun", + "thiserror", + "tinytemplate", + "tokio", + "tokio-util", + "tracing", + "webrtc", +] + +[[package]] +name = "libp2p-webrtc-utils" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95eb35ba4991eab0284c2fc2d535b0a53fe10005001284c89f3cb01c5b0e1249" +dependencies = [ + "asynchronous-codec 0.7.0", + "bytes", + "futures", + "hex", + "libp2p-core", + "libp2p-identity", + "libp2p-noise", + "quick-protobuf", + "quick-protobuf-codec 0.3.1", + "rand 0.8.5", + "serde", + "sha2 0.10.8", + "thiserror", + "tinytemplate", + "tracing", +] + [[package]] name = "libp2p-websocket" version = "0.43.0" @@ -5019,6 +5199,16 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if 1.0.0", + "digest 0.10.7", +] + [[package]] name = "memchr" version = "2.7.4" @@ -5034,6 +5224,15 @@ dependencies = [ "rustix 0.38.34", ] +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.8.0" @@ -5308,6 +5507,19 @@ dependencies = [ "libc", ] +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if 1.0.0", + "libc", + "memoffset 0.7.1", + "pin-utils", +] + [[package]] name = "no-std-net" version = "0.6.0" @@ -5503,13 +5715,22 @@ dependencies = [ "memchr", ] +[[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 = "oid-registry" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" dependencies = [ - "asn1-rs", + "asn1-rs 0.6.1", ] [[package]] @@ -5613,6 +5834,30 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + +[[package]] +name = "p384" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70786f51bcc69f6a4c0360e063a4cac5419ef7c5cd5b3c99ad70f3be5ba79209" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -5730,6 +5975,15 @@ dependencies = [ "serde", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -5938,6 +6192,15 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -6325,6 +6588,7 @@ dependencies = [ "pem", "ring 0.16.20", "time", + "x509-parser 0.15.1", "yasna", ] @@ -6488,6 +6752,17 @@ dependencies = [ "librocksdb-sys", ] +[[package]] +name = "rtcp" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33648a781874466a62d89e265fee9f17e32bc7d05a256e6cca41bf97eadcd8aa" +dependencies = [ + "bytes", + "thiserror", + "webrtc-util", +] + [[package]] name = "rtnetlink" version = "0.10.1" @@ -6498,11 +6773,37 @@ dependencies = [ "log", "netlink-packet-route", "netlink-proto", - "nix", + "nix 0.24.3", "thiserror", "tokio", ] +[[package]] +name = "rtp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e60482acbe8afb31edf6b1413103b7bca7a65004c423b3c3993749a083994fbe" +dependencies = [ + "bytes", + "rand 0.8.5", + "serde", + "thiserror", + "webrtc-util", +] + +[[package]] +name = "rtp" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47fca9bd66ae0b1f3f649b8f5003d6176433d7293b78b0fce7e1031816bdd99d" +dependencies = [ + "bytes", + "rand 0.8.5", + "serde", + "thiserror", + "webrtc-util", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -6951,6 +7252,18 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "sdp" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13254db766b17451aced321e7397ebf0a446ef0c8d2942b6e67a95815421093f" +dependencies = [ + "rand 0.8.5", + "substring", + "thiserror", + "url", +] + [[package]] name = "sec1" version = "0.7.3" @@ -7267,6 +7580,15 @@ dependencies = [ "futures-lite 2.3.0", ] +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + [[package]] name = "smoldot" version = "0.16.0" @@ -8258,6 +8580,25 @@ dependencies = [ "syn 2.0.68", ] +[[package]] +name = "stun" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3f371788132e9d623e6eab4ba28aac083763a4133f045e6ebaee5ceb869803d" +dependencies = [ + "base64 0.21.7", + "crc", + "lazy_static", + "md-5", + "rand 0.8.5", + "ring 0.17.8", + "subtle", + "thiserror", + "tokio", + "url", + "webrtc-util", +] + [[package]] name = "substrate-bip39" version = "0.4.6" @@ -8283,6 +8624,15 @@ dependencies = [ "tokio", ] +[[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.6.1" @@ -8447,6 +8797,18 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +[[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 = "synstructure" version = "0.13.1" @@ -8694,6 +9056,16 @@ dependencies = [ "crunchy", ] +[[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.1" @@ -9118,6 +9490,26 @@ dependencies = [ "utf-8", ] +[[package]] +name = "turn" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb2ac4f331064513ad510b7a36edc0df555bd61672986607f7c9ff46f98f415" +dependencies = [ + "async-trait", + "base64 0.21.7", + "futures", + "log", + "md-5", + "rand 0.8.5", + "ring 0.17.8", + "stun", + "thiserror", + "tokio", + "tokio-util", + "webrtc-util", +] + [[package]] name = "twox-hash" version = "1.6.3" @@ -9375,6 +9767,15 @@ dependencies = [ "libc", ] +[[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.2.0" @@ -9667,7 +10068,7 @@ dependencies = [ "log", "mach", "memfd", - "memoffset", + "memoffset 0.8.0", "paste", "rand 0.8.5", "rustix 0.36.17", @@ -9724,6 +10125,209 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "webrtc" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91e7cf018f7185552bf6a5dd839f4ed9827aea33b746763c9a215f84a0d0b34" +dependencies = [ + "arc-swap", + "async-trait", + "bytes", + "cfg-if 1.0.0", + "hex", + "interceptor", + "lazy_static", + "log", + "rand 0.8.5", + "rcgen", + "regex", + "ring 0.16.20", + "rtcp", + "rtp 0.9.0", + "rustls 0.21.12", + "sdp", + "serde", + "serde_json", + "sha2 0.10.8", + "smol_str", + "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.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c08e648e10572b9edbe741074e0f4d3cb221aa7cdf9a814ee71606de312f33" +dependencies = [ + "bytes", + "log", + "thiserror", + "tokio", + "webrtc-sctp", + "webrtc-util", +] + +[[package]] +name = "webrtc-dtls" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b140b953f986e97828aa33ec6318186b05d862bee689efbc57af04a243e832" +dependencies = [ + "aes", + "aes-gcm", + "async-trait", + "bincode", + "byteorder", + "cbc", + "ccm", + "der-parser 8.2.0", + "hkdf", + "hmac 0.12.1", + "log", + "p256", + "p384", + "rand 0.8.5", + "rand_core 0.6.4", + "rcgen", + "ring 0.16.20", + "rustls 0.21.12", + "sec1", + "serde", + "sha1", + "sha2 0.10.8", + "subtle", + "thiserror", + "tokio", + "webrtc-util", + "x25519-dalek", + "x509-parser 0.15.1", +] + +[[package]] +name = "webrtc-ice" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1bbd6b3dea22cc6e961e22b012e843d8869e2ac8e76b96e54d4a25e311857ad" +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.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce981f93104a8debb3563bb0cedfe4aa2f351fdf6b53f346ab50009424125c08" +dependencies = [ + "log", + "socket2 0.5.7", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-media" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "280017b6b9625ef7329146332518b339c3cceff231cc6f6a9e0e6acab25ca4af" +dependencies = [ + "byteorder", + "bytes", + "rand 0.8.5", + "rtp 0.10.0", + "thiserror", +] + +[[package]] +name = "webrtc-sctp" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df75ec042002fe995194712cbeb2029107a60a7eab646f1b789eb1be94d0e367" +dependencies = [ + "arc-swap", + "async-trait", + "bytes", + "crc", + "log", + "rand 0.8.5", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-srtp" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1db1f36c1c81e4b1e531c0b9678ba0c93809e196ce62122d87259bb71c03b9f" +dependencies = [ + "aead", + "aes", + "aes-gcm", + "byteorder", + "bytes", + "ctr", + "hmac 0.12.1", + "log", + "rtcp", + "rtp 0.9.0", + "sha1", + "subtle", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-util" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e85154ef743d9a2a116d104faaaa82740a281b8b4bed5ee691a2df6c133d873" +dependencies = [ + "async-trait", + "bitflags 1.3.2", + "bytes", + "ipnet", + "lazy_static", + "libc", + "log", + "nix 0.26.4", + "rand 0.8.5", + "thiserror", + "tokio", + "winapi", +] + [[package]] name = "widestring" version = "1.1.0" @@ -10096,18 +10700,36 @@ dependencies = [ "zeroize", ] +[[package]] +name = "x509-parser" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" +dependencies = [ + "asn1-rs 0.5.2", + "data-encoding", + "der-parser 8.2.0", + "lazy_static", + "nom", + "oid-registry 0.6.1", + "ring 0.16.20", + "rusticata-macros", + "thiserror", + "time", +] + [[package]] name = "x509-parser" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" dependencies = [ - "asn1-rs", + "asn1-rs 0.6.1", "data-encoding", - "der-parser", + "der-parser 9.0.0", "lazy_static", "nom", - "oid-registry", + "oid-registry 0.7.0", "rusticata-macros", "thiserror", "time", diff --git a/client/README.md b/client/README.md index fed315c3f..e8fc760ed 100644 --- a/client/README.md +++ b/client/README.md @@ -159,8 +159,10 @@ http_server_port = 7007 # If set to key, a valid ed25519 private key must be provided, else the client will fail # If `secret_key` is not set, random seed will be used. secret_key = { seed={seed} } -# P2P service port (default: 37000). +# P2P TCP listener port (default: 37000). port = 37000 +# P2P WebRTC listener port (default: 37001). +webrtc_port = 37001 # Configures AutoNAT behaviour to reject probes as a server for clients that are observed at a non-global ip address (default: false) autonat_only_global_ips = false # AutoNat throttle period for re-using a peer as server for a dial-request. (default: 1s) diff --git a/client/src/cli.rs b/client/src/cli.rs index 678276eab..369c0696f 100644 --- a/client/src/cli.rs +++ b/client/src/cli.rs @@ -30,6 +30,9 @@ pub struct CliOpts { /// P2P port #[arg(short, long)] pub port: Option, + /// P2P WebRTC port + #[arg(short, long)] + pub webrtc_port: Option, /// HTTP port #[arg(long)] pub http_server_port: Option, diff --git a/client/src/main.rs b/client/src/main.rs index d3a8ddc1d..a3b53957d 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -124,12 +124,20 @@ async fn run( cfg.libp2p.kademlia.kad_record_ttl, ); - // Start listening on provided port + let addrs = vec![ + cfg.libp2p.tcp_multiaddress(), + cfg.libp2p.webrtc_multiaddress(), + ]; + + // Start the TCP and WebRTC listeners p2p_client - .start_listening(cfg.libp2p.multiaddress()) + .start_listening(addrs) .await - .wrap_err("Listening on TCP not to fail.")?; - info!("TCP listener started on port {}", cfg.libp2p.port); + .wrap_err("Error starting li.")?; + info!( + "TCP listener started on port {}. WebRTC listening on port {}.", + cfg.libp2p.port, cfg.libp2p.webrtc_port + ); let p2p_clone = p2p_client.to_owned(); let cfg_clone = cfg.to_owned(); @@ -409,11 +417,11 @@ async fn run_fat( cfg.libp2p.kademlia.kad_record_ttl, ); - // Start listening on provided port + // Start listening on P2P port p2p_client - .start_listening(cfg.libp2p.multiaddress()) + .start_listening(vec![cfg.libp2p.tcp_multiaddress()]) .await - .wrap_err("Listening on TCP not to fail.")?; + .wrap_err("Error starting listeners.")?; info!("TCP listener started on port {}", cfg.libp2p.port); let p2p_clone = p2p_client.to_owned(); @@ -554,6 +562,9 @@ pub fn load_runtime_config(opts: &CliOpts) -> Result { if let Some(http_port) = opts.http_server_port { cfg.api.http_server_port = http_port; } + if let Some(webrtc_port) = opts.webrtc_port { + cfg.libp2p.webrtc_port = webrtc_port; + } if let Some(avail_path) = &opts.avail_path { cfg.avail_path = avail_path.to_string(); } diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index c617a97cd..8890115c0 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -2,6 +2,7 @@ ## [1.12.0] +- Add `WebRTC` listener with config parameter and CLI option for port setting - Remove old crate patches that were required when `subxt` was directly used - Dial peer at mdns step to trigger identify - Update expected system version to 2.2 diff --git a/core/Cargo.toml b/core/Cargo.toml index c8b2dc057..b16935dc4 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -33,6 +33,7 @@ jsonrpsee-core = { version = "0.21.0", features = ["client"] } libc = "0.2.150" libp2p = { workspace = true } libp2p-allow-block-list = { workspace = true } +libp2p-webrtc = { version = "=0.7.1-alpha", features = ["tokio"] } mockall = "0.11.3" multihash = { workspace = true } num = "0.4.0" diff --git a/core/src/network/p2p.rs b/core/src/network/p2p.rs index c5bf85d34..466476c9a 100644 --- a/core/src/network/p2p.rs +++ b/core/src/network/p2p.rs @@ -9,7 +9,9 @@ use libp2p::{ swarm::NetworkBehaviour, tcp, upnp, yamux, Multiaddr, PeerId, Swarm, SwarmBuilder, }; +use libp2p_webrtc as webrtc; use multihash::{self, Hasher}; +use rand::thread_rng; use semver::Version; use serde::{Deserialize, Serialize}; use std::{fmt, net::Ipv4Addr, str::FromStr}; @@ -234,6 +236,12 @@ async fn build_swarm( noise::Config::new, yamux::Config::default, )? + .with_other_transport(|id_keys| { + Ok(webrtc::tokio::Transport::new( + id_keys.clone(), + webrtc::tokio::Certificate::generate(&mut thread_rng())?, + )) + })? .with_dns()? .with_relay_client(noise::Config::new, yamux::Config::default)? .with_behaviour(behaviour)? diff --git a/core/src/network/p2p/client.rs b/core/src/network/p2p/client.rs index ea06dc4dc..a822b4bf8 100644 --- a/core/src/network/p2p/client.rs +++ b/core/src/network/p2p/client.rs @@ -110,12 +110,15 @@ impl Client { .wrap_err("sender should not be dropped")? } - pub async fn start_listening(&self, addr: Multiaddr) -> Result { + pub async fn start_listening(&self, addrs: Vec) -> Result> { self.execute_sync(|response_sender| { Box::new(move |context: &mut EventLoop| { - let result = context.swarm.listen_on(addr.clone()); + let results: Result, _> = addrs + .into_iter() + .map(|addr| context.swarm.listen_on(addr)) + .collect(); response_sender - .send(result.map_err(Into::into)) + .send(results.map_err(Into::into)) .map_err(|e| { eyre!("Encountered error while sending Start Listening response: {e:?}") })?; diff --git a/core/src/network/p2p/configuration.rs b/core/src/network/p2p/configuration.rs index 750b44610..10599c237 100644 --- a/core/src/network/p2p/configuration.rs +++ b/core/src/network/p2p/configuration.rs @@ -124,8 +124,11 @@ pub struct LibP2PConfig { /// If set to key, a valid ed25519 private key must be provided, else the client will fail /// If `secret_key` is not set, random seed will be used. pub secret_key: Option, - /// P2P service port (default: 37000). + /// P2P TCP listener port (default: 37000). pub port: u16, + /// P2P WebRTC listener port (default: 37001). + pub webrtc_port: u16, + /// P2P WebSocket switch. Note: it's mutually exclusive with the TCP listener (default: false) pub ws_transport_enable: bool, /// AutoNAT configuration #[serde(flatten)] @@ -157,6 +160,7 @@ impl Default for LibP2PConfig { Self { secret_key: None, port: 37000, + webrtc_port: 37001, ws_transport_enable: false, autonat: Default::default(), kademlia: Default::default(), @@ -174,7 +178,7 @@ impl Default for LibP2PConfig { } impl LibP2PConfig { - pub fn multiaddress(&self) -> Multiaddr { + pub fn tcp_multiaddress(&self) -> Multiaddr { let tcp_multiaddress = Multiaddr::empty() .with(Protocol::from(Ipv4Addr::UNSPECIFIED)) .with(Protocol::Tcp(self.port)); @@ -185,6 +189,12 @@ impl LibP2PConfig { tcp_multiaddress } } + + pub fn webrtc_multiaddress(&self) -> Multiaddr { + Multiaddr::from(Ipv4Addr::UNSPECIFIED) + .with(Protocol::Udp(self.webrtc_port)) + .with(Protocol::WebRTCDirect) + } } impl From<&LibP2PConfig> for kad::Config { diff --git a/crawler/src/main.rs b/crawler/src/main.rs index e6179e272..d3da953c7 100644 --- a/crawler/src/main.rs +++ b/crawler/src/main.rs @@ -112,9 +112,9 @@ async fn run(config: Config, db: RocksDB, shutdown: Controller) -> Resul ); p2p_client - .start_listening(config.libp2p.multiaddress()) + .start_listening(vec![config.libp2p.tcp_multiaddress()]) .await - .wrap_err("Listening on TCP not to fail.")?; + .wrap_err("Error starting listeners.")?; info!("TCP listener started on port {}", config.libp2p.port); let bootstrap_p2p_client = p2p_client.clone();