fix(security): upgrade libp2p 0.54.1 → 0.56.0 to eliminate ring 0.16.20 vulnerability

- Update libp2p from 0.54.1 to 0.56.0 in Cargo.toml
- Update libp2p-kad from 0.46.2 to 0.48.0 for compatibility
- Remove deprecated bandwidth logging (removed in libp2p 0.56)
  - transport.rs: Remove with_bandwidth_logging(), use websocket::Config
  - service.rs: Add NoBandwidthSink stub for bandwidth metrics
- Fix NetworkBehaviour derive macro changes:
  - behaviour.rs: Add From<Infallible> implementation for BehaviourOut
- Update pattern matching for new libp2p-swarm event fields:
  - request_responses.rs: Add connection_id to patterns
  - service.rs: Fix DialError::WrongPeerId field rename (endpoint → address)
  - service.rs: Add peer_id to IncomingConnectionError pattern
- Fix test file for new transport return type:
  - conformance.rs: Update transport usage

This eliminates the ring 0.16.20 security vulnerability (RUSTSEC-2024-0006)
by upgrading to ring 0.17.14 via the libp2p dependency chain.
This commit is contained in:
2025-12-23 05:29:36 +03:00
parent 30c8f91b94
commit e585615b45
7 changed files with 142 additions and 335 deletions
Generated
+109 -297
View File
@@ -1079,29 +1079,13 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "asn1-rs"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048"
dependencies = [
"asn1-rs-derive 0.5.1",
"asn1-rs-impl",
"displaydoc",
"nom 7.1.3",
"num-traits",
"rusticata-macros",
"thiserror 1.0.69",
"time",
]
[[package]] [[package]]
name = "asn1-rs" name = "asn1-rs"
version = "0.7.1" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56624a96882bb8c26d61312ae18cb45868e5a9992ea73c58e45c3101e56a1e60" checksum = "56624a96882bb8c26d61312ae18cb45868e5a9992ea73c58e45c3101e56a1e60"
dependencies = [ dependencies = [
"asn1-rs-derive 0.6.0", "asn1-rs-derive",
"asn1-rs-impl", "asn1-rs-impl",
"displaydoc", "displaydoc",
"nom 7.1.3", "nom 7.1.3",
@@ -1111,18 +1095,6 @@ dependencies = [
"time", "time",
] ]
[[package]]
name = "asn1-rs-derive"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490"
dependencies = [
"proc-macro2 1.0.103",
"quote 1.0.42",
"syn 2.0.111",
"synstructure 0.13.2",
]
[[package]] [[package]]
name = "asn1-rs-derive" name = "asn1-rs-derive"
version = "0.6.0" version = "0.6.0"
@@ -1815,11 +1787,12 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]] [[package]]
name = "attohttpc" name = "attohttpc"
version = "0.24.1" version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d9a9bf8b79a749ee0b911b91b671cc2b6c670bdbc7e3dfd537576ddc94bb2a2" checksum = "16e2cdb6d5ed835199484bb92bb8b3edd526effe995c61732580439c1a67e2e9"
dependencies = [ dependencies = [
"http 0.2.12", "base64 0.22.1",
"http 1.4.0",
"log", "log",
"url", "url",
] ]
@@ -4509,27 +4482,13 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "der-parser"
version = "9.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553"
dependencies = [
"asn1-rs 0.6.2",
"displaydoc",
"nom 7.1.3",
"num-bigint",
"num-traits",
"rusticata-macros",
]
[[package]] [[package]]
name = "der-parser" name = "der-parser"
version = "10.0.0" version = "10.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6"
dependencies = [ dependencies = [
"asn1-rs 0.7.1", "asn1-rs",
"displaydoc", "displaydoc",
"nom 7.1.3", "nom 7.1.3",
"num-bigint", "num-bigint",
@@ -5570,7 +5529,7 @@ checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"spin 0.9.8", "spin",
] ]
[[package]] [[package]]
@@ -6230,25 +6189,6 @@ dependencies = [
"subtle 2.6.1", "subtle 2.6.1",
] ]
[[package]]
name = "h2"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http 0.2.12",
"indexmap 2.12.1",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.12" version = "0.4.12"
@@ -6418,31 +6358,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
[[package]]
name = "hickory-proto"
version = "0.24.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92652067c9ce6f66ce53cc38d1169daa36e6e7eb7dd3b63b5103bd9d97117248"
dependencies = [
"async-trait",
"cfg-if",
"data-encoding",
"enum-as-inner",
"futures-channel",
"futures-io",
"futures-util",
"idna",
"ipnet",
"once_cell",
"rand 0.8.5",
"socket2 0.5.10",
"thiserror 1.0.69",
"tinyvec",
"tokio",
"tracing",
"url",
]
[[package]] [[package]]
name = "hickory-proto" name = "hickory-proto"
version = "0.25.2" version = "0.25.2"
@@ -6460,7 +6375,8 @@ dependencies = [
"ipnet", "ipnet",
"once_cell", "once_cell",
"rand 0.9.2", "rand 0.9.2",
"ring 0.17.14", "ring",
"socket2 0.5.10",
"thiserror 2.0.17", "thiserror 2.0.17",
"tinyvec", "tinyvec",
"tokio", "tokio",
@@ -6468,27 +6384,6 @@ dependencies = [
"url", "url",
] ]
[[package]]
name = "hickory-resolver"
version = "0.24.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbb117a1ca520e111743ab2f6688eddee69db4e0ea242545a604dce8a66fd22e"
dependencies = [
"cfg-if",
"futures-util",
"hickory-proto 0.24.4",
"ipconfig",
"lru-cache",
"once_cell",
"parking_lot 0.12.5",
"rand 0.8.5",
"resolv-conf",
"smallvec",
"thiserror 1.0.69",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "hickory-resolver" name = "hickory-resolver"
version = "0.25.2" version = "0.25.2"
@@ -6497,7 +6392,7 @@ checksum = "dc62a9a99b0bfb44d2ab95a7208ac952d31060efc16241c87eaf36406fecf87a"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"futures-util", "futures-util",
"hickory-proto 0.25.2", "hickory-proto",
"ipconfig", "ipconfig",
"moka", "moka",
"once_cell", "once_cell",
@@ -6670,7 +6565,6 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.3.27",
"http 0.2.12", "http 0.2.12",
"http-body 0.4.6", "http-body 0.4.6",
"httparse", "httparse",
@@ -6694,7 +6588,7 @@ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"h2 0.4.12", "h2",
"http 1.4.0", "http 1.4.0",
"http-body 1.0.1", "http-body 1.0.1",
"httparse", "httparse",
@@ -6963,18 +6857,20 @@ dependencies = [
[[package]] [[package]]
name = "igd-next" name = "igd-next"
version = "0.14.3" version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "064d90fec10d541084e7b39ead8875a5a80d9114a2b18791565253bae25f49e4" checksum = "516893339c97f6011282d5825ac94fc1c7aad5cad26bdc2d0cee068c0bf97f97"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"attohttpc", "attohttpc",
"bytes", "bytes",
"futures", "futures",
"http 0.2.12", "http 1.4.0",
"hyper 0.14.32", "http-body-util",
"hyper 1.8.1",
"hyper-util",
"log", "log",
"rand 0.8.5", "rand 0.9.2",
"tokio", "tokio",
"url", "url",
"xmltree", "xmltree",
@@ -7830,7 +7726,7 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
dependencies = [ dependencies = [
"spin 0.9.8", "spin",
] ]
[[package]] [[package]]
@@ -7905,9 +7801,9 @@ dependencies = [
[[package]] [[package]]
name = "libp2p" name = "libp2p"
version = "0.54.1" version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbbe80f9c7e00526cd6b838075b9c171919404a4732cb2fa8ece0a093223bfc4" checksum = "ce71348bf5838e46449ae240631117b487073d5f347c06d434caddcb91dceb5a"
dependencies = [ dependencies = [
"bytes", "bytes",
"either", "either",
@@ -7935,38 +7831,36 @@ dependencies = [
"multiaddr 0.18.2", "multiaddr 0.18.2",
"pin-project", "pin-project",
"rw-stream-sink", "rw-stream-sink",
"thiserror 1.0.69", "thiserror 2.0.17",
] ]
[[package]] [[package]]
name = "libp2p-allow-block-list" name = "libp2p-allow-block-list"
version = "0.4.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1027ccf8d70320ed77e984f273bc8ce952f623762cb9bf2d126df73caef8041" checksum = "d16ccf824ee859ca83df301e1c0205270206223fd4b1f2e512a693e1912a8f4a"
dependencies = [ dependencies = [
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"libp2p-swarm", "libp2p-swarm",
"void",
] ]
[[package]] [[package]]
name = "libp2p-connection-limits" name = "libp2p-connection-limits"
version = "0.4.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d003540ee8baef0d254f7b6bfd79bac3ddf774662ca0abf69186d517ef82ad8" checksum = "a18b8b607cf3bfa2f8c57db9c7d8569a315d5cc0a282e6bfd5ebfc0a9840b2a0"
dependencies = [ dependencies = [
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"libp2p-swarm", "libp2p-swarm",
"void",
] ]
[[package]] [[package]]
name = "libp2p-core" name = "libp2p-core"
version = "0.42.0" version = "0.43.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a61f26c83ed111104cd820fe9bc3aaabbac5f1652a1d213ed6e900b7918a1298" checksum = "249128cd37a2199aff30a7675dffa51caf073b51aa612d2f544b19932b9aebca"
dependencies = [ dependencies = [
"either", "either",
"fnv", "fnv",
@@ -7976,29 +7870,26 @@ dependencies = [
"multiaddr 0.18.2", "multiaddr 0.18.2",
"multihash 0.19.3", "multihash 0.19.3",
"multistream-select", "multistream-select",
"once_cell",
"parking_lot 0.12.5", "parking_lot 0.12.5",
"pin-project", "pin-project",
"quick-protobuf", "quick-protobuf",
"rand 0.8.5", "rand 0.8.5",
"rw-stream-sink", "rw-stream-sink",
"smallvec", "thiserror 2.0.17",
"thiserror 1.0.69",
"tracing", "tracing",
"unsigned-varint 0.8.0", "unsigned-varint 0.8.0",
"void",
"web-time", "web-time",
] ]
[[package]] [[package]]
name = "libp2p-dns" name = "libp2p-dns"
version = "0.42.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97f37f30d5c7275db282ecd86e54f29dd2176bd3ac656f06abf43bedb21eb8bd" checksum = "0b770c1c8476736ca98c578cba4b505104ff8e842c2876b528925f9766379f9a"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures", "futures",
"hickory-resolver 0.24.4", "hickory-resolver",
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"parking_lot 0.12.5", "parking_lot 0.12.5",
@@ -8008,9 +7899,9 @@ dependencies = [
[[package]] [[package]]
name = "libp2p-identify" name = "libp2p-identify"
version = "0.45.0" version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1711b004a273be4f30202778856368683bd9a83c4c7dcc8f848847606831a4e3" checksum = "8ab792a8b68fdef443a62155b01970c81c3aadab5e659621b063ef252a8e65e8"
dependencies = [ dependencies = [
"asynchronous-codec 0.7.0", "asynchronous-codec 0.7.0",
"either", "either",
@@ -8020,13 +7911,11 @@ dependencies = [
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"libp2p-swarm", "libp2p-swarm",
"lru 0.12.5",
"quick-protobuf", "quick-protobuf",
"quick-protobuf-codec", "quick-protobuf-codec",
"smallvec", "smallvec",
"thiserror 1.0.69", "thiserror 2.0.17",
"tracing", "tracing",
"void",
] ]
[[package]] [[package]]
@@ -8049,11 +7938,10 @@ dependencies = [
[[package]] [[package]]
name = "libp2p-kad" name = "libp2p-kad"
version = "0.46.2" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced237d0bd84bbebb7c2cad4c073160dacb4fe40534963c32ed6d4c6bb7702a3" checksum = "13d3fd632a5872ec804d37e7413ceea20588f69d027a0fa3c46f82574f4dee60"
dependencies = [ dependencies = [
"arrayvec 0.7.6",
"asynchronous-codec 0.7.0", "asynchronous-codec 0.7.0",
"bytes", "bytes",
"either", "either",
@@ -8069,22 +7957,20 @@ dependencies = [
"rand 0.8.5", "rand 0.8.5",
"sha2 0.10.9", "sha2 0.10.9",
"smallvec", "smallvec",
"thiserror 1.0.69", "thiserror 2.0.17",
"tracing", "tracing",
"uint 0.9.5", "uint 0.10.0",
"void",
"web-time", "web-time",
] ]
[[package]] [[package]]
name = "libp2p-mdns" name = "libp2p-mdns"
version = "0.46.0" version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b8546b6644032565eb29046b42744aee1e9f261ed99671b2c93fb140dba417" checksum = "c66872d0f1ffcded2788683f76931be1c52e27f343edb93bc6d0bcd8887be443"
dependencies = [ dependencies = [
"data-encoding",
"futures", "futures",
"hickory-proto 0.24.4", "hickory-proto",
"if-watch", "if-watch",
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
@@ -8094,14 +7980,13 @@ dependencies = [
"socket2 0.5.10", "socket2 0.5.10",
"tokio", "tokio",
"tracing", "tracing",
"void",
] ]
[[package]] [[package]]
name = "libp2p-metrics" name = "libp2p-metrics"
version = "0.15.0" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ebafa94a717c8442d8db8d3ae5d1c6a15e30f2d347e0cd31d057ca72e42566" checksum = "805a555148522cb3414493a5153451910cb1a146c53ffbf4385708349baf62b7"
dependencies = [ dependencies = [
"futures", "futures",
"libp2p-core", "libp2p-core",
@@ -8117,25 +8002,22 @@ dependencies = [
[[package]] [[package]]
name = "libp2p-noise" name = "libp2p-noise"
version = "0.45.0" version = "0.46.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36b137cb1ae86ee39f8e5d6245a296518912014eaa87427d24e6ff58cfc1b28c" checksum = "bc73eacbe6462a0eb92a6527cac6e63f02026e5407f8831bde8293f19217bfbf"
dependencies = [ dependencies = [
"asynchronous-codec 0.7.0", "asynchronous-codec 0.7.0",
"bytes", "bytes",
"curve25519-dalek",
"futures", "futures",
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"multiaddr 0.18.2", "multiaddr 0.18.2",
"multihash 0.19.3", "multihash 0.19.3",
"once_cell",
"quick-protobuf", "quick-protobuf",
"rand 0.8.5", "rand 0.8.5",
"sha2 0.10.9",
"snow", "snow",
"static_assertions", "static_assertions",
"thiserror 1.0.69", "thiserror 2.0.17",
"tracing", "tracing",
"x25519-dalek", "x25519-dalek",
"zeroize", "zeroize",
@@ -8143,11 +8025,10 @@ dependencies = [
[[package]] [[package]]
name = "libp2p-ping" name = "libp2p-ping"
version = "0.45.0" version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "005a34420359223b974ee344457095f027e51346e992d1e0dcd35173f4cdd422" checksum = "74bb7fcdfd9fead4144a3859da0b49576f171a8c8c7c0bfc7c541921d25e60d3"
dependencies = [ dependencies = [
"either",
"futures", "futures",
"futures-timer", "futures-timer",
"libp2p-core", "libp2p-core",
@@ -8155,59 +8036,53 @@ dependencies = [
"libp2p-swarm", "libp2p-swarm",
"rand 0.8.5", "rand 0.8.5",
"tracing", "tracing",
"void",
"web-time", "web-time",
] ]
[[package]] [[package]]
name = "libp2p-quic" name = "libp2p-quic"
version = "0.11.1" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46352ac5cd040c70e88e7ff8257a2ae2f891a4076abad2c439584a31c15fd24e" checksum = "8dc448b2de9f4745784e3751fe8bc6c473d01b8317edd5ababcb0dec803d843f"
dependencies = [ dependencies = [
"bytes",
"futures", "futures",
"futures-timer", "futures-timer",
"if-watch", "if-watch",
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"libp2p-tls", "libp2p-tls",
"parking_lot 0.12.5",
"quinn", "quinn",
"rand 0.8.5", "rand 0.8.5",
"ring 0.17.14", "ring",
"rustls 0.23.35", "rustls 0.23.35",
"socket2 0.5.10", "socket2 0.5.10",
"thiserror 1.0.69", "thiserror 2.0.17",
"tokio", "tokio",
"tracing", "tracing",
] ]
[[package]] [[package]]
name = "libp2p-request-response" name = "libp2p-request-response"
version = "0.27.0" version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1356c9e376a94a75ae830c42cdaea3d4fe1290ba409a22c809033d1b7dcab0a6" checksum = "a9f1cca83488b90102abac7b67d5c36fc65bc02ed47620228af7ed002e6a1478"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures", "futures",
"futures-bounded", "futures-bounded",
"futures-timer",
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"libp2p-swarm", "libp2p-swarm",
"rand 0.8.5", "rand 0.8.5",
"smallvec", "smallvec",
"tracing", "tracing",
"void",
"web-time",
] ]
[[package]] [[package]]
name = "libp2p-swarm" name = "libp2p-swarm"
version = "0.45.1" version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7dd6741793d2c1fb2088f67f82cf07261f25272ebe3c0b0c311e0c6b50e851a" checksum = "6aa762e5215919a34e31c35d4b18bf2e18566ecab7f8a3d39535f4a3068f8b62"
dependencies = [ dependencies = [
"either", "either",
"fnv", "fnv",
@@ -8218,39 +8093,35 @@ dependencies = [
"libp2p-swarm-derive", "libp2p-swarm-derive",
"lru 0.12.5", "lru 0.12.5",
"multistream-select", "multistream-select",
"once_cell",
"rand 0.8.5", "rand 0.8.5",
"smallvec", "smallvec",
"tokio", "tokio",
"tracing", "tracing",
"void",
"web-time", "web-time",
] ]
[[package]] [[package]]
name = "libp2p-swarm-derive" name = "libp2p-swarm-derive"
version = "0.35.0" version = "0.35.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "206e0aa0ebe004d778d79fb0966aa0de996c19894e2c0605ba2f8524dd4443d8" checksum = "dd297cf53f0cb3dee4d2620bb319ae47ef27c702684309f682bdb7e55a18ae9c"
dependencies = [ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2 1.0.103",
"quote 1.0.42", "quote 1.0.42",
"syn 2.0.111", "syn 2.0.111",
] ]
[[package]] [[package]]
name = "libp2p-tcp" name = "libp2p-tcp"
version = "0.42.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad964f312c59dcfcac840acd8c555de8403e295d39edf96f5240048b5fcaa314" checksum = "65b4e030c52c46c8d01559b2b8ca9b7c4185f10576016853129ca1fe5cd1a644"
dependencies = [ dependencies = [
"futures", "futures",
"futures-timer", "futures-timer",
"if-watch", "if-watch",
"libc", "libc",
"libp2p-core", "libp2p-core",
"libp2p-identity",
"socket2 0.5.10", "socket2 0.5.10",
"tokio", "tokio",
"tracing", "tracing",
@@ -8258,28 +8129,28 @@ dependencies = [
[[package]] [[package]]
name = "libp2p-tls" name = "libp2p-tls"
version = "0.5.0" version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47b23dddc2b9c355f73c1e36eb0c3ae86f7dc964a3715f0731cfad352db4d847" checksum = "96ff65a82e35375cbc31ebb99cacbbf28cb6c4fefe26bf13756ddcf708d40080"
dependencies = [ dependencies = [
"futures", "futures",
"futures-rustls", "futures-rustls",
"libp2p-core", "libp2p-core",
"libp2p-identity", "libp2p-identity",
"rcgen", "rcgen",
"ring 0.17.14", "ring",
"rustls 0.23.35", "rustls 0.23.35",
"rustls-webpki 0.101.7", "rustls-webpki 0.103.8",
"thiserror 1.0.69", "thiserror 2.0.17",
"x509-parser 0.16.0", "x509-parser",
"yasna", "yasna",
] ]
[[package]] [[package]]
name = "libp2p-upnp" name = "libp2p-upnp"
version = "0.3.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01bf2d1b772bd3abca049214a3304615e6a36fa6ffc742bdd1ba774486200b8f" checksum = "4757e65fe69399c1a243bbb90ec1ae5a2114b907467bf09f3575e899815bb8d3"
dependencies = [ dependencies = [
"futures", "futures",
"futures-timer", "futures-timer",
@@ -8288,14 +8159,13 @@ dependencies = [
"libp2p-swarm", "libp2p-swarm",
"tokio", "tokio",
"tracing", "tracing",
"void",
] ]
[[package]] [[package]]
name = "libp2p-websocket" name = "libp2p-websocket"
version = "0.44.0" version = "0.45.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "888b2ff2e5d8dcef97283daab35ad1043d18952b65e05279eecbe02af4c6e347" checksum = "520e29066a48674c007bc11defe5dce49908c24cafd8fad2f5e1a6a8726ced53"
dependencies = [ dependencies = [
"either", "either",
"futures", "futures",
@@ -8306,22 +8176,22 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"rw-stream-sink", "rw-stream-sink",
"soketto", "soketto",
"thiserror 1.0.69", "thiserror 2.0.17",
"tracing", "tracing",
"url", "url",
"webpki-roots 0.25.4", "webpki-roots 0.26.11",
] ]
[[package]] [[package]]
name = "libp2p-yamux" name = "libp2p-yamux"
version = "0.46.0" version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "788b61c80789dba9760d8c669a5bedb642c8267555c803fabd8396e4ca5c5882" checksum = "f15df094914eb4af272acf9adaa9e287baa269943f32ea348ba29cfb9bfc60d8"
dependencies = [ dependencies = [
"either", "either",
"futures", "futures",
"libp2p-core", "libp2p-core",
"thiserror 1.0.69", "thiserror 2.0.17",
"tracing", "tracing",
"yamux 0.12.1", "yamux 0.12.1",
"yamux 0.13.8", "yamux 0.13.8",
@@ -8517,7 +8387,7 @@ dependencies = [
"enum-display", "enum-display",
"futures", "futures",
"futures-timer", "futures-timer",
"hickory-resolver 0.25.2", "hickory-resolver",
"indexmap 2.12.1", "indexmap 2.12.1",
"libc", "libc",
"mockall", "mockall",
@@ -8529,7 +8399,7 @@ dependencies = [
"prost 0.13.5", "prost 0.13.5",
"prost-build 0.14.1", "prost-build 0.14.1",
"rand 0.8.5", "rand 0.8.5",
"ring 0.17.14", "ring",
"serde", "serde",
"sha2 0.10.9", "sha2 0.10.9",
"simple-dns", "simple-dns",
@@ -8546,7 +8416,7 @@ dependencies = [
"unsigned-varint 0.8.0", "unsigned-varint 0.8.0",
"url", "url",
"x25519-dalek", "x25519-dalek",
"x509-parser 0.17.0", "x509-parser",
"yamux 0.13.8", "yamux 0.13.8",
"yasna", "yasna",
"zeroize", "zeroize",
@@ -8589,15 +8459,6 @@ dependencies = [
"hashbrown 0.15.5", "hashbrown 0.15.5",
] ]
[[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]] [[package]]
name = "lru-slab" name = "lru-slab"
version = "0.1.2" version = "0.1.2"
@@ -9484,22 +9345,13 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "oid-registry"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9"
dependencies = [
"asn1-rs 0.6.2",
]
[[package]] [[package]]
name = "oid-registry" name = "oid-registry"
version = "0.8.1" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7"
dependencies = [ dependencies = [
"asn1-rs 0.7.1", "asn1-rs",
] ]
[[package]] [[package]]
@@ -22271,9 +22123,9 @@ dependencies = [
[[package]] [[package]]
name = "prometheus-client" name = "prometheus-client"
version = "0.22.3" version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca" checksum = "cf41c1a7c32ed72abe5082fb19505b969095c12da9f5732a4bc9878757fd087c"
dependencies = [ dependencies = [
"dtoa", "dtoa",
"itoa", "itoa",
@@ -22621,7 +22473,7 @@ dependencies = [
"getrandom 0.3.4", "getrandom 0.3.4",
"lru-slab", "lru-slab",
"rand 0.9.2", "rand 0.9.2",
"ring 0.17.14", "ring",
"rustc-hash 2.1.1", "rustc-hash 2.1.1",
"rustls 0.23.35", "rustls 0.23.35",
"rustls-pki-types", "rustls-pki-types",
@@ -22832,12 +22684,13 @@ dependencies = [
[[package]] [[package]]
name = "rcgen" name = "rcgen"
version = "0.11.3" version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52c4f3084aa3bc7dfbba4eff4fab2a54db4324965d8872ab933565e6fbd83bc6" checksum = "75e669e5202259b5314d1ea5397316ad400819437857b90861765f24c4cf80a2"
dependencies = [ dependencies = [
"pem", "pem",
"ring 0.16.20", "ring",
"rustls-pki-types",
"time", "time",
"yasna", "yasna",
] ]
@@ -23051,7 +22904,7 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.4.12", "h2",
"http 1.4.0", "http 1.4.0",
"http-body 1.0.1", "http-body 1.0.1",
"http-body-util", "http-body-util",
@@ -23290,21 +23143,6 @@ dependencies = [
"subtle 2.6.1", "subtle 2.6.1",
] ]
[[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 0.5.2",
"untrusted 0.7.1",
"web-sys",
"winapi",
]
[[package]] [[package]]
name = "ring" name = "ring"
version = "0.17.14" version = "0.17.14"
@@ -23315,7 +23153,7 @@ dependencies = [
"cfg-if", "cfg-if",
"getrandom 0.2.16", "getrandom 0.2.16",
"libc", "libc",
"untrusted 0.9.0", "untrusted",
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
@@ -23597,7 +23435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
dependencies = [ dependencies = [
"log", "log",
"ring 0.17.14", "ring",
"rustls-webpki 0.101.7", "rustls-webpki 0.101.7",
"sct", "sct",
] ]
@@ -23610,7 +23448,7 @@ checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f"
dependencies = [ dependencies = [
"log", "log",
"once_cell", "once_cell",
"ring 0.17.14", "ring",
"rustls-pki-types", "rustls-pki-types",
"rustls-webpki 0.103.8", "rustls-webpki 0.103.8",
"subtle 2.6.1", "subtle 2.6.1",
@@ -23693,8 +23531,8 @@ version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
dependencies = [ dependencies = [
"ring 0.17.14", "ring",
"untrusted 0.9.0", "untrusted",
] ]
[[package]] [[package]]
@@ -23703,9 +23541,9 @@ version = "0.103.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52"
dependencies = [ dependencies = [
"ring 0.17.14", "ring",
"rustls-pki-types", "rustls-pki-types",
"untrusted 0.9.0", "untrusted",
] ]
[[package]] [[package]]
@@ -24058,8 +23896,8 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
dependencies = [ dependencies = [
"ring 0.17.14", "ring",
"untrusted 0.9.0", "untrusted",
] ]
[[package]] [[package]]
@@ -24765,7 +24603,7 @@ dependencies = [
"chacha20poly1305", "chacha20poly1305",
"curve25519-dalek", "curve25519-dalek",
"rand_core 0.6.4", "rand_core 0.6.4",
"ring 0.17.14", "ring",
"rustc_version 0.4.1", "rustc_version 0.4.1",
"sha2 0.10.9", "sha2 0.10.9",
"subtle 2.6.1", "subtle 2.6.1",
@@ -24862,12 +24700,6 @@ dependencies = [
"twox-hash 1.6.3", "twox-hash 1.6.3",
] ]
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]] [[package]]
name = "spin" name = "spin"
version = "0.9.8" version = "0.9.8"
@@ -26737,12 +26569,6 @@ dependencies = [
"tokio-util", "tokio-util",
] ]
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.9.0" version = "0.9.0"
@@ -26852,7 +26678,7 @@ dependencies = [
"parity-scale-codec", "parity-scale-codec",
"scale-info", "scale-info",
"schnorrkel 0.10.2", "schnorrkel 0.10.2",
"spin 0.9.8", "spin",
] ]
[[package]] [[package]]
@@ -27157,7 +26983,7 @@ dependencies = [
"num-derive", "num-derive",
"num-traits", "num-traits",
"smallvec", "smallvec",
"spin 0.9.8", "spin",
"wasmi_collections 0.32.3", "wasmi_collections 0.32.3",
"wasmi_core 0.32.3", "wasmi_core 0.32.3",
"wasmparser-nostd", "wasmparser-nostd",
@@ -27172,7 +26998,7 @@ dependencies = [
"arrayvec 0.7.6", "arrayvec 0.7.6",
"multi-stash", "multi-stash",
"smallvec", "smallvec",
"spin 0.9.8", "spin",
"wasmi_collections 0.40.0", "wasmi_collections 0.40.0",
"wasmi_core 0.40.0", "wasmi_core 0.40.0",
"wasmi_ir", "wasmi_ir",
@@ -27570,9 +27396,12 @@ dependencies = [
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.25.4" version = "0.26.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
dependencies = [
"webpki-roots 1.0.4",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
@@ -28136,35 +27965,18 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "x509-parser"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69"
dependencies = [
"asn1-rs 0.6.2",
"data-encoding",
"der-parser 9.0.0",
"lazy_static",
"nom 7.1.3",
"oid-registry 0.7.1",
"rusticata-macros",
"thiserror 1.0.69",
"time",
]
[[package]] [[package]]
name = "x509-parser" name = "x509-parser"
version = "0.17.0" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4569f339c0c402346d4a75a9e39cf8dad310e287eef1ff56d4c68e5067f53460" checksum = "4569f339c0c402346d4a75a9e39cf8dad310e287eef1ff56d4c68e5067f53460"
dependencies = [ dependencies = [
"asn1-rs 0.7.1", "asn1-rs",
"data-encoding", "data-encoding",
"der-parser 10.0.0", "der-parser",
"lazy_static", "lazy_static",
"nom 7.1.3", "nom 7.1.3",
"oid-registry 0.8.1", "oid-registry",
"rusticata-macros", "rusticata-macros",
"thiserror 2.0.17", "thiserror 2.0.17",
"time", "time",
+2 -2
View File
@@ -889,9 +889,9 @@ landlock = { version = "0.3.0" }
lazy_static = { version = "1.5" } lazy_static = { version = "1.5" }
libc = { version = "0.2.155" } libc = { version = "0.2.155" }
libfuzzer-sys = { version = "0.4" } libfuzzer-sys = { version = "0.4" }
libp2p = { version = "0.54.1" } libp2p = { version = "0.56.0" }
libp2p-identity = { version = "0.2.9" } libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.46.2", default-features = false } libp2p-kad = { version = "0.48.0", default-features = false }
libsecp256k1 = { version = "0.7.0", default-features = false } libsecp256k1 = { version = "0.7.0", default-features = false }
linked-hash-map = { version = "0.5.4" } linked-hash-map = { version = "0.5.4" }
linked_hash_set = { version = "0.1.4" } linked_hash_set = { version = "0.1.4" }
@@ -464,3 +464,9 @@ impl From<void::Void> for BehaviourOut {
void::unreachable(e) void::unreachable(e)
} }
} }
impl From<std::convert::Infallible> for BehaviourOut {
fn from(value: std::convert::Infallible) -> Self {
match value {}
}
}
@@ -111,7 +111,7 @@ fn setup_libp2p(
.with_max_negotiating_inbound_streams(2048) .with_max_negotiating_inbound_streams(2048)
.with_idle_connection_timeout(Duration::from_secs(5)); .with_idle_connection_timeout(Duration::from_secs(5));
Swarm::new(transport.0, behaviour, local_peer_id, config) Swarm::new(transport, behaviour, local_peer_id, config)
}; };
swarm.listen_on("/ip6/::1/tcp/0".parse().unwrap()).unwrap(); swarm.listen_on("/ip6/::1/tcp/0".parse().unwrap()).unwrap();
@@ -762,6 +762,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
request_response::Event::Message { request_response::Event::Message {
peer, peer,
message: Message::Request { request_id, request, channel, .. }, message: Message::Request { request_id, request, channel, .. },
..
} => { } => {
self.pending_responses_arrival_time self.pending_responses_arrival_time
.insert((protocol.clone(), request_id).into(), Instant::now()); .insert((protocol.clone(), request_id).into(), Instant::now());
@@ -962,7 +963,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
}, },
// A response to an inbound request has been sent. // A response to an inbound request has been sent.
request_response::Event::ResponseSent { request_id, peer } => { request_response::Event::ResponseSent { request_id, peer, .. } => {
let arrival_time = self let arrival_time = self
.pending_responses_arrival_time .pending_responses_arrival_time
.remove(&(protocol.clone(), request_id).into()) .remove(&(protocol.clone(), request_id).into())
+15 -17
View File
@@ -113,18 +113,18 @@ pub mod traits;
/// Logging target for the file. /// Logging target for the file.
const LOG_TARGET: &str = "sub-libp2p"; const LOG_TARGET: &str = "sub-libp2p";
struct Libp2pBandwidthSink { /// Stub bandwidth sink that returns 0 for all metrics.
#[allow(deprecated)] /// Bandwidth logging was removed in libp2p 0.56.0.
sink: Arc<transport::BandwidthSinks>, /// TODO: Implement custom bandwidth tracking if needed.
} struct NoBandwidthSink;
impl BandwidthSink for Libp2pBandwidthSink { impl BandwidthSink for NoBandwidthSink {
fn total_inbound(&self) -> u64 { fn total_inbound(&self) -> u64 {
self.sink.total_inbound() 0
} }
fn total_outbound(&self) -> u64 { fn total_outbound(&self) -> u64 {
self.sink.total_outbound() 0
} }
} }
@@ -338,7 +338,7 @@ where
); );
info!(target: LOG_TARGET, "Running libp2p network backend"); info!(target: LOG_TARGET, "Running libp2p network backend");
let (transport, bandwidth) = { let transport = {
let config_mem = match network_config.transport { let config_mem = match network_config.transport {
TransportConfig::MemoryOnly => true, TransportConfig::MemoryOnly => true,
TransportConfig::Normal { .. } => false, TransportConfig::Normal { .. } => false,
@@ -467,7 +467,7 @@ where
)?; )?;
// Build the swarm. // Build the swarm.
let (mut swarm, bandwidth): (Swarm<Behaviour<B>>, _) = { let mut swarm = {
let user_agent = let user_agent =
format!("{} ({})", network_config.client_version, network_config.node_name); format!("{} ({})", network_config.client_version, network_config.node_name);
@@ -554,10 +554,12 @@ where
Swarm::new(transport, behaviour, local_peer_id, config) Swarm::new(transport, behaviour, local_peer_id, config)
}; };
swarm
(swarm, Arc::new(Libp2pBandwidthSink { sink: bandwidth }))
}; };
// Stub bandwidth sink (bandwidth logging removed in libp2p 0.56.0)
let bandwidth: Arc<dyn BandwidthSink> = Arc::new(NoBandwidthSink);
// Initialize the metrics. // Initialize the metrics.
let metrics = match &params.metrics_registry { let metrics = match &params.metrics_registry {
Some(registry) => Some(metrics::register( Some(registry) => Some(metrics::register(
@@ -1790,12 +1792,7 @@ where
if let Some(addresses) = if let Some(addresses) =
not_reported.then(|| self.boot_node_ids.get(&peer_id)).flatten() not_reported.then(|| self.boot_node_ids.get(&peer_id)).flatten()
{ {
if let DialError::WrongPeerId { obtained, endpoint } = &error { if let DialError::WrongPeerId { obtained, address } = &error {
if let ConnectedPoint::Dialer {
address,
role_override: _,
port_use: _,
} = endpoint
{ {
let address_without_peer_id = parse_addr(address.clone().into()) let address_without_peer_id = parse_addr(address.clone().into())
.map_or_else(|_| address.clone(), |r| r.1.into()); .map_or_else(|_| address.clone(), |r| r.1.into());
@@ -1851,6 +1848,7 @@ where
local_addr, local_addr,
send_back_addr, send_back_addr,
error, error,
..
} => { } => {
debug!( debug!(
target: LOG_TARGET, target: LOG_TARGET,
+7 -17
View File
@@ -25,26 +25,18 @@ use libp2p::{
transport::{Boxed, OptionalTransport}, transport::{Boxed, OptionalTransport},
upgrade, upgrade,
}, },
dns, identity, noise, tcp, websocket, PeerId, Transport, TransportExt, dns, identity, noise, tcp, websocket, PeerId, Transport,
}; };
use std::{sync::Arc, time::Duration}; use std::time::Duration;
// TODO: Create a wrapper similar to upstream `BandwidthTransport` that tracks sent/received bytes
#[allow(deprecated)]
pub use libp2p::bandwidth::BandwidthSinks;
/// Builds the transport that serves as a common ground for all connections. /// Builds the transport that serves as a common ground for all connections.
/// ///
/// If `memory_only` is true, then only communication within the same process are allowed. Only /// If `memory_only` is true, then only communication within the same process are allowed. Only
/// addresses with the format `/memory/...` are allowed. /// addresses with the format `/memory/...` are allowed.
///
/// Returns a `BandwidthSinks` object that allows querying the average bandwidth produced by all
/// the connections spawned with this transport.
#[allow(deprecated)]
pub fn build_transport( pub fn build_transport(
keypair: identity::Keypair, keypair: identity::Keypair,
memory_only: bool, memory_only: bool,
) -> (Boxed<(PeerId, StreamMuxerBox)>, Arc<BandwidthSinks>) { ) -> Boxed<(PeerId, StreamMuxerBox)> {
// Build the base layer of the transport. // Build the base layer of the transport.
let transport = if !memory_only { let transport = if !memory_only {
// Main transport: DNS(TCP) // Main transport: DNS(TCP)
@@ -61,11 +53,11 @@ pub fn build_transport(
let tcp_trans = tcp::tokio::Transport::new(tcp_config); let tcp_trans = tcp::tokio::Transport::new(tcp_config);
let dns_for_wss = dns::tokio::Transport::system(tcp_trans) let dns_for_wss = dns::tokio::Transport::system(tcp_trans)
.expect("same system_conf & resolver to work"); .expect("same system_conf & resolver to work");
Either::Left(websocket::WsConfig::new(dns_for_wss).or_transport(dns)) Either::Left(websocket::Config::new(dns_for_wss).or_transport(dns))
} else { } else {
// In case DNS can't be constructed, fallback to TCP + WS (WSS won't work) // In case DNS can't be constructed, fallback to TCP + WS (WSS won't work)
let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone());
let desktop_trans = websocket::WsConfig::new(tcp_trans) let desktop_trans = websocket::Config::new(tcp_trans)
.or_transport(tcp::tokio::Transport::new(tcp_config)); .or_transport(tcp::tokio::Transport::new(tcp_config));
Either::Right(desktop_trans) Either::Right(desktop_trans)
}) })
@@ -76,12 +68,10 @@ pub fn build_transport(
let authentication_config = noise::Config::new(&keypair).expect("Can create noise config. qed"); let authentication_config = noise::Config::new(&keypair).expect("Can create noise config. qed");
let multiplexing_config = libp2p::yamux::Config::default(); let multiplexing_config = libp2p::yamux::Config::default();
let transport = transport transport
.upgrade(upgrade::Version::V1Lazy) .upgrade(upgrade::Version::V1Lazy)
.authenticate(authentication_config) .authenticate(authentication_config)
.multiplex(multiplexing_config) .multiplex(multiplexing_config)
.timeout(Duration::from_secs(20)) .timeout(Duration::from_secs(20))
.boxed(); .boxed()
transport.with_bandwidth_logging()
} }