diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 29c54c335a4d..c51267e140f9 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1,8 +1,8 @@
blank_issues_enabled: true
contact_links:
- - name: Question
+ - name: Technical Questions
url: https://github.com/libp2p/rust-libp2p/discussions/new?category=q-a
- about: Please ask questions in the rust-libp2p GitHub Discussions forum.
- - name: Libp2p Discourse Forum
+ about: Please ask technical questions in the rust-libp2p GitHub Discussions forum.
+ - name: Community-wide libp2p Discussion
url: https://discuss.libp2p.io
- about: Discussions and questions related to multiple libp2p implementations.
+ about: Discussions and questions about the libp2p community.
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 59915a71b6c0..6c43a31d2c11 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -9,10 +9,23 @@ updates:
prefix: "deps"
rebase-strategy: "disabled"
groups:
- trust-dns:
+ hickory-dns:
patterns:
- - "trust-dns-*"
+ - "hickory-*"
- "async-std-resolver"
+ opentelemetry:
+ patterns:
+ - "opentelemetry*"
+ - "tracing-opentelemetry"
+ axum:
+ patterns:
+ - "axum"
+ - "tower"
+ - "tower-http"
+ webrtc:
+ patterns:
+ - "rcgen"
+ - "webrtc"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
diff --git a/.github/workflows/cache-factory.yml b/.github/workflows/cache-factory.yml
index f4ef3cc8591c..8c49b335f1b8 100644
--- a/.github/workflows/cache-factory.yml
+++ b/.github/workflows/cache-factory.yml
@@ -22,7 +22,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
shared-key: stable-cache
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 429511175165..90635ee53e76 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -33,12 +33,14 @@ jobs:
CRATE: ${{ matrix.crate }}
steps:
- uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- uses: dtolnay/rust-toolchain@stable
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
shared-key: stable-cache
save-if: false
@@ -50,7 +52,7 @@ jobs:
run: cargo build --package "$CRATE" --no-default-features
- name: Enforce no dependency on meta crate
- if: env.CRATE != 'libp2p-server'
+ if: env.CRATE != 'libp2p-server' && env.CRATE != 'libp2p-perf'
run: |
cargo metadata --format-version=1 --no-deps | \
jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .dependencies | all(.name != "libp2p")'
@@ -59,16 +61,48 @@ jobs:
with:
tool: tomlq
+ - name: Extract version from manifest
+ run: |
+ CRATE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .version')
+
+ echo "CRATE_VERSION=$CRATE_VERSION" >> $GITHUB_ENV
+
- name: Enforce version in `workspace.dependencies` matches latest version
if: env.CRATE != 'libp2p'
run: |
- PACKAGE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .version')
SPECIFIED_VERSION=$(tomlq "workspace.dependencies.$CRATE.version" --file ./Cargo.toml)
- echo "Package version: $PACKAGE_VERSION";
+ echo "Package version: $CRATE_VERSION";
echo "Specified version: $SPECIFIED_VERSION";
- test "$PACKAGE_VERSION" = "$SPECIFIED_VERSION"
+ test "$CRATE_VERSION" = "$SPECIFIED_VERSION" || test "=$CRATE_VERSION" = "$SPECIFIED_VERSION"
+
+ - name: Enforce version in CHANGELOG.md matches version in manifest
+ run: |
+ MANIFEST_PATH=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .manifest_path')
+ DIR_TO_CRATE=$(dirname "$MANIFEST_PATH")
+ VERSION_IN_CHANGELOG=$(awk -F' ' '/^## [0-9]+\.[0-9]+\.[0-9]+/{print $2; exit}' "$DIR_TO_CRATE/CHANGELOG.md")
+
+ echo "Package version: $CRATE_VERSION";
+ echo "Changelog version: $VERSION_IN_CHANGELOG";
+
+ test "$CRATE_VERSION" = "$VERSION_IN_CHANGELOG"
+
+ - name: Ensure manifest and CHANGELOG are properly updated
+ if: >
+ github.event_name == 'pull_request' &&
+ !startsWith(github.event.pull_request.title, 'chore') &&
+ !startsWith(github.event.pull_request.title, 'refactor') &&
+ !startsWith(github.event.pull_request.title, 'deps') &&
+ !startsWith(github.event.pull_request.title, 'docs') &&
+ !contains(github.event.pull_request.labels.*.name, 'internal-change')
+ run: |
+ git fetch origin master:master
+ git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
+ ./scripts/ensure-version-bump-and-changelog.sh
+ env:
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ PR_BASE: ${{ github.event.pull_request.base.ref }}
wasm_tests:
name: Run all WASM tests
@@ -124,7 +158,7 @@ jobs:
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
key: ${{ matrix.target }}
save-if: ${{ github.ref == 'refs/heads/master' }}
@@ -149,7 +183,7 @@ jobs:
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
@@ -170,7 +204,7 @@ jobs:
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
key: ${{ matrix.features }}
save-if: ${{ github.ref == 'refs/heads/master' }}
@@ -187,7 +221,7 @@ jobs:
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
@@ -200,9 +234,8 @@ jobs:
fail-fast: false
matrix:
rust-version: [
- # 1.72.0, # current stable
- # beta,
- nightly-2023-09-10
+ 1.75.0, # current stable
+ beta,
]
steps:
- uses: actions/checkout@v4
@@ -214,12 +247,11 @@ jobs:
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
- - name: Run cargo clippy
- run: cargo clippy
+ - run: cargo clippy --all-targets --all-features
ipfs-integration-test:
name: IPFS Integration tests
@@ -231,7 +263,7 @@ jobs:
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
save-if: ${{ github.ref == 'refs/heads/master' }}
@@ -250,7 +282,7 @@ jobs:
- uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
shared-key: stable-cache
save-if: false
@@ -263,13 +295,31 @@ jobs:
cargo check --manifest-path "$toml";
done
+ - uses: taiki-e/cache-cargo-install-action@v1
+ with:
+ tool: wasm-pack@0.12.0
+
+ - name: Build webrtc-browser example
+ run: |
+ cd examples/browser-webrtc
+ wasm-pack build --target web --out-dir static
+
semver:
runs-on: ubuntu-latest
+ env:
+ # Unset the global `RUSTFLAGS` env to allow warnings.
+ # cargo-semver-checks intentionally re-locks dependency versions
+ # before checking, and we shouldn't fail here if a dep has a warning.
+ #
+ # More context:
+ # https://github.com/libp2p/rust-libp2p/pull/4932#issuecomment-1829014527
+ # https://github.com/obi1kenobi/cargo-semver-checks/issues/589
+ RUSTFLAGS: ''
steps:
- uses: actions/checkout@v4
- - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.24.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
+ - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.27.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
shell: bash
- - uses: obi1kenobi/cargo-semver-checks-action@e275dda72e250d4df5b564e969e1348d67fefa52 # v2
+ - uses: obi1kenobi/cargo-semver-checks-action@48f4ef7da6d907d69d18249e0ba79aa98c61b9db # v2
rustfmt:
runs-on: ubuntu-latest
@@ -299,8 +349,6 @@ jobs:
ALL_FEATURES=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "libp2p") | .features | keys | map(select(. != "full")) | sort | join(" ")')
FULL_FEATURE=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "libp2p") | .features["full"] | sort | join(" ")')
- test "$ALL_FEATURES = $FULL_FEATURE"
-
echo "$ALL_FEATURES";
echo "$FULL_FEATURE";
@@ -326,12 +374,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- run: cargo install --version 0.10.0 pb-rs --locked
- name: Glob match
- uses: tj-actions/glob@v17
+ uses: tj-actions/glob@v20
id: glob
with:
files: |
@@ -352,7 +400,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
+ - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- run: cargo metadata --locked --format-version=1 > /dev/null
cargo-deny:
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
index 3b39ef7e1d61..b9cd82897c24 100644
--- a/.github/workflows/docker-image.yml
+++ b/.github/workflows/docker-image.yml
@@ -34,6 +34,11 @@ jobs:
with:
context: .
file: ./misc/server/Dockerfile
- push: ${{ ! github.event.pull_request.head.repo.fork }} # Only push image if we have the required permissions, i.e. not running from a fork
+ push: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} # Only push image if we have the required permissions, i.e. not running from a fork
+ cache-from: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' && type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=rust-libp2p-server }}
+ cache-to: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' && type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=rust-libp2p-server }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+ env:
+ AWS_ACCESS_KEY_ID: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index bffcc60d2eaa..b2a761fd8c13 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -24,7 +24,7 @@ jobs:
echo "" > target/doc/index.html
cp -r target/doc/* ./host-docs
- name: Upload documentation
- uses: actions/upload-pages-artifact@v2.0.0
+ uses: actions/upload-pages-artifact@v3.0.1
with:
path: "host-docs/"
@@ -42,5 +42,5 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
- uses: actions/deploy-pages@v2
+ uses: actions/deploy-pages@v4
diff --git a/.github/workflows/interop-test.yml b/.github/workflows/interop-test.yml
index 8fa00f0a8f60..f39508970893 100644
--- a/.github/workflows/interop-test.yml
+++ b/.github/workflows/interop-test.yml
@@ -10,8 +10,8 @@ concurrency:
cancel-in-progress: true
jobs:
- run-multidim-interop:
- name: Run multidimensional interoperability tests
+ run-transport-interop:
+ name: Run transport interoperability tests
runs-on: ${{ fromJSON(github.repository == 'libp2p/rust-libp2p' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }}
strategy:
matrix:
@@ -29,7 +29,7 @@ jobs:
FLAVOUR: ${{ matrix.flavour }}
- name: Run ${{ matrix.flavour }} tests
- uses: libp2p/test-plans/.github/actions/run-interop-ping-test@master
+ uses: libp2p/test-plans/.github/actions/run-transport-interop-test@master
with:
test-filter: ${{ matrix.flavour }}-rust-libp2p-head
extra-versions: ${{ github.workspace }}/interop-tests/${{ matrix.flavour }}-ping-version.json
@@ -37,3 +37,20 @@ jobs:
s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
worker-count: 16
+ run-holepunching-interop:
+ name: Run hole-punch interoperability tests
+ runs-on: ${{ fromJSON(github.repository == 'libp2p/rust-libp2p' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }}
+ steps:
+ - uses: actions/checkout@v4
+ - uses: docker/setup-buildx-action@v3
+ - name: Build image
+ run: docker buildx build --load -t rust-libp2p-head . -f hole-punching-tests/Dockerfile
+ - name: Run tests
+ uses: libp2p/test-plans/.github/actions/run-interop-hole-punch-test@master
+ with:
+ test-filter: rust-libp2p-head
+ extra-versions: ${{ github.workspace }}/hole-punching-tests/version.json
+ s3-cache-bucket: libp2p-by-tf-aws-bootstrap
+ s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
+ s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
+ worker-count: 16
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f6b32c35f979..3c3466708c9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,7 +24,6 @@
## Transport Protocols & Upgrades
-- [`libp2p-deflate` CHANGELOG](transports/deflate/CHANGELOG.md)
- [`libp2p-dns` CHANGELOG](transports/dns/CHANGELOG.md)
- [`libp2p-noise` CHANGELOG](transports/noise/CHANGELOG.md)
- [`libp2p-perf` CHANGELOG](transports/perf/CHANGELOG.md)
@@ -32,10 +31,11 @@
- [`libp2p-pnet` CHANGELOG](transports/pnet/CHANGELOG.md)
- [`libp2p-quic` CHANGELOG](transports/quic/CHANGELOG.md)
- [`libp2p-tcp` CHANGELOG](transports/tcp/CHANGELOG.md)
+- [`libp2p-tls` CHANGELOG](transports/tls/CHANGELOG.md)
- [`libp2p-uds` CHANGELOG](transports/uds/CHANGELOG.md)
- [`libp2p-wasm-ext` CHANGELOG](transports/wasm-ext/CHANGELOG.md)
- [`libp2p-websocket` CHANGELOG](transports/websocket/CHANGELOG.md)
-- [`libp2p-tls` CHANGELOG](transports/tls/CHANGELOG.md)
+- [`libp2p-websocket-websys` CHANGELOG](transports/websocket-websys/CHANGELOG.md)
## Multiplexers
diff --git a/Cargo.lock b/Cargo.lock
index 7a913d157a54..92929a8bae1a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17,15 +17,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
-[[package]]
-name = "aead"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877"
-dependencies = [
- "generic-array",
-]
-
[[package]]
name = "aead"
version = "0.5.2"
@@ -36,18 +27,6 @@ dependencies = [
"generic-array",
]
-[[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.3"
@@ -55,47 +34,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2"
dependencies = [
"cfg-if",
- "cipher 0.4.4",
+ "cipher",
"cpufeatures",
]
[[package]]
name = "aes-gcm"
-version = "0.9.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f"
-dependencies = [
- "aead 0.4.3",
- "aes 0.7.5",
- "cipher 0.3.0",
- "ctr 0.7.0",
- "ghash 0.4.4",
- "subtle",
-]
-
-[[package]]
-name = "aes-gcm"
-version = "0.10.2"
+version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237"
+checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
dependencies = [
- "aead 0.5.2",
- "aes 0.8.3",
- "cipher 0.4.4",
- "ctr 0.9.2",
- "ghash 0.5.0",
+ "aead",
+ "aes",
+ "cipher",
+ "ctr",
+ "ghash",
"subtle",
]
[[package]]
name = "ahash"
-version = "0.8.3"
+version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
+checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
+ "zerocopy",
]
[[package]]
@@ -130,16 +96,15 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anstream"
-version = "0.3.2"
+version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
+checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
- "is-terminal",
"utf8parse",
]
@@ -164,24 +129,24 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
dependencies = [
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
name = "anstyle-wincon"
-version = "1.0.1"
+version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
+checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
dependencies = [
"anstyle",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
name = "anyhow"
-version = "1.0.75"
+version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
+checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "arbitrary"
@@ -269,7 +234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35"
dependencies = [
"concurrent-queue",
- "event-listener",
+ "event-listener 2.5.3",
"futures-core",
]
@@ -279,11 +244,11 @@ version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb"
dependencies = [
- "async-lock",
+ "async-lock 2.7.0",
"async-task",
"concurrent-queue",
"fastrand 1.9.0",
- "futures-lite",
+ "futures-lite 1.13.0",
"slab",
]
@@ -293,10 +258,10 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06"
dependencies = [
- "async-lock",
+ "async-lock 2.7.0",
"autocfg",
"blocking",
- "futures-lite",
+ "futures-lite 1.13.0",
]
[[package]]
@@ -307,10 +272,10 @@ checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776"
dependencies = [
"async-channel",
"async-executor",
- "async-io",
- "async-lock",
+ "async-io 1.13.0",
+ "async-lock 2.7.0",
"blocking",
- "futures-lite",
+ "futures-lite 1.13.0",
"once_cell",
]
@@ -320,27 +285,57 @@ version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af"
dependencies = [
- "async-lock",
+ "async-lock 2.7.0",
"autocfg",
"cfg-if",
"concurrent-queue",
- "futures-lite",
+ "futures-lite 1.13.0",
"log",
"parking",
- "polling",
- "rustix 0.37.23",
+ "polling 2.8.0",
+ "rustix 0.37.25",
"slab",
"socket2 0.4.9",
"waker-fn",
]
+[[package]]
+name = "async-io"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65"
+dependencies = [
+ "async-lock 3.1.0",
+ "cfg-if",
+ "concurrent-queue",
+ "futures-io",
+ "futures-lite 2.0.1",
+ "parking",
+ "polling 3.3.0",
+ "rustix 0.38.31",
+ "slab",
+ "tracing",
+ "windows-sys 0.52.0",
+]
+
[[package]]
name = "async-lock"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7"
dependencies = [
- "event-listener",
+ "event-listener 2.5.3",
+]
+
+[[package]]
+name = "async-lock"
+version = "3.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7"
+dependencies = [
+ "event-listener 3.1.0",
+ "event-listener-strategy",
+ "pin-project-lite",
]
[[package]]
@@ -349,10 +344,10 @@ version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4051e67316bc7eff608fe723df5d32ed639946adcd69e07df41fd42a7b411f1f"
dependencies = [
- "async-io",
+ "async-io 1.13.0",
"autocfg",
"blocking",
- "futures-lite",
+ "futures-lite 1.13.0",
]
[[package]]
@@ -361,16 +356,16 @@ version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9"
dependencies = [
- "async-io",
- "async-lock",
+ "async-io 1.13.0",
+ "async-lock 2.7.0",
"autocfg",
"blocking",
"cfg-if",
- "event-listener",
- "futures-lite",
- "rustix 0.37.23",
+ "event-listener 2.5.3",
+ "futures-lite 1.13.0",
+ "rustix 0.37.25",
"signal-hook",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -382,20 +377,20 @@ dependencies = [
"async-attributes",
"async-channel",
"async-global-executor",
- "async-io",
- "async-lock",
+ "async-io 1.13.0",
+ "async-lock 2.7.0",
"async-process",
"crossbeam-utils",
"futures-channel",
"futures-core",
"futures-io",
- "futures-lite",
+ "futures-lite 1.13.0",
"gloo-timers",
"kv-log-macro",
"log",
"memchr",
"once_cell",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"pin-utils",
"slab",
"wasm-bindgen-futures",
@@ -403,17 +398,17 @@ dependencies = [
[[package]]
name = "async-std-resolver"
-version = "0.23.0"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0354a68a52265a3bde76005ddd2726624ef8624614f7f58871301de205a58a59"
+checksum = "3c0ed2b6671c13d2c28756c5a64e04759c1e0b5d3d7ac031f521c3561e21fbcb"
dependencies = [
"async-std",
"async-trait",
"futures-io",
"futures-util",
+ "hickory-resolver",
"pin-utils",
- "socket2 0.5.4",
- "trust-dns-resolver",
+ "socket2 0.5.5",
]
[[package]]
@@ -424,26 +419,26 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae"
[[package]]
name = "async-trait"
-version = "0.1.73"
+version = "0.1.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
+checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
name = "asynchronous-codec"
-version = "0.6.2"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568"
+checksum = "a860072022177f903e59730004fb5dc13db9275b79bb2aef7ba8ce831956c233"
dependencies = [
"bytes",
"futures-sink",
"futures-util",
"memchr",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
]
[[package]]
@@ -458,7 +453,7 @@ version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d9a9bf8b79a749ee0b911b91b671cc2b6c670bdbc7e3dfd537576ddc94bb2a2"
dependencies = [
- "http",
+ "http 0.2.9",
"log",
"url",
]
@@ -474,10 +469,11 @@ name = "autonat-example"
version = "0.1.0"
dependencies = [
"clap",
- "env_logger 0.10.0",
"futures",
"libp2p",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -487,19 +483,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
dependencies = [
"async-trait",
- "axum-core",
+ "axum-core 0.3.4",
"bitflags 1.3.2",
"bytes",
"futures-util",
- "http",
- "http-body",
- "hyper",
+ "http 0.2.9",
+ "http-body 0.4.5",
+ "hyper 0.14.27",
+ "itoa",
+ "matchit",
+ "memchr",
+ "mime",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustversion",
+ "serde",
+ "sync_wrapper",
+ "tower",
+ "tower-layer",
+ "tower-service",
+]
+
+[[package]]
+name = "axum"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e"
+dependencies = [
+ "async-trait",
+ "axum-core 0.4.3",
+ "bytes",
+ "futures-util",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "http-body-util",
+ "hyper 1.1.0",
+ "hyper-util",
"itoa",
"matchit",
"memchr",
"mime",
"percent-encoding",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"rustversion",
"serde",
"serde_json",
@@ -510,6 +535,7 @@ dependencies = [
"tower",
"tower-layer",
"tower-service",
+ "tracing",
]
[[package]]
@@ -521,12 +547,33 @@ dependencies = [
"async-trait",
"bytes",
"futures-util",
- "http",
- "http-body",
+ "http 0.2.9",
+ "http-body 0.4.5",
+ "mime",
+ "rustversion",
+ "tower-layer",
+ "tower-service",
+]
+
+[[package]]
+name = "axum-core"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3"
+dependencies = [
+ "async-trait",
+ "bytes",
+ "futures-util",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "http-body-util",
"mime",
+ "pin-project-lite",
"rustversion",
+ "sync_wrapper",
"tower-layer",
"tower-service",
+ "tracing",
]
[[package]]
@@ -564,9 +611,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "base64"
-version = "0.21.4"
+version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
+checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64ct"
@@ -576,9 +623,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]]
name = "basic-toml"
-version = "0.1.4"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6"
+checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5"
dependencies = [
"serde",
]
@@ -606,9 +653,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
-version = "2.3.3"
+version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
+checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]]
name = "blake2"
@@ -653,11 +700,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65"
dependencies = [
"async-channel",
- "async-lock",
+ "async-lock 2.7.0",
"async-task",
"atomic-waker",
"fastrand 1.9.0",
- "futures-lite",
+ "futures-lite 1.13.0",
"log",
]
@@ -666,14 +713,12 @@ name = "browser-webrtc-example"
version = "0.1.0"
dependencies = [
"anyhow",
- "axum",
- "env_logger 0.10.0",
+ "axum 0.7.4",
"futures",
"js-sys",
"libp2p",
"libp2p-webrtc",
"libp2p-webrtc-websys",
- "log",
"mime_guess",
"rand 0.8.5",
"rust-embed",
@@ -681,9 +726,11 @@ dependencies = [
"tokio-util",
"tower",
"tower-http",
+ "tracing",
+ "tracing-subscriber",
+ "tracing-wasm",
"wasm-bindgen",
"wasm-bindgen-futures",
- "wasm-logger",
"web-sys",
]
@@ -714,9 +761,9 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
name = "byteorder"
-version = "1.4.3"
+version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
+checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
@@ -739,23 +786,26 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
dependencies = [
- "cipher 0.4.4",
+ "cipher",
]
[[package]]
name = "cbor4ii"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "13e8c816014cad3f58c2f0607677e8d2c6f76754dd8e735461a440b27b95199c"
+checksum = "59b4c883b9cc4757b061600d39001d4d0232bece4a3174696cf8f58a14db107d"
dependencies = [
"serde",
]
[[package]]
name = "cc"
-version = "1.0.79"
+version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
[[package]]
name = "ccm"
@@ -763,9 +813,9 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ae3c82e4355234767756212c570e29833699ab63e6ffd161887314cc5b43847"
dependencies = [
- "aead 0.5.2",
- "cipher 0.4.4",
- "ctr 0.9.2",
+ "aead",
+ "cipher",
+ "ctr",
"subtle",
]
@@ -777,25 +827,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chacha20"
-version = "0.8.2"
+version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6"
+checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
dependencies = [
"cfg-if",
- "cipher 0.3.0",
+ "cipher",
"cpufeatures",
- "zeroize",
]
[[package]]
name = "chacha20poly1305"
-version = "0.9.1"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5"
+checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
dependencies = [
- "aead 0.4.3",
+ "aead",
"chacha20",
- "cipher 0.3.0",
+ "cipher",
"poly1305",
"zeroize",
]
@@ -805,10 +854,11 @@ name = "chat-example"
version = "0.1.0"
dependencies = [
"async-trait",
- "env_logger 0.10.0",
"futures",
"libp2p",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -838,15 +888,6 @@ dependencies = [
"half",
]
-[[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"
@@ -855,24 +896,24 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
dependencies = [
"crypto-common",
"inout",
+ "zeroize",
]
[[package]]
name = "clap"
-version = "4.3.23"
+version = "4.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3"
+checksum = "58e54881c004cec7895b0068a0a954cd5d62da01aef83fa35b1e594497bf5445"
dependencies = [
"clap_builder",
"clap_derive",
- "once_cell",
]
[[package]]
name = "clap_builder"
-version = "4.3.23"
+version = "4.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98"
+checksum = "59cb82d7f531603d2fd1f507441cdd35184fa81beff7bd489570de7f773460bb"
dependencies = [
"anstream",
"anstyle",
@@ -882,21 +923,21 @@ dependencies = [
[[package]]
name = "clap_derive"
-version = "4.3.12"
+version = "4.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050"
+checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
name = "clap_lex"
-version = "0.5.0"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
+checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
[[package]]
name = "colorchoice"
@@ -913,7 +954,7 @@ dependencies = [
"bytes",
"futures-core",
"memchr",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"tokio",
"tokio-util",
]
@@ -1003,15 +1044,6 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484"
-[[package]]
-name = "crc32fast"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
-dependencies = [
- "cfg-if",
-]
-
[[package]]
name = "criterion"
version = "0.5.1"
@@ -1130,22 +1162,13 @@ dependencies = [
"subtle",
]
-[[package]]
-name = "ctr"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481"
-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",
+ "cipher",
]
[[package]]
@@ -1161,22 +1184,9 @@ dependencies = [
[[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.1.1"
+version = "4.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c"
+checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348"
dependencies = [
"cfg-if",
"cpufeatures",
@@ -1197,14 +1207,14 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
name = "data-encoding"
-version = "2.4.0"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
+checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]]
name = "data-encoding-macro"
@@ -1231,11 +1241,13 @@ name = "dcutr-example"
version = "0.1.0"
dependencies = [
"clap",
- "env_logger 0.10.0",
"futures",
"futures-timer",
"libp2p",
"log",
+ "tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -1312,7 +1324,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
@@ -1321,9 +1333,10 @@ version = "0.1.0"
dependencies = [
"async-std",
"async-trait",
- "env_logger 0.10.0",
"futures",
"libp2p",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -1358,15 +1371,16 @@ dependencies = [
[[package]]
name = "ed25519-dalek"
-version = "2.0.0"
+version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980"
+checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871"
dependencies = [
- "curve25519-dalek 4.1.1",
+ "curve25519-dalek",
"ed25519",
"rand_core 0.6.4",
"serde",
"sha2 0.10.8",
+ "subtle",
"zeroize",
]
@@ -1415,7 +1429,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
@@ -1430,9 +1444,9 @@ dependencies = [
[[package]]
name = "env_logger"
-version = "0.10.0"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
+checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"humantime",
"is-terminal",
@@ -1449,30 +1463,40 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
-version = "0.3.1"
+version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
+checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [
- "errno-dragonfly",
"libc",
- "windows-sys",
+ "windows-sys 0.52.0",
]
[[package]]
-name = "errno-dragonfly"
-version = "0.1.2"
+name = "event-listener"
+version = "2.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
+checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
+
+[[package]]
+name = "event-listener"
+version = "3.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2"
dependencies = [
- "cc",
- "libc",
+ "concurrent-queue",
+ "parking",
+ "pin-project-lite",
]
[[package]]
-name = "event-listener"
-version = "2.5.3"
+name = "event-listener-strategy"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
+checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160"
+dependencies = [
+ "event-listener 3.1.0",
+ "pin-project-lite",
+]
[[package]]
name = "fantoccini"
@@ -1484,8 +1508,8 @@ dependencies = [
"cookie",
"futures-core",
"futures-util",
- "http",
- "hyper",
+ "http 0.2.9",
+ "hyper 0.14.27",
"hyper-rustls",
"mime",
"serde",
@@ -1507,9 +1531,9 @@ dependencies = [
[[package]]
name = "fastrand"
-version = "2.0.0"
+version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
+checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "ff"
@@ -1534,23 +1558,14 @@ dependencies = [
"async-std",
"clap",
"either",
- "env_logger 0.10.0",
"futures",
"libp2p",
"serde",
+ "tracing",
+ "tracing-subscriber",
"void",
]
-[[package]]
-name = "flate2"
-version = "1.0.27"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
-dependencies = [
- "crc32fast",
- "miniz_oxide",
-]
-
[[package]]
name = "fnv"
version = "1.0.7"
@@ -1574,18 +1589,18 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
-version = "1.2.0"
+version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
+checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
dependencies = [
"percent-encoding",
]
[[package]]
name = "futures"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
+checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [
"futures-channel",
"futures-core",
@@ -1598,8 +1613,9 @@ dependencies = [
[[package]]
name = "futures-bounded"
-version = "0.1.0"
+version = "0.2.3"
dependencies = [
+ "futures",
"futures-timer",
"futures-util",
"tokio",
@@ -1607,9 +1623,9 @@ dependencies = [
[[package]]
name = "futures-channel"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
+checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
dependencies = [
"futures-core",
"futures-sink",
@@ -1617,15 +1633,15 @@ dependencies = [
[[package]]
name = "futures-core"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
+checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
[[package]]
name = "futures-executor"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
+checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
dependencies = [
"futures-core",
"futures-task",
@@ -1635,9 +1651,9 @@ dependencies = [
[[package]]
name = "futures-io"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
+checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]]
name = "futures-lite"
@@ -1650,19 +1666,29 @@ dependencies = [
"futures-io",
"memchr",
"parking",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"waker-fn",
]
+[[package]]
+name = "futures-lite"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+]
+
[[package]]
name = "futures-macro"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
+checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
@@ -1672,20 +1698,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28"
dependencies = [
"futures-io",
- "rustls 0.21.7",
+ "rustls 0.21.9",
]
[[package]]
name = "futures-sink"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
+checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]]
name = "futures-task"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
+checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]]
name = "futures-ticker"
@@ -1710,9 +1736,9 @@ dependencies = [
[[package]]
name = "futures-util"
-version = "0.3.28"
+version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
+checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [
"futures-channel",
"futures-core",
@@ -1721,7 +1747,7 @@ dependencies = [
"futures-sink",
"futures-task",
"memchr",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"pin-utils",
"slab",
]
@@ -1762,9 +1788,9 @@ dependencies = [
[[package]]
name = "getrandom"
-version = "0.2.10"
+version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
+checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
dependencies = [
"cfg-if",
"js-sys",
@@ -1773,16 +1799,6 @@ dependencies = [
"wasm-bindgen",
]
-[[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"
@@ -1790,7 +1806,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40"
dependencies = [
"opaque-debug",
- "polyval 0.6.1",
+ "polyval",
]
[[package]]
@@ -1843,17 +1859,36 @@ dependencies = [
[[package]]
name = "h2"
-version = "0.3.20"
+version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049"
+checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
- "http",
- "indexmap 1.9.3",
+ "http 0.2.9",
+ "indexmap 2.2.1",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
+[[package]]
+name = "h2"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1d308f63daf4181410c242d34c11f928dcb3aa105852019e043c9d1f4e4368a"
+dependencies = [
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "http 1.0.0",
+ "indexmap 2.2.1",
"slab",
"tokio",
"tokio-util",
@@ -1874,9 +1909,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
-version = "0.14.0"
+version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
+checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"ahash",
"allocator-api2",
@@ -1913,21 +1948,67 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f"
[[package]]
-name = "hkdf"
-version = "0.12.3"
+name = "hickory-proto"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437"
+checksum = "091a6fbccf4860009355e3efc52ff4acf37a63489aad7435372d44ceeb6fbbcf"
dependencies = [
- "hmac 0.12.1",
+ "async-trait",
+ "cfg-if",
+ "data-encoding",
+ "enum-as-inner",
+ "futures-channel",
+ "futures-io",
+ "futures-util",
+ "idna 0.4.0",
+ "ipnet",
+ "once_cell",
+ "rand 0.8.5",
+ "socket2 0.5.5",
+ "thiserror",
+ "tinyvec",
+ "tokio",
+ "tracing",
+ "url",
]
[[package]]
-name = "hmac"
-version = "0.8.1"
+name = "hickory-resolver"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
+checksum = "35b8f021164e6a984c9030023544c57789c51760065cd510572fedcfb04164e8"
dependencies = [
- "crypto-mac",
+ "cfg-if",
+ "futures-util",
+ "hickory-proto",
+ "ipconfig",
+ "lru-cache",
+ "once_cell",
+ "parking_lot",
+ "rand 0.8.5",
+ "resolv-conf",
+ "smallvec",
+ "thiserror",
+ "tokio",
+ "tracing",
+]
+
+[[package]]
+name = "hkdf"
+version = "0.12.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
+dependencies = [
+ "hmac 0.12.1",
+]
+
+[[package]]
+name = "hmac"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
+dependencies = [
+ "crypto-mac",
"digest 0.9.0",
]
@@ -1951,6 +2032,22 @@ dependencies = [
"hmac 0.8.1",
]
+[[package]]
+name = "hole-punching-tests"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "either",
+ "env_logger 0.10.2",
+ "futures",
+ "libp2p",
+ "redis",
+ "serde",
+ "serde_json",
+ "tokio",
+ "tracing",
+]
+
[[package]]
name = "hostname"
version = "0.3.1"
@@ -1973,6 +2070,17 @@ dependencies = [
"itoa",
]
+[[package]]
+name = "http"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea"
+dependencies = [
+ "bytes",
+ "fnv",
+ "itoa",
+]
+
[[package]]
name = "http-body"
version = "0.4.5"
@@ -1980,15 +2088,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
dependencies = [
"bytes",
- "http",
- "pin-project-lite 0.2.12",
+ "http 0.2.9",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "http-body"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
+dependencies = [
+ "bytes",
+ "http 1.0.0",
+]
+
+[[package]]
+name = "http-body-util"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840"
+dependencies = [
+ "bytes",
+ "futures-util",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "pin-project-lite",
]
[[package]]
name = "http-range-header"
-version = "0.3.1"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f"
+checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe"
[[package]]
name = "httparse"
@@ -2018,13 +2149,13 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
- "h2",
- "http",
- "http-body",
+ "h2 0.3.24",
+ "http 0.2.9",
+ "http-body 0.4.5",
"httparse",
"httpdate",
"itoa",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"socket2 0.4.9",
"tokio",
"tower-service",
@@ -2032,19 +2163,50 @@ dependencies = [
"want",
]
+[[package]]
+name = "hyper"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "h2 0.4.0",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "tokio",
+]
+
[[package]]
name = "hyper-rustls"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c"
dependencies = [
- "http",
- "hyper",
+ "http 0.2.9",
+ "hyper 0.14.27",
"log",
"rustls 0.20.8",
"rustls-native-certs",
"tokio",
- "tokio-rustls 0.23.4",
+ "tokio-rustls",
+]
+
+[[package]]
+name = "hyper-timeout"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
+dependencies = [
+ "hyper 0.14.27",
+ "pin-project-lite",
+ "tokio",
+ "tokio-io-timeout",
]
[[package]]
@@ -2054,21 +2216,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
- "hyper",
+ "hyper 0.14.27",
"native-tls",
"tokio",
"tokio-native-tls",
]
+[[package]]
+name = "hyper-util"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "hyper 1.1.0",
+ "pin-project-lite",
+ "socket2 0.5.5",
+ "tokio",
+ "tracing",
+]
+
[[package]]
name = "identify-example"
version = "0.1.0"
dependencies = [
"async-std",
"async-trait",
- "env_logger 0.10.0",
"futures",
"libp2p",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -2081,23 +2262,33 @@ dependencies = [
"unicode-normalization",
]
+[[package]]
+name = "idna"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
+dependencies = [
+ "unicode-bidi",
+ "unicode-normalization",
+]
+
[[package]]
name = "if-addrs"
-version = "0.7.0"
+version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9"
+checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a"
dependencies = [
"libc",
- "winapi",
+ "windows-sys 0.48.0",
]
[[package]]
name = "if-watch"
-version = "3.0.1"
+version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9465340214b296cd17a0009acdb890d6160010b8adf8f78a00d0d7ab270f79f"
+checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e"
dependencies = [
- "async-io",
+ "async-io 2.3.1",
"core-foundation",
"fnv",
"futures",
@@ -2113,16 +2304,16 @@ dependencies = [
[[package]]
name = "igd-next"
-version = "0.14.2"
+version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57e065e90a518ab5fedf79aa1e4b784e10f8e484a834f6bda85c42633a2cb7af"
+checksum = "064d90fec10d541084e7b39ead8875a5a80d9114a2b18791565253bae25f49e4"
dependencies = [
"async-trait",
"attohttpc",
"bytes",
"futures",
- "http",
- "hyper",
+ "http 0.2.9",
+ "hyper 0.14.27",
"log",
"rand 0.8.5",
"tokio",
@@ -2142,12 +2333,12 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.0.0"
+version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
+checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
dependencies = [
"equivalent",
- "hashbrown 0.14.0",
+ "hashbrown 0.14.3",
]
[[package]]
@@ -2196,18 +2387,18 @@ name = "interop-tests"
version = "0.1.0"
dependencies = [
"anyhow",
- "axum",
+ "axum 0.7.4",
"console_error_panic_hook",
"either",
- "env_logger 0.10.0",
"futures",
"futures-timer",
"instant",
"libp2p",
"libp2p-mplex",
+ "libp2p-noise",
+ "libp2p-tls",
"libp2p-webrtc",
"libp2p-webrtc-websys",
- "log",
"mime_guess",
"rand 0.8.5",
"redis",
@@ -2233,7 +2424,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [
"hermit-abi",
"libc",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -2242,9 +2433,9 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f"
dependencies = [
- "socket2 0.5.4",
+ "socket2 0.5.5",
"widestring",
- "windows-sys",
+ "windows-sys 0.48.0",
"winreg",
]
@@ -2255,10 +2446,12 @@ dependencies = [
"anyhow",
"async-trait",
"clap",
- "env_logger 0.10.0",
+ "env_logger 0.10.2",
"futures",
"libp2p",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -2267,10 +2460,11 @@ version = "0.1.0"
dependencies = [
"async-trait",
"either",
- "env_logger 0.10.0",
"futures",
"libp2p",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -2286,8 +2480,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
- "rustix 0.38.4",
- "windows-sys",
+ "rustix 0.38.31",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -2307,9 +2501,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "js-sys"
-version = "0.3.64"
+version = "0.3.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a"
+checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee"
dependencies = [
"wasm-bindgen",
]
@@ -2327,7 +2521,7 @@ dependencies = [
name = "keygen"
version = "0.1.0"
dependencies = [
- "base64 0.21.4",
+ "base64 0.21.7",
"clap",
"libp2p-core",
"libp2p-identity",
@@ -2353,30 +2547,28 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.149"
+version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
+checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libp2p"
-version = "0.52.3"
+version = "0.53.2"
dependencies = [
"async-std",
"async-trait",
"bytes",
"clap",
"either",
- "env_logger 0.10.0",
"futures",
"futures-timer",
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
"instant",
"libp2p-allow-block-list",
"libp2p-autonat",
"libp2p-connection-limits",
"libp2p-core",
"libp2p-dcutr",
- "libp2p-deflate",
"libp2p-dns",
"libp2p-floodsub",
"libp2p-gossipsub",
@@ -2386,6 +2578,7 @@ dependencies = [
"libp2p-mdns",
"libp2p-memory-connection-limits",
"libp2p-metrics",
+ "libp2p-mplex",
"libp2p-noise",
"libp2p-ping",
"libp2p-plaintext",
@@ -2399,18 +2592,21 @@ dependencies = [
"libp2p-tls",
"libp2p-uds",
"libp2p-upnp",
- "libp2p-wasm-ext",
"libp2p-websocket",
+ "libp2p-websocket-websys",
"libp2p-webtransport-websys",
"libp2p-yamux",
"multiaddr",
"pin-project",
+ "rw-stream-sink",
+ "thiserror",
"tokio",
+ "tracing-subscriber",
]
[[package]]
name = "libp2p-allow-block-list"
-version = "0.2.0"
+version = "0.3.0"
dependencies = [
"async-std",
"libp2p-core",
@@ -2423,11 +2619,11 @@ dependencies = [
[[package]]
name = "libp2p-autonat"
-version = "0.11.0"
+version = "0.12.0"
dependencies = [
"async-std",
"async-trait",
- "env_logger 0.10.0",
+ "asynchronous-codec",
"futures",
"futures-timer",
"instant",
@@ -2436,14 +2632,16 @@ dependencies = [
"libp2p-request-response",
"libp2p-swarm",
"libp2p-swarm-test",
- "log",
"quick-protobuf",
+ "quick-protobuf-codec",
"rand 0.8.5",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
name = "libp2p-connection-limits"
-version = "0.2.1"
+version = "0.3.1"
dependencies = [
"async-std",
"libp2p-core",
@@ -2460,7 +2658,7 @@ dependencies = [
[[package]]
name = "libp2p-core"
-version = "0.40.1"
+version = "0.41.2"
dependencies = [
"async-std",
"either",
@@ -2471,7 +2669,6 @@ dependencies = [
"libp2p-identity",
"libp2p-mplex",
"libp2p-noise",
- "log",
"multiaddr",
"multihash",
"multistream-select",
@@ -2485,20 +2682,21 @@ dependencies = [
"serde",
"smallvec",
"thiserror",
- "unsigned-varint",
+ "tracing",
+ "unsigned-varint 0.8.0",
"void",
]
[[package]]
name = "libp2p-dcutr"
-version = "0.10.0"
+version = "0.11.0"
dependencies = [
"async-std",
"asynchronous-codec",
"clap",
"either",
- "env_logger 0.10.0",
"futures",
+ "futures-bounded",
"futures-timer",
"instant",
"libp2p-core",
@@ -2513,80 +2711,68 @@ dependencies = [
"libp2p-swarm-test",
"libp2p-tcp",
"libp2p-yamux",
- "log",
+ "lru",
"quick-protobuf",
"quick-protobuf-codec",
"rand 0.8.5",
"thiserror",
+ "tracing",
+ "tracing-subscriber",
"void",
]
-[[package]]
-name = "libp2p-deflate"
-version = "0.40.1"
-dependencies = [
- "async-std",
- "flate2",
- "futures",
- "futures_ringbuf",
- "libp2p-core",
- "libp2p-tcp",
- "quickcheck-ext",
- "rand 0.8.5",
-]
-
[[package]]
name = "libp2p-dns"
-version = "0.40.1"
+version = "0.41.1"
dependencies = [
"async-std",
"async-std-resolver",
"async-trait",
- "env_logger 0.10.0",
"futures",
+ "hickory-resolver",
"libp2p-core",
"libp2p-identity",
- "log",
"parking_lot",
"smallvec",
"tokio",
- "trust-dns-resolver",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
name = "libp2p-floodsub"
-version = "0.43.0"
+version = "0.44.0"
dependencies = [
"asynchronous-codec",
+ "bytes",
"cuckoofilter",
"fnv",
"futures",
"libp2p-core",
"libp2p-identity",
"libp2p-swarm",
- "log",
"quick-protobuf",
"quick-protobuf-codec",
"rand 0.8.5",
"smallvec",
"thiserror",
+ "tracing",
]
[[package]]
name = "libp2p-gossipsub"
-version = "0.45.1"
+version = "0.46.1"
dependencies = [
"async-std",
"asynchronous-codec",
- "base64 0.21.4",
+ "base64 0.21.7",
"byteorder",
"bytes",
"either",
- "env_logger 0.10.0",
"fnv",
"futures",
"futures-ticker",
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
"hex",
"hex_fmt",
"instant",
@@ -2596,7 +2782,6 @@ dependencies = [
"libp2p-swarm",
"libp2p-swarm-test",
"libp2p-yamux",
- "log",
"prometheus-client",
"quick-protobuf",
"quick-protobuf-codec",
@@ -2606,18 +2791,18 @@ dependencies = [
"serde",
"sha2 0.10.8",
"smallvec",
- "unsigned-varint",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-identify"
-version = "0.43.1"
+version = "0.44.2"
dependencies = [
"async-std",
"asynchronous-codec",
"either",
- "env_logger 0.10.0",
"futures",
"futures-bounded",
"futures-timer",
@@ -2625,56 +2810,57 @@ dependencies = [
"libp2p-identity",
"libp2p-swarm",
"libp2p-swarm-test",
- "log",
"lru",
"quick-protobuf",
"quick-protobuf-codec",
"smallvec",
"thiserror",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-identity"
-version = "0.2.5"
+version = "0.2.8"
dependencies = [
"asn1_der",
- "base64 0.21.4",
+ "base64 0.21.7",
"bs58",
"criterion",
"ed25519-dalek",
"hex-literal",
"hkdf",
"libsecp256k1",
- "log",
"multihash",
"p256",
"quick-protobuf",
"quickcheck-ext",
"rand 0.8.5",
- "ring",
+ "ring 0.17.5",
"rmp-serde",
"sec1",
"serde",
"serde_json",
"sha2 0.10.8",
"thiserror",
+ "tracing",
"void",
"zeroize",
]
[[package]]
name = "libp2p-kad"
-version = "0.44.6"
+version = "0.45.4"
dependencies = [
"arrayvec",
"async-std",
"asynchronous-codec",
"bytes",
"either",
- "env_logger 0.10.0",
"fnv",
"futures",
+ "futures-bounded",
"futures-timer",
"instant",
"libp2p-core",
@@ -2684,7 +2870,6 @@ dependencies = [
"libp2p-swarm",
"libp2p-swarm-test",
"libp2p-yamux",
- "log",
"quick-protobuf",
"quick-protobuf-codec",
"quickcheck-ext",
@@ -2693,20 +2878,21 @@ dependencies = [
"sha2 0.10.8",
"smallvec",
"thiserror",
+ "tracing",
+ "tracing-subscriber",
"uint",
- "unsigned-varint",
"void",
]
[[package]]
name = "libp2p-mdns"
-version = "0.44.0"
+version = "0.45.1"
dependencies = [
- "async-io",
+ "async-io 2.3.1",
"async-std",
"data-encoding",
- "env_logger 0.10.0",
"futures",
+ "hickory-proto",
"if-watch",
"libp2p-core",
"libp2p-identity",
@@ -2715,18 +2901,18 @@ dependencies = [
"libp2p-swarm-test",
"libp2p-tcp",
"libp2p-yamux",
- "log",
"rand 0.8.5",
"smallvec",
- "socket2 0.5.4",
+ "socket2 0.5.5",
"tokio",
- "trust-dns-proto",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-memory-connection-limits"
-version = "0.1.0"
+version = "0.2.0"
dependencies = [
"async-std",
"libp2p-core",
@@ -2735,17 +2921,18 @@ dependencies = [
"libp2p-swarm",
"libp2p-swarm-derive",
"libp2p-swarm-test",
- "log",
"memory-stats",
"rand 0.8.5",
"sysinfo",
+ "tracing",
"void",
]
[[package]]
name = "libp2p-metrics"
-version = "0.13.1"
+version = "0.14.1"
dependencies = [
+ "futures",
"instant",
"libp2p-core",
"libp2p-dcutr",
@@ -2756,32 +2943,32 @@ dependencies = [
"libp2p-ping",
"libp2p-relay",
"libp2p-swarm",
- "once_cell",
+ "pin-project",
"prometheus-client",
]
[[package]]
name = "libp2p-mplex"
-version = "0.40.0"
+version = "0.41.0"
dependencies = [
"async-std",
"asynchronous-codec",
"bytes",
"criterion",
- "env_logger 0.10.0",
"futures",
"libp2p-core",
"libp2p-identity",
"libp2p-muxer-test-harness",
"libp2p-plaintext",
"libp2p-tcp",
- "log",
"nohash-hasher",
"parking_lot",
"quickcheck-ext",
"rand 0.8.5",
"smallvec",
- "unsigned-varint",
+ "tracing",
+ "tracing-subscriber",
+ "unsigned-varint 0.8.0",
]
[[package]]
@@ -2792,21 +2979,20 @@ dependencies = [
"futures-timer",
"futures_ringbuf",
"libp2p-core",
- "log",
+ "tracing",
]
[[package]]
name = "libp2p-noise"
-version = "0.43.1"
+version = "0.44.0"
dependencies = [
+ "asynchronous-codec",
"bytes",
- "curve25519-dalek 4.1.1",
- "env_logger 0.10.0",
+ "curve25519-dalek",
"futures",
"futures_ringbuf",
"libp2p-core",
"libp2p-identity",
- "log",
"multiaddr",
"multihash",
"once_cell",
@@ -2817,46 +3003,48 @@ dependencies = [
"snow",
"static_assertions",
"thiserror",
- "x25519-dalek 1.1.1",
+ "tracing",
+ "tracing-subscriber",
+ "x25519-dalek",
"zeroize",
]
[[package]]
name = "libp2p-perf"
-version = "0.2.0"
+version = "0.3.0"
dependencies = [
"anyhow",
- "async-trait",
"clap",
- "env_logger 0.10.0",
"futures",
+ "futures-bounded",
+ "futures-timer",
"instant",
+ "libp2p",
"libp2p-core",
"libp2p-dns",
"libp2p-identity",
"libp2p-quic",
- "libp2p-request-response",
"libp2p-swarm",
"libp2p-swarm-test",
"libp2p-tcp",
"libp2p-tls",
"libp2p-yamux",
- "log",
"rand 0.8.5",
"serde",
"serde_json",
"thiserror",
"tokio",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-ping"
-version = "0.43.1"
+version = "0.44.0"
dependencies = [
"async-std",
"either",
- "env_logger 0.10.0",
"futures",
"futures-timer",
"instant",
@@ -2864,33 +3052,34 @@ dependencies = [
"libp2p-identity",
"libp2p-swarm",
"libp2p-swarm-test",
- "log",
"quickcheck-ext",
"rand 0.8.5",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-plaintext"
-version = "0.40.1"
+version = "0.41.0"
dependencies = [
"asynchronous-codec",
"bytes",
- "env_logger 0.10.0",
"futures",
"futures_ringbuf",
"libp2p-core",
"libp2p-identity",
- "log",
"quick-protobuf",
+ "quick-protobuf-codec",
"quickcheck-ext",
"rand 0.8.5",
- "unsigned-varint",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
name = "libp2p-pnet"
-version = "0.23.0"
+version = "0.24.0"
dependencies = [
"futures",
"libp2p-core",
@@ -2900,22 +3089,21 @@ dependencies = [
"libp2p-tcp",
"libp2p-websocket",
"libp2p-yamux",
- "log",
"pin-project",
"quickcheck-ext",
"rand 0.8.5",
"salsa20",
"sha3",
"tokio",
+ "tracing",
]
[[package]]
name = "libp2p-quic"
-version = "0.9.2"
+version = "0.10.2"
dependencies = [
"async-std",
"bytes",
- "env_logger 0.10.0",
"futures",
"futures-timer",
"if-watch",
@@ -2926,26 +3114,26 @@ dependencies = [
"libp2p-tcp",
"libp2p-tls",
"libp2p-yamux",
- "log",
"parking_lot",
"quickcheck",
"quinn",
"rand 0.8.5",
- "ring",
- "rustls 0.21.7",
- "socket2 0.5.4",
+ "ring 0.16.20",
+ "rustls 0.21.9",
+ "socket2 0.5.5",
"thiserror",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
name = "libp2p-relay"
-version = "0.16.1"
+version = "0.17.1"
dependencies = [
"asynchronous-codec",
"bytes",
"either",
- "env_logger 0.10.0",
"futures",
"futures-bounded",
"futures-timer",
@@ -2955,25 +3143,26 @@ dependencies = [
"libp2p-ping",
"libp2p-plaintext",
"libp2p-swarm",
+ "libp2p-swarm-test",
"libp2p-yamux",
- "log",
"quick-protobuf",
"quick-protobuf-codec",
"quickcheck-ext",
"rand 0.8.5",
"static_assertions",
"thiserror",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-rendezvous"
-version = "0.13.0"
+version = "0.14.0"
dependencies = [
"async-trait",
"asynchronous-codec",
"bimap",
- "env_logger 0.10.0",
"futures",
"futures-timer",
"instant",
@@ -2987,24 +3176,27 @@ dependencies = [
"libp2p-swarm-test",
"libp2p-tcp",
"libp2p-yamux",
- "log",
"quick-protobuf",
"quick-protobuf-codec",
"rand 0.8.5",
"thiserror",
"tokio",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-request-response"
-version = "0.25.1"
+version = "0.26.2"
dependencies = [
+ "anyhow",
"async-std",
"async-trait",
"cbor4ii",
- "env_logger 0.10.0",
"futures",
+ "futures-bounded",
+ "futures-timer",
"futures_ringbuf",
"instant",
"libp2p-core",
@@ -3014,45 +3206,61 @@ dependencies = [
"libp2p-swarm-test",
"libp2p-tcp",
"libp2p-yamux",
- "log",
"rand 0.8.5",
"serde",
"serde_json",
"smallvec",
+ "tracing",
+ "tracing-subscriber",
"void",
]
[[package]]
name = "libp2p-server"
-version = "0.12.3"
+version = "0.12.6"
dependencies = [
- "base64 0.21.4",
+ "base64 0.21.7",
"clap",
- "env_logger 0.10.0",
"futures",
"futures-timer",
- "hyper",
+ "hyper 0.14.27",
"libp2p",
- "log",
"prometheus-client",
"serde",
"serde_derive",
"serde_json",
"tokio",
+ "tracing",
+ "tracing-subscriber",
"zeroize",
]
+[[package]]
+name = "libp2p-stream"
+version = "0.1.0-alpha"
+dependencies = [
+ "futures",
+ "libp2p-core",
+ "libp2p-identity",
+ "libp2p-swarm",
+ "libp2p-swarm-test",
+ "rand 0.8.5",
+ "tokio",
+ "tracing",
+ "tracing-subscriber",
+ "void",
+]
+
[[package]]
name = "libp2p-swarm"
-version = "0.43.5"
+version = "0.44.2"
dependencies = [
"async-std",
"either",
- "env_logger 0.10.0",
"fnv",
"futures",
"futures-timer",
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
"instant",
"libp2p-core",
"libp2p-identify",
@@ -3063,13 +3271,15 @@ dependencies = [
"libp2p-swarm-derive",
"libp2p-swarm-test",
"libp2p-yamux",
- "log",
+ "lru",
"multistream-select",
"once_cell",
"quickcheck-ext",
"rand 0.8.5",
"smallvec",
"tokio",
+ "tracing",
+ "tracing-subscriber",
"trybuild",
"void",
"wasm-bindgen-futures",
@@ -3077,18 +3287,17 @@ dependencies = [
[[package]]
name = "libp2p-swarm-derive"
-version = "0.33.0"
+version = "0.34.3"
dependencies = [
"heck",
- "proc-macro-warning",
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
name = "libp2p-swarm-test"
-version = "0.2.0"
+version = "0.3.0"
dependencies = [
"async-trait",
"futures",
@@ -3099,31 +3308,31 @@ dependencies = [
"libp2p-swarm",
"libp2p-tcp",
"libp2p-yamux",
- "log",
"rand 0.8.5",
+ "tracing",
]
[[package]]
name = "libp2p-tcp"
-version = "0.40.0"
+version = "0.41.0"
dependencies = [
- "async-io",
+ "async-io 2.3.1",
"async-std",
- "env_logger 0.10.0",
"futures",
"futures-timer",
"if-watch",
"libc",
"libp2p-core",
"libp2p-identity",
- "log",
- "socket2 0.5.4",
+ "socket2 0.5.5",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
name = "libp2p-tls"
-version = "0.2.1"
+version = "0.3.0"
dependencies = [
"futures",
"futures-rustls",
@@ -3133,9 +3342,9 @@ dependencies = [
"libp2p-identity",
"libp2p-swarm",
"libp2p-yamux",
- "rcgen 0.10.0",
- "ring",
- "rustls 0.21.7",
+ "rcgen",
+ "ring 0.16.20",
+ "rustls 0.21.9",
"rustls-webpki",
"thiserror",
"tokio",
@@ -3145,49 +3354,36 @@ dependencies = [
[[package]]
name = "libp2p-uds"
-version = "0.39.0"
+version = "0.40.0"
dependencies = [
"async-std",
"futures",
"libp2p-core",
- "log",
"tempfile",
"tokio",
+ "tracing",
]
[[package]]
name = "libp2p-upnp"
-version = "0.1.1"
+version = "0.2.1"
dependencies = [
"futures",
"futures-timer",
"igd-next",
"libp2p-core",
"libp2p-swarm",
- "log",
"tokio",
+ "tracing",
"void",
]
-[[package]]
-name = "libp2p-wasm-ext"
-version = "0.40.0"
-dependencies = [
- "futures",
- "js-sys",
- "libp2p-core",
- "send_wrapper 0.6.0",
- "wasm-bindgen",
- "wasm-bindgen-futures",
-]
-
[[package]]
name = "libp2p-webrtc"
-version = "0.6.1-alpha"
+version = "0.7.1-alpha"
dependencies = [
"async-trait",
"bytes",
- "env_logger 0.10.0",
"futures",
"futures-timer",
"hex",
@@ -3196,23 +3392,24 @@ dependencies = [
"libp2p-identity",
"libp2p-noise",
"libp2p-webrtc-utils",
- "log",
"multihash",
"quickcheck",
"rand 0.8.5",
- "rcgen 0.11.1",
+ "rcgen",
"serde",
"stun",
"thiserror",
"tinytemplate",
"tokio",
"tokio-util",
+ "tracing",
+ "tracing-subscriber",
"webrtc",
]
[[package]]
name = "libp2p-webrtc-utils"
-version = "0.1.0"
+version = "0.2.0"
dependencies = [
"asynchronous-codec",
"bytes",
@@ -3222,7 +3419,6 @@ dependencies = [
"libp2p-core",
"libp2p-identity",
"libp2p-noise",
- "log",
"quick-protobuf",
"quick-protobuf-codec",
"rand 0.8.5",
@@ -3230,30 +3426,24 @@ dependencies = [
"sha2 0.10.8",
"thiserror",
"tinytemplate",
- "unsigned-varint",
+ "tracing",
]
[[package]]
name = "libp2p-webrtc-websys"
-version = "0.1.0-alpha"
+version = "0.3.0-alpha"
dependencies = [
"bytes",
"futures",
- "futures-timer",
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
"hex",
- "hex-literal",
"js-sys",
"libp2p-core",
"libp2p-identity",
- "libp2p-noise",
- "libp2p-ping",
- "libp2p-swarm",
"libp2p-webrtc-utils",
- "log",
"send_wrapper 0.6.0",
- "serde",
"thiserror",
+ "tracing",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -3261,7 +3451,7 @@ dependencies = [
[[package]]
name = "libp2p-websocket"
-version = "0.42.1"
+version = "0.43.0"
dependencies = [
"async-std",
"either",
@@ -3271,31 +3461,50 @@ dependencies = [
"libp2p-dns",
"libp2p-identity",
"libp2p-tcp",
- "log",
"parking_lot",
- "quicksink",
- "rcgen 0.10.0",
+ "pin-project-lite",
+ "rcgen",
"rw-stream-sink",
"soketto",
+ "tracing",
"url",
"webpki-roots",
]
+[[package]]
+name = "libp2p-websocket-websys"
+version = "0.3.1"
+dependencies = [
+ "bytes",
+ "futures",
+ "js-sys",
+ "libp2p-core",
+ "libp2p-identity",
+ "libp2p-noise",
+ "libp2p-yamux",
+ "parking_lot",
+ "send_wrapper 0.6.0",
+ "thiserror",
+ "tracing",
+ "wasm-bindgen",
+ "web-sys",
+]
+
[[package]]
name = "libp2p-webtransport-websys"
-version = "0.1.0"
+version = "0.2.0"
dependencies = [
"futures",
"js-sys",
"libp2p-core",
"libp2p-identity",
"libp2p-noise",
- "log",
"multiaddr",
"multibase",
"multihash",
"send_wrapper 0.6.0",
"thiserror",
+ "tracing",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -3303,15 +3512,17 @@ dependencies = [
[[package]]
name = "libp2p-yamux"
-version = "0.44.1"
+version = "0.45.1"
dependencies = [
"async-std",
+ "either",
"futures",
"libp2p-core",
"libp2p-muxer-test-harness",
- "log",
"thiserror",
- "yamux",
+ "tracing",
+ "yamux 0.12.1",
+ "yamux 0.13.1",
]
[[package]]
@@ -3376,9 +3587,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
[[package]]
name = "linux-raw-sys"
-version = "0.4.3"
+version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0"
+checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
[[package]]
name = "lock_api"
@@ -3401,11 +3612,11 @@ dependencies = [
[[package]]
name = "lru"
-version = "0.12.0"
+version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
+checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7"
dependencies = [
- "hashbrown 0.14.0",
+ "hashbrown 0.14.3",
]
[[package]]
@@ -3485,13 +3696,17 @@ dependencies = [
name = "metrics-example"
version = "0.1.0"
dependencies = [
- "env_logger 0.10.0",
"futures",
- "hyper",
+ "hyper 0.14.27",
"libp2p",
- "log",
+ "opentelemetry",
+ "opentelemetry-otlp",
+ "opentelemetry_api",
"prometheus-client",
"tokio",
+ "tracing",
+ "tracing-opentelemetry",
+ "tracing-subscriber",
]
[[package]]
@@ -3527,20 +3742,20 @@ dependencies = [
[[package]]
name = "mio"
-version = "0.8.8"
+version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
+checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
dependencies = [
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
name = "multiaddr"
-version = "0.18.0"
+version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92a651988b3ed3ad1bc8c87d016bb92f6f395b84ed1db9b926b32b1fc5a2c8b5"
+checksum = "8b852bc02a2da5feed68cd14fa50d0774b92790a5bdbfa932a813926c8472070"
dependencies = [
"arrayref",
"byteorder",
@@ -3551,7 +3766,7 @@ dependencies = [
"percent-encoding",
"serde",
"static_assertions",
- "unsigned-varint",
+ "unsigned-varint 0.7.2",
"url",
]
@@ -3577,7 +3792,7 @@ dependencies = [
"quickcheck",
"rand 0.8.5",
"serde",
- "unsigned-varint",
+ "unsigned-varint 0.7.2",
]
[[package]]
@@ -3586,16 +3801,16 @@ version = "0.13.0"
dependencies = [
"async-std",
"bytes",
- "env_logger 0.10.0",
"futures",
"futures_ringbuf",
- "log",
"pin-project",
"quickcheck-ext",
"rand 0.8.5",
"rw-stream-sink",
"smallvec",
- "unsigned-varint",
+ "tracing",
+ "tracing-subscriber",
+ "unsigned-varint 0.8.0",
]
[[package]]
@@ -3675,7 +3890,7 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411"
dependencies = [
- "async-io",
+ "async-io 1.13.0",
"bytes",
"futures",
"libc",
@@ -3765,9 +3980,9 @@ dependencies = [
[[package]]
name = "num-traits"
-version = "0.2.17"
+version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
+checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
dependencies = [
"autocfg",
]
@@ -3802,9 +4017,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.18.0"
+version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
+checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "oorandom"
@@ -3820,11 +4035,11 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
-version = "0.10.55"
+version = "0.10.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d"
+checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags 2.4.1",
"cfg-if",
"foreign-types",
"libc",
@@ -3841,7 +4056,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
@@ -3852,9 +4067,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
-version = "0.9.90"
+version = "0.9.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6"
+checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f"
dependencies = [
"cc",
"libc",
@@ -3862,6 +4077,104 @@ dependencies = [
"vcpkg",
]
+[[package]]
+name = "opentelemetry"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9591d937bc0e6d2feb6f71a559540ab300ea49955229c347a517a28d27784c54"
+dependencies = [
+ "opentelemetry_api",
+ "opentelemetry_sdk",
+]
+
+[[package]]
+name = "opentelemetry-otlp"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e5e5a5c4135864099f3faafbe939eb4d7f9b80ebf68a8448da961b32a7c1275"
+dependencies = [
+ "async-trait",
+ "futures-core",
+ "http 0.2.9",
+ "opentelemetry-proto",
+ "opentelemetry-semantic-conventions",
+ "opentelemetry_api",
+ "opentelemetry_sdk",
+ "prost",
+ "thiserror",
+ "tokio",
+ "tonic",
+]
+
+[[package]]
+name = "opentelemetry-proto"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1e3f814aa9f8c905d0ee4bde026afd3b2577a97c10e1699912e3e44f0c4cbeb"
+dependencies = [
+ "opentelemetry_api",
+ "opentelemetry_sdk",
+ "prost",
+ "tonic",
+]
+
+[[package]]
+name = "opentelemetry-semantic-conventions"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73c9f9340ad135068800e7f1b24e9e09ed9e7143f5bf8518ded3d3ec69789269"
+dependencies = [
+ "opentelemetry",
+]
+
+[[package]]
+name = "opentelemetry_api"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a81f725323db1b1206ca3da8bb19874bbd3f57c3bcd59471bfb04525b265b9b"
+dependencies = [
+ "futures-channel",
+ "futures-util",
+ "indexmap 1.9.3",
+ "js-sys",
+ "once_cell",
+ "pin-project-lite",
+ "thiserror",
+ "urlencoding",
+]
+
+[[package]]
+name = "opentelemetry_sdk"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa8e705a0612d48139799fcbaba0d4a90f06277153e43dd2bdc16c6f0edd8026"
+dependencies = [
+ "async-trait",
+ "crossbeam-channel",
+ "futures-channel",
+ "futures-executor",
+ "futures-util",
+ "once_cell",
+ "opentelemetry_api",
+ "ordered-float",
+ "percent-encoding",
+ "rand 0.8.5",
+ "regex",
+ "serde_json",
+ "thiserror",
+ "tokio",
+ "tokio-stream",
+]
+
+[[package]]
+name = "ordered-float"
+version = "3.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc"
+dependencies = [
+ "num-traits",
+]
+
[[package]]
name = "overload"
version = "0.1.1"
@@ -3918,7 +4231,7 @@ dependencies = [
"libc",
"redox_syscall 0.3.5",
"smallvec",
- "windows-targets",
+ "windows-targets 0.48.5",
]
[[package]]
@@ -3927,32 +4240,13 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
-[[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"
-version = "2.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b13fe415cdf3c8e44518e18a7c95a13431d9bdf6d15367d82b23c377fdd441a"
-dependencies = [
- "base64 0.21.4",
- "serde",
-]
-
[[package]]
name = "pem"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3163d2912b7c3b52d651a055f2c7eec9ba5cd22d26ef75b8dd3a59980b185923"
dependencies = [
- "base64 0.21.4",
+ "base64 0.21.7",
"serde",
]
@@ -3967,41 +4261,35 @@ dependencies = [
[[package]]
name = "percent-encoding"
-version = "2.3.0"
+version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
+checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "pin-project"
-version = "1.1.3"
+version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422"
+checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
-version = "1.1.3"
+version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
+checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
name = "pin-project-lite"
-version = "0.1.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777"
-
-[[package]]
-name = "pin-project-lite"
-version = "0.2.12"
+version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05"
+checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
@@ -4013,10 +4301,11 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
name = "ping-example"
version = "0.1.0"
dependencies = [
- "env_logger 0.10.0",
"futures",
"libp2p",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -4081,31 +4370,33 @@ dependencies = [
"concurrent-queue",
"libc",
"log",
- "pin-project-lite 0.2.12",
- "windows-sys",
+ "pin-project-lite",
+ "windows-sys 0.48.0",
]
[[package]]
-name = "poly1305"
-version = "0.7.2"
+name = "polling"
+version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede"
+checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531"
dependencies = [
- "cpufeatures",
- "opaque-debug",
- "universal-hash 0.4.0",
+ "cfg-if",
+ "concurrent-queue",
+ "pin-project-lite",
+ "rustix 0.38.31",
+ "tracing",
+ "windows-sys 0.48.0",
]
[[package]]
-name = "polyval"
-version = "0.5.3"
+name = "poly1305"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1"
+checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
dependencies = [
- "cfg-if",
"cpufeatures",
"opaque-debug",
- "universal-hash 0.4.0",
+ "universal-hash",
]
[[package]]
@@ -4117,7 +4408,7 @@ dependencies = [
"cfg-if",
"cpufeatures",
"opaque-debug",
- "universal-hash 0.5.1",
+ "universal-hash",
]
[[package]]
@@ -4159,31 +4450,20 @@ dependencies = [
"version_check",
]
-[[package]]
-name = "proc-macro-warning"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.38",
-]
-
[[package]]
name = "proc-macro2"
-version = "1.0.69"
+version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
+checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [
"unicode-ident",
]
[[package]]
name = "prometheus-client"
-version = "0.21.2"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c99afa9a01501019ac3a14d71d9f94050346f55ca471ce90c799a15c58f61e2"
+checksum = "6f87c10af16e0af74010d2a123d202e8363c04db5acfa91d8747f64a8524da3a"
dependencies = [
"dtoa",
"itoa",
@@ -4193,10 +4473,33 @@ dependencies = [
[[package]]
name = "prometheus-client-derive-encode"
-version = "0.4.1"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.49",
+]
+
+[[package]]
+name = "prost"
+version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1"
+checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
dependencies = [
+ "bytes",
+ "prost-derive",
+]
+
+[[package]]
+name = "prost-derive"
+version = "0.11.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
+dependencies = [
+ "anyhow",
+ "itertools",
"proc-macro2",
"quote",
"syn 1.0.109",
@@ -4219,13 +4522,16 @@ dependencies = [
[[package]]
name = "quick-protobuf-codec"
-version = "0.2.0"
+version = "0.3.1"
dependencies = [
"asynchronous-codec",
"bytes",
+ "criterion",
+ "futures",
"quick-protobuf",
+ "quickcheck-ext",
"thiserror",
- "unsigned-varint",
+ "unsigned-varint 0.8.0",
]
[[package]]
@@ -4247,32 +4553,21 @@ dependencies = [
"quickcheck",
]
-[[package]]
-name = "quicksink"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858"
-dependencies = [
- "futures-core",
- "futures-sink",
- "pin-project-lite 0.1.12",
-]
-
[[package]]
name = "quinn"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cc2c5017e4b43d5995dcea317bc46c1e09404c0a9664d2908f7f02dfe943d75"
dependencies = [
- "async-io",
+ "async-io 1.13.0",
"async-std",
"bytes",
"futures-io",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash",
- "rustls 0.21.7",
+ "rustls 0.21.9",
"thiserror",
"tokio",
"tracing",
@@ -4286,9 +4581,9 @@ checksum = "2c78e758510582acc40acb90458401172d41f1016f8c9dde89e49677afb7eec1"
dependencies = [
"bytes",
"rand 0.8.5",
- "ring",
+ "ring 0.16.20",
"rustc-hash",
- "rustls 0.21.7",
+ "rustls 0.21.9",
"slab",
"thiserror",
"tinyvec",
@@ -4303,16 +4598,16 @@ checksum = "6df19e284d93757a9fb91d63672f7741b129246a669db09d1c0063071debc0c0"
dependencies = [
"bytes",
"libc",
- "socket2 0.5.4",
+ "socket2 0.5.5",
"tracing",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
name = "quote"
-version = "1.0.33"
+version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
+checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
@@ -4376,7 +4671,7 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
]
[[package]]
@@ -4412,24 +4707,12 @@ dependencies = [
[[package]]
name = "rcgen"
-version = "0.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b"
-dependencies = [
- "pem 1.1.1",
- "ring",
- "time",
- "yasna",
-]
-
-[[package]]
-name = "rcgen"
-version = "0.11.1"
+version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4954fbc00dcd4d8282c987710e50ba513d351400dbdd00e803a05172a90d8976"
+checksum = "52c4f3084aa3bc7dfbba4eff4fab2a54db4324965d8872ab933565e6fbd83bc6"
dependencies = [
- "pem 2.0.1",
- "ring",
+ "pem",
+ "ring 0.16.20",
"time",
"x509-parser",
"yasna",
@@ -4447,7 +4730,7 @@ dependencies = [
"futures-util",
"itoa",
"percent-encoding",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"ryu",
"tokio",
"tokio-util",
@@ -4478,21 +4761,21 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
"redox_syscall 0.2.16",
"thiserror",
]
[[package]]
name = "regex"
-version = "1.9.6"
+version = "1.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff"
+checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
dependencies = [
"aho-corasick 1.0.2",
"memchr",
- "regex-automata 0.3.9",
- "regex-syntax 0.7.5",
+ "regex-automata 0.4.4",
+ "regex-syntax 0.8.2",
]
[[package]]
@@ -4506,13 +4789,13 @@ dependencies = [
[[package]]
name = "regex-automata"
-version = "0.3.9"
+version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9"
+checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a"
dependencies = [
"aho-corasick 1.0.2",
"memchr",
- "regex-syntax 0.7.5",
+ "regex-syntax 0.8.2",
]
[[package]]
@@ -4523,9 +4806,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
-version = "0.7.5"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "relay-server-example"
@@ -4534,9 +4817,10 @@ dependencies = [
"async-std",
"async-trait",
"clap",
- "env_logger 0.10.0",
"futures",
"libp2p",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -4545,28 +4829,28 @@ version = "0.1.0"
dependencies = [
"async-std",
"async-trait",
- "env_logger 0.10.0",
"futures",
"libp2p",
- "log",
"tokio",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
name = "reqwest"
-version = "0.11.22"
+version = "0.11.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b"
+checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251"
dependencies = [
- "base64 0.21.4",
+ "base64 0.21.7",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
- "h2",
- "http",
- "http-body",
- "hyper",
+ "h2 0.3.24",
+ "http 0.2.9",
+ "http-body 0.4.5",
+ "hyper 0.14.27",
"hyper-tls",
"ipnet",
"js-sys",
@@ -4575,10 +4859,12 @@ dependencies = [
"native-tls",
"once_cell",
"percent-encoding",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
+ "rustls-pemfile",
"serde",
"serde_json",
"serde_urlencoded",
+ "sync_wrapper",
"system-configuration",
"tokio",
"tokio-native-tls",
@@ -4619,12 +4905,26 @@ dependencies = [
"cc",
"libc",
"once_cell",
- "spin",
- "untrusted",
+ "spin 0.5.2",
+ "untrusted 0.7.1",
"web-sys",
"winapi",
]
+[[package]]
+name = "ring"
+version = "0.17.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b"
+dependencies = [
+ "cc",
+ "getrandom 0.2.12",
+ "libc",
+ "spin 0.9.8",
+ "untrusted 0.9.0",
+ "windows-sys 0.48.0",
+]
+
[[package]]
name = "ringbuf"
version = "0.3.3"
@@ -4698,9 +4998,9 @@ dependencies = [
[[package]]
name = "rust-embed"
-version = "8.0.0"
+version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1e7d90385b59f0a6bf3d3b757f3ca4ece2048265d70db20a2016043d4509a40"
+checksum = "a82c0bbc10308ed323529fd3c1dce8badda635aa319a5ff0e6466f33b8101e3f"
dependencies = [
"rust-embed-impl",
"rust-embed-utils",
@@ -4709,23 +5009,23 @@ dependencies = [
[[package]]
name = "rust-embed-impl"
-version = "8.0.0"
+version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c3d8c6fd84090ae348e63a84336b112b5c3918b3bf0493a581f7bd8ee623c29"
+checksum = "6227c01b1783cdfee1bcf844eb44594cd16ec71c35305bf1c9fb5aade2735e16"
dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"shellexpand",
- "syn 2.0.38",
+ "syn 2.0.49",
"walkdir",
]
[[package]]
name = "rust-embed-utils"
-version = "8.0.0"
+version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "873feff8cb7bf86fdf0a71bb21c95159f4e4a37dd7a4bd1855a940909b583ada"
+checksum = "8cb0a25bfbb2d4b4402179c2cf030387d9990857ce08a32592c6238db9fa8665"
dependencies = [
"globset",
"sha2 0.10.8",
@@ -4764,29 +5064,29 @@ dependencies = [
[[package]]
name = "rustix"
-version = "0.37.23"
+version = "0.37.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06"
+checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035"
dependencies = [
"bitflags 1.3.2",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys 0.3.8",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
name = "rustix"
-version = "0.38.4"
+version = "0.38.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5"
+checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
dependencies = [
- "bitflags 2.3.3",
+ "bitflags 2.4.1",
"errno",
"libc",
- "linux-raw-sys 0.4.3",
- "windows-sys",
+ "linux-raw-sys 0.4.12",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -4796,19 +5096,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f"
dependencies = [
"log",
- "ring",
+ "ring 0.16.20",
"sct",
"webpki",
]
[[package]]
name = "rustls"
-version = "0.21.7"
+version = "0.21.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8"
+checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9"
dependencies = [
"log",
- "ring",
+ "ring 0.17.5",
"rustls-webpki",
"sct",
]
@@ -4831,17 +5131,17 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2"
dependencies = [
- "base64 0.21.4",
+ "base64 0.21.7",
]
[[package]]
name = "rustls-webpki"
-version = "0.101.4"
+version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d"
+checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
dependencies = [
- "ring",
- "untrusted",
+ "ring 0.17.5",
+ "untrusted 0.9.0",
]
[[package]]
@@ -4872,7 +5172,7 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
dependencies = [
- "cipher 0.4.4",
+ "cipher",
]
[[package]]
@@ -4890,7 +5190,7 @@ version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88"
dependencies = [
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -4911,8 +5211,8 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
- "ring",
- "untrusted",
+ "ring 0.16.20",
+ "untrusted 0.7.1",
]
[[package]]
@@ -4987,31 +5287,31 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.188"
+version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
+checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.188"
+version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
+checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
name = "serde_json"
-version = "1.0.107"
+version = "1.0.113"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
+checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"
dependencies = [
- "indexmap 2.0.0",
+ "indexmap 2.2.1",
"itoa",
"ryu",
"serde",
@@ -5035,7 +5335,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
@@ -5119,9 +5419,9 @@ dependencies = [
[[package]]
name = "shellexpand"
-version = "2.1.2"
+version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4"
+checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b"
dependencies = [
"dirs",
]
@@ -5166,9 +5466,9 @@ dependencies = [
[[package]]
name = "smallvec"
-version = "1.11.1"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
+checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e"
[[package]]
name = "smol"
@@ -5179,12 +5479,12 @@ dependencies = [
"async-channel",
"async-executor",
"async-fs",
- "async-io",
- "async-lock",
+ "async-io 1.13.0",
+ "async-lock 2.7.0",
"async-net",
"async-process",
"blocking",
- "futures-lite",
+ "futures-lite 1.13.0",
]
[[package]]
@@ -5198,16 +5498,16 @@ dependencies = [
[[package]]
name = "snow"
-version = "0.9.3"
+version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155"
+checksum = "850948bee068e713b8ab860fe1adc4d109676ab4c3b621fd8147f06b261f2f85"
dependencies = [
- "aes-gcm 0.9.2",
+ "aes-gcm",
"blake2",
"chacha20poly1305",
- "curve25519-dalek 4.1.1",
+ "curve25519-dalek",
"rand_core 0.6.4",
- "ring",
+ "ring 0.17.5",
"rustc_version",
"sha2 0.10.8",
"subtle",
@@ -5225,12 +5525,12 @@ dependencies = [
[[package]]
name = "socket2"
-version = "0.5.4"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e"
+checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
dependencies = [
"libc",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -5254,6 +5554,12 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
+[[package]]
+name = "spin"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+
[[package]]
name = "spki"
version = "0.7.2"
@@ -5270,6 +5576,20 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+[[package]]
+name = "stream-example"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "futures",
+ "libp2p",
+ "libp2p-stream",
+ "rand 0.8.5",
+ "tokio",
+ "tracing",
+ "tracing-subscriber",
+]
+
[[package]]
name = "stringmatch"
version = "0.4.0"
@@ -5291,12 +5611,12 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7beb1624a3ea34778d58d30e2b8606b4d29fe65e87c4d50b87ed30afd5c3830c"
dependencies = [
- "base64 0.21.4",
+ "base64 0.21.7",
"crc",
"lazy_static",
"md-5",
"rand 0.8.5",
- "ring",
+ "ring 0.16.20",
"subtle",
"thiserror",
"tokio",
@@ -5332,9 +5652,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.38"
+version = "2.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
+checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496"
dependencies = [
"proc-macro2",
"quote",
@@ -5361,9 +5681,9 @@ dependencies = [
[[package]]
name = "sysinfo"
-version = "0.29.10"
+version = "0.29.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5"
+checksum = "cd727fc423c2060f6c92d9534cef765c65a6ed3f428a03d7def74a8c4348e666"
dependencies = [
"cfg-if",
"core-foundation-sys",
@@ -5397,15 +5717,14 @@ dependencies = [
[[package]]
name = "tempfile"
-version = "3.8.0"
+version = "3.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
+checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67"
dependencies = [
"cfg-if",
- "fastrand 2.0.0",
- "redox_syscall 0.3.5",
- "rustix 0.38.4",
- "windows-sys",
+ "fastrand 2.0.1",
+ "rustix 0.38.31",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -5424,11 +5743,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf0fe180d5f1f7dd32bb5f1a8d19231bb63dc9bbb1985e1dbb6f07163b6a8578"
dependencies = [
"async-trait",
- "base64 0.21.4",
+ "base64 0.21.7",
"cookie",
"fantoccini",
"futures",
- "http",
+ "http 0.2.9",
"indexmap 1.9.3",
"log",
"parking_lot",
@@ -5457,22 +5776,22 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.49"
+version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4"
+checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.49"
+version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc"
+checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
@@ -5539,9 +5858,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.32.0"
+version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9"
+checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
dependencies = [
"backtrace",
"bytes",
@@ -5549,22 +5868,32 @@ dependencies = [
"mio",
"num_cpus",
"parking_lot",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"signal-hook-registry",
- "socket2 0.5.4",
+ "socket2 0.5.5",
"tokio-macros",
- "windows-sys",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "tokio-io-timeout"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
+dependencies = [
+ "pin-project-lite",
+ "tokio",
]
[[package]]
name = "tokio-macros"
-version = "2.1.0"
+version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
+checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
@@ -5589,27 +5918,56 @@ dependencies = [
]
[[package]]
-name = "tokio-rustls"
-version = "0.24.1"
+name = "tokio-stream"
+version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
+checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
dependencies = [
- "rustls 0.21.7",
+ "futures-core",
+ "pin-project-lite",
"tokio",
]
[[package]]
name = "tokio-util"
-version = "0.7.9"
+version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d"
+checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
dependencies = [
"bytes",
"futures-core",
"futures-io",
"futures-sink",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
+ "tokio",
+ "tracing",
+]
+
+[[package]]
+name = "tonic"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a"
+dependencies = [
+ "async-trait",
+ "axum 0.6.20",
+ "base64 0.21.7",
+ "bytes",
+ "futures-core",
+ "futures-util",
+ "h2 0.3.24",
+ "http 0.2.9",
+ "http-body 0.4.5",
+ "hyper 0.14.27",
+ "hyper-timeout",
+ "percent-encoding",
+ "pin-project",
+ "prost",
"tokio",
+ "tokio-stream",
+ "tower",
+ "tower-layer",
+ "tower-service",
"tracing",
]
@@ -5621,9 +5979,13 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
"futures-core",
"futures-util",
+ "indexmap 1.9.3",
"pin-project",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
+ "rand 0.8.5",
+ "slab",
"tokio",
+ "tokio-util",
"tower-layer",
"tower-service",
"tracing",
@@ -5631,22 +5993,22 @@ dependencies = [
[[package]]
name = "tower-http"
-version = "0.4.4"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140"
+checksum = "0da193277a4e2c33e59e09b5861580c33dd0a637c3883d0fa74ba40c0374af2e"
dependencies = [
- "bitflags 2.3.3",
+ "bitflags 2.4.1",
"bytes",
- "futures-core",
"futures-util",
- "http",
- "http-body",
+ "http 1.0.0",
+ "http-body 1.0.0",
+ "http-body-util",
"http-range-header",
"httpdate",
"mime",
"mime_guess",
"percent-encoding",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"tokio",
"tokio-util",
"tower-layer",
@@ -5668,33 +6030,32 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
[[package]]
name = "tracing"
-version = "0.1.37"
+version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
+checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
- "cfg-if",
"log",
- "pin-project-lite 0.2.12",
+ "pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
-version = "0.1.26"
+version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
+checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
[[package]]
name = "tracing-core"
-version = "0.1.31"
+version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
+checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
dependencies = [
"once_cell",
"valuable",
@@ -5712,79 +6073,59 @@ dependencies = [
]
[[package]]
-name = "tracing-subscriber"
-version = "0.3.17"
+name = "tracing-log"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
+checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
- "matchers",
- "nu-ansi-term",
+ "log",
"once_cell",
- "regex",
- "sharded-slab",
- "smallvec",
- "thread_local",
- "tracing",
"tracing-core",
- "tracing-log",
]
[[package]]
-name = "trust-dns-proto"
-version = "0.23.0"
+name = "tracing-opentelemetry"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0dc775440033cb114085f6f2437682b194fa7546466024b1037e82a48a052a69"
+checksum = "75327c6b667828ddc28f5e3f169036cb793c3f588d83bf0f262a7f062ffed3c8"
dependencies = [
- "async-trait",
- "bytes",
- "cfg-if",
- "data-encoding",
- "enum-as-inner",
- "futures-channel",
- "futures-io",
- "futures-util",
- "h2",
- "http",
- "idna",
- "ipnet",
"once_cell",
- "rand 0.8.5",
- "rustls 0.21.7",
- "rustls-pemfile",
- "rustls-webpki",
+ "opentelemetry",
+ "opentelemetry_sdk",
"smallvec",
- "socket2 0.5.4",
- "thiserror",
- "tinyvec",
- "tokio",
- "tokio-rustls 0.24.1",
"tracing",
- "url",
- "webpki-roots",
+ "tracing-core",
+ "tracing-log 0.1.3",
+ "tracing-subscriber",
]
[[package]]
-name = "trust-dns-resolver"
-version = "0.23.0"
+name = "tracing-subscriber"
+version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dff7aed33ef3e8bf2c9966fccdfed93f93d46f432282ea875cd66faabc6ef2f"
+checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
dependencies = [
- "cfg-if",
- "futures-util",
- "ipconfig",
- "lru-cache",
+ "matchers",
+ "nu-ansi-term",
"once_cell",
- "parking_lot",
- "rand 0.8.5",
- "resolv-conf",
- "rustls 0.21.7",
+ "regex",
+ "sharded-slab",
"smallvec",
- "thiserror",
- "tokio",
- "tokio-rustls 0.24.1",
+ "thread_local",
"tracing",
- "trust-dns-proto",
- "webpki-roots",
+ "tracing-core",
+ "tracing-log 0.2.0",
+]
+
+[[package]]
+name = "tracing-wasm"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07"
+dependencies = [
+ "tracing",
+ "tracing-subscriber",
+ "wasm-bindgen",
]
[[package]]
@@ -5795,9 +6136,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "trybuild"
-version = "1.0.85"
+version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "196a58260a906cedb9bf6d8034b6379d0c11f552416960452f267402ceeddff1"
+checksum = "9a9d3ba662913483d6722303f619e75ea10b7855b0f8e0d72799cf8621bb488f"
dependencies = [
"basic-toml",
"glob",
@@ -5815,12 +6156,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58f4fcb97da0426e8146fe0e9b78cc13120161087256198701d12d9df77f7701"
dependencies = [
"async-trait",
- "base64 0.21.4",
+ "base64 0.21.7",
"futures",
"log",
"md-5",
"rand 0.8.5",
- "ring",
+ "ring 0.16.20",
"stun",
"thiserror",
"tokio",
@@ -5887,16 +6228,6 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
-[[package]]
-name = "universal-hash"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402"
-dependencies = [
- "generic-array",
- "subtle",
-]
-
[[package]]
name = "universal-hash"
version = "0.5.1"
@@ -5912,6 +6243,12 @@ name = "unsigned-varint"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105"
+
+[[package]]
+name = "unsigned-varint"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06"
dependencies = [
"asynchronous-codec",
"bytes",
@@ -5923,6 +6260,12 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
+[[package]]
+name = "untrusted"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+
[[package]]
name = "upnp-example"
version = "0.1.0"
@@ -5930,19 +6273,26 @@ dependencies = [
"futures",
"libp2p",
"tokio",
+ "tracing-subscriber",
]
[[package]]
name = "url"
-version = "2.4.1"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5"
+checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
dependencies = [
"form_urlencoded",
- "idna",
+ "idna 0.5.0",
"percent-encoding",
]
+[[package]]
+name = "urlencoding"
+version = "2.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
+
[[package]]
name = "utf8parse"
version = "0.2.1"
@@ -5955,7 +6305,7 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d"
dependencies = [
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
]
[[package]]
@@ -6036,9 +6386,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
-version = "0.2.87"
+version = "0.2.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
+checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@@ -6046,24 +6396,24 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
-version = "0.2.87"
+version = "0.2.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd"
+checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
-version = "0.4.37"
+version = "0.4.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03"
+checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97"
dependencies = [
"cfg-if",
"js-sys",
@@ -6073,9 +6423,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.87"
+version = "0.2.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
+checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -6083,28 +6433,28 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.87"
+version = "0.2.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
+checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.87"
+version = "0.2.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
+checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838"
[[package]]
name = "wasm-bindgen-test"
-version = "0.3.37"
+version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e6e302a7ea94f83a6d09e78e7dc7d9ca7b186bc2829c24a22d0753efd680671"
+checksum = "143ddeb4f833e2ed0d252e618986e18bfc7b0e52f2d28d77d05b2f045dd8eb61"
dependencies = [
"console_error_panic_hook",
"js-sys",
@@ -6116,12 +6466,13 @@ dependencies = [
[[package]]
name = "wasm-bindgen-test-macro"
-version = "0.3.37"
+version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ecb993dd8c836930ed130e020e77d9b2e65dd0fbab1b67c790b0f5d80b11a575"
+checksum = "a5211b7550606857312bba1d978a8ec75692eae187becc5e680444fffc5e6f89"
dependencies = [
"proc-macro2",
"quote",
+ "syn 2.0.49",
]
[[package]]
@@ -6137,9 +6488,9 @@ dependencies = [
[[package]]
name = "web-sys"
-version = "0.3.64"
+version = "0.3.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b"
+checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed"
dependencies = [
"js-sys",
"wasm-bindgen",
@@ -6154,7 +6505,7 @@ dependencies = [
"base64 0.13.1",
"bytes",
"cookie",
- "http",
+ "http 0.2.9",
"log",
"serde",
"serde_derive",
@@ -6170,8 +6521,8 @@ version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f"
dependencies = [
- "ring",
- "untrusted",
+ "ring 0.16.20",
+ "untrusted 0.7.1",
]
[[package]]
@@ -6194,14 +6545,14 @@ dependencies = [
"interceptor",
"lazy_static",
"log",
- "pem 3.0.2",
+ "pem",
"rand 0.8.5",
- "rcgen 0.11.1",
+ "rcgen",
"regex",
- "ring",
+ "ring 0.16.20",
"rtcp",
"rtp",
- "rustls 0.21.7",
+ "rustls 0.21.9",
"sdp",
"serde",
"serde_json",
@@ -6244,8 +6595,8 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32b140b953f986e97828aa33ec6318186b05d862bee689efbc57af04a243e832"
dependencies = [
- "aes 0.8.3",
- "aes-gcm 0.10.2",
+ "aes",
+ "aes-gcm",
"async-trait",
"bincode",
"byteorder",
@@ -6257,12 +6608,12 @@ dependencies = [
"log",
"p256",
"p384",
- "pem 3.0.2",
+ "pem",
"rand 0.8.5",
"rand_core 0.6.4",
- "rcgen 0.11.1",
- "ring",
- "rustls 0.21.7",
+ "rcgen",
+ "ring 0.16.20",
+ "rustls 0.21.9",
"sec1",
"serde",
"sha1",
@@ -6271,7 +6622,7 @@ dependencies = [
"thiserror",
"tokio",
"webrtc-util",
- "x25519-dalek 2.0.0",
+ "x25519-dalek",
"x509-parser",
]
@@ -6306,7 +6657,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bebbd40e7f8b630a0f1a74783dbfff1edfc0ccaae891c4689891156a8c4d8c"
dependencies = [
"log",
- "socket2 0.5.4",
+ "socket2 0.5.5",
"thiserror",
"tokio",
"webrtc-util",
@@ -6348,12 +6699,12 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1db1f36c1c81e4b1e531c0b9678ba0c93809e196ce62122d87259bb71c03b9f"
dependencies = [
- "aead 0.5.2",
- "aes 0.8.3",
- "aes-gcm 0.10.2",
+ "aead",
+ "aes",
+ "aes-gcm",
"byteorder",
"bytes",
- "ctr 0.9.2",
+ "ctr",
"hmac 0.12.1",
"log",
"rtcp",
@@ -6391,7 +6742,7 @@ name = "webtransport-tests"
version = "0.1.0"
dependencies = [
"futures",
- "getrandom 0.2.10",
+ "getrandom 0.2.12",
"libp2p-core",
"libp2p-identity",
"libp2p-noise",
@@ -6443,15 +6794,21 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
-version = "0.34.0"
+version = "0.51.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9"
+dependencies = [
+ "windows-core",
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45296b64204227616fdbf2614cefa4c236b98ee64dfaaaa435207ed99fe7829f"
+checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64"
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",
+ "windows-targets 0.48.5",
]
[[package]]
@@ -6460,95 +6817,131 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
- "windows-targets",
+ "windows-targets 0.48.5",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets 0.52.0",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm 0.48.5",
+ "windows_aarch64_msvc 0.48.5",
+ "windows_i686_gnu 0.48.5",
+ "windows_i686_msvc 0.48.5",
+ "windows_x86_64_gnu 0.48.5",
+ "windows_x86_64_gnullvm 0.48.5",
+ "windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
-version = "0.48.1"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f"
+checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
- "windows_aarch64_gnullvm",
- "windows_aarch64_msvc 0.48.0",
- "windows_i686_gnu 0.48.0",
- "windows_i686_msvc 0.48.0",
- "windows_x86_64_gnu 0.48.0",
- "windows_x86_64_gnullvm",
- "windows_x86_64_msvc 0.48.0",
+ "windows_aarch64_gnullvm 0.52.0",
+ "windows_aarch64_msvc 0.52.0",
+ "windows_i686_gnu 0.52.0",
+ "windows_i686_msvc 0.52.0",
+ "windows_x86_64_gnu 0.52.0",
+ "windows_x86_64_gnullvm 0.52.0",
+ "windows_x86_64_msvc 0.52.0",
]
[[package]]
name = "windows_aarch64_gnullvm"
-version = "0.48.0"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
+checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.34.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.48.0"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
+checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]]
name = "windows_i686_gnu"
-version = "0.34.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
-version = "0.48.0"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
+checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]]
name = "windows_i686_msvc"
-version = "0.34.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
-version = "0.48.0"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
+checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.34.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.48.0"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
+checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.48.0"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
+checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.34.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.48.0"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
+checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winreg"
@@ -6557,27 +6950,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [
"cfg-if",
- "windows-sys",
-]
-
-[[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",
+ "windows-sys 0.48.0",
]
[[package]]
name = "x25519-dalek"
-version = "2.0.0"
+version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96"
+checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277"
dependencies = [
- "curve25519-dalek 4.1.1",
+ "curve25519-dalek",
"rand_core 0.6.4",
"serde",
"zeroize",
@@ -6595,7 +6977,7 @@ dependencies = [
"lazy_static",
"nom",
"oid-registry",
- "ring",
+ "ring 0.16.20",
"rusticata-macros",
"thiserror",
"time",
@@ -6618,11 +7000,27 @@ dependencies = [
[[package]]
name = "yamux"
-version = "0.12.0"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ed0164ae619f2dc144909a9f082187ebb5893693d8c0196e8085283ccd4b776"
+dependencies = [
+ "futures",
+ "log",
+ "nohash-hasher",
+ "parking_lot",
+ "pin-project",
+ "rand 0.8.5",
+ "static_assertions",
+]
+
+[[package]]
+name = "yamux"
+version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0329ef377816896f014435162bb3711ea7a07729c23d0960e6f8048b21b8fe91"
+checksum = "ad1d0148b89300047e72994bee99ecdabd15a9166a7b70c8b8c37c314dcc9002"
dependencies = [
"futures",
+ "instant",
"log",
"nohash-hasher",
"parking_lot",
@@ -6640,11 +7038,31 @@ dependencies = [
"time",
]
+[[package]]
+name = "zerocopy"
+version = "0.7.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.7.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.49",
+]
+
[[package]]
name = "zeroize"
-version = "1.6.0"
+version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
+checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
dependencies = [
"zeroize_derive",
]
@@ -6657,5 +7075,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.38",
+ "syn 2.0.49",
]
diff --git a/Cargo.toml b/Cargo.toml
index 55129a8ea965..3d7097f9a88b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,9 @@ members = [
"examples/ping",
"examples/relay-server",
"examples/rendezvous",
+ "examples/stream",
"examples/upnp",
+ "hole-punching-tests",
"identity",
"interop-tests",
"misc/allow-block-list",
@@ -44,11 +46,11 @@ members = [
"protocols/relay",
"protocols/rendezvous",
"protocols/request-response",
+ "protocols/stream",
"protocols/upnp",
- "swarm",
"swarm-derive",
"swarm-test",
- "transports/deflate",
+ "swarm",
"transports/dns",
"transports/noise",
"transports/plaintext",
@@ -57,9 +59,9 @@ members = [
"transports/tcp",
"transports/tls",
"transports/uds",
- "transports/wasm-ext",
- "transports/webrtc",
"transports/webrtc-websys",
+ "transports/webrtc",
+ "transports/websocket-websys",
"transports/websocket",
"transports/webtransport-websys",
"wasm-tests/webtransport-tests",
@@ -67,62 +69,65 @@ members = [
resolver = "2"
[workspace.package]
-rust-version = "1.65.0"
+rust-version = "1.73.0"
[workspace.dependencies]
-futures-bounded = { version = "0.1.0", path = "misc/futures-bounded" }
-libp2p = { version = "0.52.3", path = "libp2p" }
-libp2p-allow-block-list = { version = "0.2.0", path = "misc/allow-block-list" }
-libp2p-autonat = { version = "0.11.0", path = "protocols/autonat" }
-libp2p-connection-limits = { version = "0.2.1", path = "misc/connection-limits" }
-libp2p-core = { version = "0.40.1", path = "core" }
-libp2p-dcutr = { version = "0.10.0", path = "protocols/dcutr" }
-libp2p-deflate = { version = "0.40.1", path = "transports/deflate" }
-libp2p-dns = { version = "0.40.1", path = "transports/dns" }
-libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" }
-libp2p-gossipsub = { version = "0.45.1", path = "protocols/gossipsub" }
-libp2p-identify = { version = "0.43.1", path = "protocols/identify" }
-libp2p-identity = { version = "0.2.5" }
-libp2p-kad = { version = "0.44.6", path = "protocols/kad" }
-libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" }
-libp2p-memory-connection-limits = { version = "0.1.0", path = "misc/memory-connection-limits" }
-libp2p-metrics = { version = "0.13.1", path = "misc/metrics" }
-libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" }
+asynchronous-codec = { version = "0.7.0" }
+futures-bounded = { version = "0.2.3", path = "misc/futures-bounded" }
+libp2p = { version = "0.53.2", path = "libp2p" }
+libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" }
+libp2p-autonat = { version = "0.12.0", path = "protocols/autonat" }
+libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" }
+libp2p-core = { version = "0.41.2", path = "core" }
+libp2p-dcutr = { version = "0.11.0", path = "protocols/dcutr" }
+libp2p-dns = { version = "0.41.1", path = "transports/dns" }
+libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" }
+libp2p-gossipsub = { version = "0.46.1", path = "protocols/gossipsub" }
+libp2p-identify = { version = "0.44.2", path = "protocols/identify" }
+libp2p-identity = { version = "0.2.8" }
+libp2p-kad = { version = "0.45.4", path = "protocols/kad" }
+libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" }
+libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" }
+libp2p-metrics = { version = "0.14.1", path = "misc/metrics" }
+libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" }
libp2p-muxer-test-harness = { path = "muxers/test-harness" }
-libp2p-noise = { version = "0.43.1", path = "transports/noise" }
-libp2p-perf = { version = "0.2.0", path = "protocols/perf" }
-libp2p-ping = { version = "0.43.1", path = "protocols/ping" }
-libp2p-plaintext = { version = "0.40.1", path = "transports/plaintext" }
-libp2p-pnet = { version = "0.23.0", path = "transports/pnet" }
-libp2p-quic = { version = "0.9.2", path = "transports/quic" }
-libp2p-relay = { version = "0.16.1", path = "protocols/relay" }
-libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" }
-libp2p-upnp = { version = "0.1.1", path = "protocols/upnp" }
-libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" }
-libp2p-server = { version = "0.12.3", path = "misc/server" }
-libp2p-swarm = { version = "0.43.5", path = "swarm" }
-libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" }
-libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" }
-libp2p-tcp = { version = "0.40.0", path = "transports/tcp" }
-libp2p-tls = { version = "0.2.1", path = "transports/tls" }
-libp2p-uds = { version = "0.39.0", path = "transports/uds" }
-libp2p-wasm-ext = { version = "0.40.0", path = "transports/wasm-ext" }
-libp2p-webrtc = { version = "0.6.1-alpha", path = "transports/webrtc" }
-libp2p-webrtc-utils = { version = "0.1.0", path = "misc/webrtc-utils" }
-libp2p-webrtc-websys = { version = "0.1.0-alpha", path = "transports/webrtc-websys" }
-libp2p-websocket = { version = "0.42.1", path = "transports/websocket" }
-libp2p-webtransport-websys = { version = "0.1.0", path = "transports/webtransport-websys" }
-libp2p-yamux = { version = "0.44.1", path = "muxers/yamux" }
+libp2p-noise = { version = "0.44.0", path = "transports/noise" }
+libp2p-perf = { version = "0.3.0", path = "protocols/perf" }
+libp2p-ping = { version = "0.44.0", path = "protocols/ping" }
+libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" }
+libp2p-pnet = { version = "0.24.0", path = "transports/pnet" }
+libp2p-quic = { version = "0.10.2", path = "transports/quic" }
+libp2p-relay = { version = "0.17.1", path = "protocols/relay" }
+libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" }
+libp2p-request-response = { version = "0.26.2", path = "protocols/request-response" }
+libp2p-server = { version = "0.12.6", path = "misc/server" }
+libp2p-stream = { version = "0.1.0-alpha", path = "protocols/stream" }
+libp2p-swarm = { version = "0.44.2", path = "swarm" }
+libp2p-swarm-derive = { version = "=0.34.3", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
+libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" }
+libp2p-tcp = { version = "0.41.0", path = "transports/tcp" }
+libp2p-tls = { version = "0.3.0", path = "transports/tls" }
+libp2p-uds = { version = "0.40.0", path = "transports/uds" }
+libp2p-upnp = { version = "0.2.1", path = "protocols/upnp" }
+libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" }
+libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" }
+libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" }
+libp2p-websocket = { version = "0.43.0", path = "transports/websocket" }
+libp2p-websocket-websys = { version = "0.3.1", path = "transports/websocket-websys" }
+libp2p-webtransport-websys = { version = "0.2.0", path = "transports/webtransport-websys" }
+libp2p-yamux = { version = "0.45.1", path = "muxers/yamux" }
+multiaddr = "0.18.1"
+multihash = "0.19.1"
multistream-select = { version = "0.13.0", path = "misc/multistream-select" }
-quick-protobuf-codec = { version = "0.2.0", path = "misc/quick-protobuf-codec" }
+prometheus-client = "0.22.1"
+quick-protobuf-codec = { version = "0.3.1", path = "misc/quick-protobuf-codec" }
quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" }
rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" }
-multiaddr = "0.18.0"
-multihash = "0.19.1"
+unsigned-varint = { version = "0.8.0" }
[patch.crates-io]
-# Patch away `libp2p-idnentity` in our dependency tree with the workspace version.
+# Patch away `libp2p-identity` in our dependency tree with the workspace version.
# `libp2p-identity` is a leaf dependency and used within `rust-multiaddr` which is **not** part of the workspace.
# As a result, we cannot just reference the workspace version in our crates because the types would mismatch with what
# we import via `rust-multiaddr`.
@@ -134,3 +139,9 @@ rust.unreachable_pub = "warn"
clippy.used_underscore_binding = "warn"
clippy.pedantic = "allow"
clippy.type_complexity = "allow"
+clippy.unnecessary_wraps = "warn"
+clippy.manual_let_else = "warn"
+clippy.dbg_macro = "warn"
+
+[workspace.metadata.release]
+pre-release-hook = ["/bin/sh", '-c', '/bin/sh $WORKSPACE_ROOT/scripts/add-changelog-header.sh'] # Nested use of shell to expand variables.
diff --git a/README.md b/README.md
index 6bd528fc6800..48fa976635ae 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,8 @@ This repository is the central place for Rust development of the [libp2p](https:
many protocols in this repository.
- For **security related issues** please [file a private security vulnerability
- report](https://github.com/libp2p/rust-libp2p/security/advisories/new)
- or reach out to [security@libp2p.io](mailto:security@libp2p.io). Please do not
- file a public issue on GitHub.
+ report](https://github.com/libp2p/rust-libp2p/security/advisories/new) . Please do not file a
+ public issue on GitHub.
- To **report bugs, suggest improvements or request new features** please open a
GitHub issue on this repository.
@@ -42,7 +41,7 @@ The main components of this repository are structured as follows:
* `transports/`: Implementations of transport protocols (e.g. TCP) and protocol upgrades
(e.g. for authenticated encryption, compression, ...) based on the `libp2p-core` `Transport`
- API .
+ API.
* `muxers/`: Implementations of the `StreamMuxer` interface of `libp2p-core`,
e.g. (sub)stream multiplexing protocols on top of (typically TCP) connections.
@@ -91,8 +90,8 @@ Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
- [Forest](https://github.com/ChainSafe/forest) - An implementation of Filecoin written in Rust.
- [fuel-core](https://github.com/FuelLabs/fuel-core) - A Rust implementation of the Fuel protocol.
- [HotShot](https://github.com/EspressoSystems/HotShot) - Decentralized sequencer in Rust developed by [Espresso Systems](https://www.espressosys.com/).
-- [ipfs-embed](https://github.com/ipfs-rust/ipfs-embed) - A small embeddable ipfs implementation
-used and maintained by [Actyx](https://www.actyx.com).
+- [ipfs-embed](https://github.com/ipfs-rust/ipfs-embed) - A small embeddable ipfs implementation used and maintained by [Actyx](https://www.actyx.com).
+- [Homestar](https://github.com/ipvm-wg/homestar) - An InterPlanetary Virtual Machine (IPVM) implementation used and maintained by Fission.
- [beetle](https://github.com/n0-computer/beetle) - Next-generation implementation of IPFS for Cloud & Mobile platforms.
- [Lighthouse](https://github.com/sigp/lighthouse) - Ethereum consensus client in Rust.
- [Locutus](https://github.com/freenet/locutus) - Global, observable, decentralized key-value store.
@@ -103,4 +102,4 @@ used and maintained by [Actyx](https://www.actyx.com).
- [Subspace](https://github.com/subspace/subspace) - Subspace Network reference implementation
- [Substrate](https://github.com/paritytech/substrate) - Framework for blockchain innovation,
used by [Polkadot](https://www.parity.io/technologies/polkadot/).
-- [Taple](https://github.com/opencanarias/taple-core) - Sustainable DLT for asset and process traceability by [OpenCanarias](https://www.opencanarias.com/en/).
\ No newline at end of file
+- [Taple](https://github.com/opencanarias/taple-core) - Sustainable DLT for asset and process traceability by [OpenCanarias](https://www.opencanarias.com/en/).
diff --git a/SECURITY.md b/SECURITY.md
index 0e5a3f2e55f9..f3ae83405e85 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -7,5 +7,3 @@ By default we provide security patches for the latest released version only. On
## Reporting a Vulnerability
Please do not file a public issue on GitHub. Instead, please [file a private security vulnerability report](https://github.com/libp2p/rust-libp2p/security/advisories/new).
-
-If you need further assistance, please reach out to [security@libp2p.io](mailto:security@libp2p.io).
diff --git a/clippy.toml b/clippy.toml
index f66cc0ac2dac..fd38ead02022 100644
--- a/clippy.toml
+++ b/clippy.toml
@@ -1,3 +1,4 @@
disallowed-methods = [
{ path = "futures::channel::mpsc::unbounded", reason = "does not enforce backpressure" },
]
+avoid-breaking-exported-api = false
diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md
index ea7bc2bd6a06..a7cd7fd46b45 100644
--- a/core/CHANGELOG.md
+++ b/core/CHANGELOG.md
@@ -1,3 +1,23 @@
+## 0.41.2
+
+- Implement `std::fmt::Display` on `ListenerId`.
+ See [PR 4936](https://github.com/libp2p/rust-libp2p/pull/4936).
+
+## 0.41.1
+
+- Implement `{In,Out}boundConnectionUpgrade` for `SelectUpgrade`.
+ See [PR 4812](https://github.com/libp2p/rust-libp2p/pull/4812).
+
+## 0.41.0
+
+- Remove blanket-impl of `{In,Out}boundUpgrade` for `{In,Out}boundConnectionUpgrade`.
+ See [PR 4695](https://github.com/libp2p/rust-libp2p/pull/4695).
+- Remove deprecated functions from `ListenerId`.
+ See [PR 4736](https://github.com/libp2p/rust-libp2p/pull/4736).
+- Remove `upgrade::transfer` module.
+ See [issue 4011](https://github.com/libp2p/rust-libp2p/issues/4011) for details.
+ See [PR 4788](https://github.com/libp2p/rust-libp2p/pull/4788).
+
## 0.40.1
- Implement `Debug` for `StreamMuxerEvent`.
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 15288a48d1cb..619cd357744d 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -3,7 +3,7 @@ name = "libp2p-core"
edition = "2021"
rust-version = { workspace = true }
description = "Core traits and structs of libp2p"
-version = "0.40.1"
+version = "0.41.2"
authors = ["Parity Technologies "]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -13,24 +13,24 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
either = "1.9"
fnv = "1.0"
-futures = { version = "0.3.28", features = ["executor", "thread-pool"] }
+futures = { version = "0.3.30", features = ["executor", "thread-pool"] }
futures-timer = "3"
instant = "0.1.12"
libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] }
-log = "0.4"
multiaddr = { workspace = true }
multihash = { workspace = true }
multistream-select = { workspace = true }
-once_cell = "1.18.0"
+once_cell = "1.19.0"
parking_lot = "0.12.0"
-pin-project = "1.1.3"
+pin-project = "1.1.4"
quick-protobuf = "0.8"
rand = "0.8"
rw-stream-sink = { workspace = true }
serde = { version = "1", optional = true, features = ["derive"] }
-smallvec = "1.11.1"
+smallvec = "1.12.0"
thiserror = "1.0"
-unsigned-varint = "0.7"
+tracing = "0.1.37"
+unsigned-varint = { workspace = true }
void = "1"
[dev-dependencies]
@@ -39,7 +39,7 @@ libp2p-mplex = { path = "../muxers/mplex" } # Using `path` he
libp2p-noise = { path = "../transports/noise" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing.
multihash = { workspace = true, features = ["arb"] }
quickcheck = { workspace = true }
-libp2p-identity = { workspace = true, features = ["ed25519"] }
+libp2p-identity = { workspace = true, features = ["ed25519", "rand"] }
[features]
serde = ["multihash/serde-codec", "dep:serde", "libp2p-identity/serde"]
diff --git a/core/src/transport.rs b/core/src/transport.rs
index 9aeddb72ad08..22e7a0532fa9 100644
--- a/core/src/transport.rs
+++ b/core/src/transport.rs
@@ -250,22 +250,15 @@ pub trait Transport {
pub struct ListenerId(usize);
impl ListenerId {
- #[deprecated(note = "Renamed to ` ListenerId::next`.")]
- #[allow(clippy::new_without_default)]
- /// Creates a new `ListenerId`.
- pub fn new() -> Self {
- ListenerId::next()
- }
-
/// Creates a new `ListenerId`.
pub fn next() -> Self {
ListenerId(NEXT_LISTENER_ID.fetch_add(1, Ordering::SeqCst))
}
+}
- #[deprecated(note = "Use ` ListenerId::next` instead.")]
- #[allow(clippy::should_implement_trait)]
- pub fn default() -> Self {
- Self::next()
+impl std::fmt::Display for ListenerId {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", self.0)
}
}
@@ -414,16 +407,16 @@ impl TransportEvent {
/// Returns `None` if the event is not actually an incoming connection,
/// otherwise the upgrade and the remote address.
pub fn into_incoming(self) -> Option<(TUpgr, Multiaddr)> {
- if let TransportEvent::Incoming {
+ let TransportEvent::Incoming {
upgrade,
send_back_addr,
..
} = self
- {
- Some((upgrade, send_back_addr))
- } else {
- None
- }
+ else {
+ return None;
+ };
+
+ Some((upgrade, send_back_addr))
}
/// Returns `true` if this is a [`TransportEvent::NewAddress`].
diff --git a/core/src/transport/choice.rs b/core/src/transport/choice.rs
index 8d3bfdecb794..aa3acfc32310 100644
--- a/core/src/transport/choice.rs
+++ b/core/src/transport/choice.rs
@@ -22,7 +22,6 @@ use crate::either::EitherFuture;
use crate::transport::{ListenerId, Transport, TransportError, TransportEvent};
use either::Either;
use futures::future;
-use log::{debug, trace};
use multiaddr::Multiaddr;
use std::{pin::Pin, task::Context, task::Poll};
@@ -52,16 +51,16 @@ where
id: ListenerId,
addr: Multiaddr,
) -> Result<(), TransportError> {
- trace!(
- "Attempting to listen on {} using {}",
- addr,
+ tracing::trace!(
+ address=%addr,
+ "Attempting to listen on address using {}",
std::any::type_name::()
);
let addr = match self.0.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => {
- debug!(
- "Failed to listen on {} using {}",
- addr,
+ tracing::debug!(
+ address=%addr,
+ "Failed to listen on address using {}",
std::any::type_name::()
);
addr
@@ -69,16 +68,16 @@ where
res => return res.map_err(|err| err.map(Either::Left)),
};
- trace!(
- "Attempting to listen on {} using {}",
- addr,
+ tracing::trace!(
+ address=%addr,
+ "Attempting to listen on address using {}",
std::any::type_name::()
);
let addr = match self.1.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => {
- debug!(
- "Failed to listen on {} using {}",
- addr,
+ tracing::debug!(
+ address=%addr,
+ "Failed to listen on address using {}",
std::any::type_name::()
);
addr
@@ -94,17 +93,17 @@ where
}
fn dial(&mut self, addr: Multiaddr) -> Result> {
- trace!(
- "Attempting to dial {} using {}",
- addr,
+ tracing::trace!(
+ address=%addr,
+ "Attempting to dial address using {}",
std::any::type_name::()
);
let addr = match self.0.dial(addr) {
Ok(connec) => return Ok(EitherFuture::First(connec)),
Err(TransportError::MultiaddrNotSupported(addr)) => {
- debug!(
- "Failed to dial {} using {}",
- addr,
+ tracing::debug!(
+ address=%addr,
+ "Failed to dial address using {}",
std::any::type_name::()
);
addr
@@ -114,17 +113,17 @@ where
}
};
- trace!(
- "Attempting to dial {} using {}",
- addr,
+ tracing::trace!(
+ address=%addr,
+ "Attempting to dial address using {}",
std::any::type_name::()
);
let addr = match self.1.dial(addr) {
Ok(connec) => return Ok(EitherFuture::Second(connec)),
Err(TransportError::MultiaddrNotSupported(addr)) => {
- debug!(
- "Failed to dial {} using {}",
- addr,
+ tracing::debug!(
+ address=%addr,
+ "Failed to dial address using {}",
std::any::type_name::()
);
addr
diff --git a/core/src/transport/global_only.rs b/core/src/transport/global_only.rs
index 4f1fe8ab7947..0671b0e99845 100644
--- a/core/src/transport/global_only.rs
+++ b/core/src/transport/global_only.rs
@@ -22,7 +22,6 @@ use crate::{
multiaddr::{Multiaddr, Protocol},
transport::{ListenerId, TransportError, TransportEvent},
};
-use log::debug;
use std::{
pin::Pin,
task::{Context, Poll},
@@ -292,20 +291,20 @@ impl crate::Transport for Transport {
match addr.iter().next() {
Some(Protocol::Ip4(a)) => {
if !ipv4_global::is_global(a) {
- debug!("Not dialing non global IP address {:?}.", a);
+ tracing::debug!(ip=%a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial(addr)
}
Some(Protocol::Ip6(a)) => {
if !ipv6_global::is_global(a) {
- debug!("Not dialing non global IP address {:?}.", a);
+ tracing::debug!(ip=%a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial(addr)
}
_ => {
- debug!("Not dialing unsupported Multiaddress {:?}.", addr);
+ tracing::debug!(address=%addr, "Not dialing unsupported Multiaddress");
Err(TransportError::MultiaddrNotSupported(addr))
}
}
@@ -318,20 +317,20 @@ impl crate::Transport for Transport {
match addr.iter().next() {
Some(Protocol::Ip4(a)) => {
if !ipv4_global::is_global(a) {
- debug!("Not dialing non global IP address {:?}.", a);
+ tracing::debug!(ip=?a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial_as_listener(addr)
}
Some(Protocol::Ip6(a)) => {
if !ipv6_global::is_global(a) {
- debug!("Not dialing non global IP address {:?}.", a);
+ tracing::debug!(ip=?a, "Not dialing non global IP address");
return Err(TransportError::MultiaddrNotSupported(addr));
}
self.inner.dial_as_listener(addr)
}
_ => {
- debug!("Not dialing unsupported Multiaddress {:?}.", addr);
+ tracing::debug!(address=%addr, "Not dialing unsupported Multiaddress");
Err(TransportError::MultiaddrNotSupported(addr))
}
}
diff --git a/core/src/transport/memory.rs b/core/src/transport/memory.rs
index 4c30ee9b65d1..bf88215dd43b 100644
--- a/core/src/transport/memory.rs
+++ b/core/src/transport/memory.rs
@@ -62,9 +62,8 @@ impl Hub {
port
} else {
loop {
- let port = match NonZeroU64::new(rand::random()) {
- Some(p) => p,
- None => continue,
+ let Some(port) = NonZeroU64::new(rand::random()) else {
+ continue;
};
if !hub.contains_key(&port) {
break port;
@@ -184,16 +183,12 @@ impl Transport for MemoryTransport {
id: ListenerId,
addr: Multiaddr,
) -> Result<(), TransportError> {
- let port = if let Ok(port) = parse_memory_addr(&addr) {
- port
- } else {
- return Err(TransportError::MultiaddrNotSupported(addr));
- };
+ let port =
+ parse_memory_addr(&addr).map_err(|_| TransportError::MultiaddrNotSupported(addr))?;
- let (rx, port) = match HUB.register_port(port) {
- Some((rx, port)) => (rx, port),
- None => return Err(TransportError::Other(MemoryTransportError::Unreachable)),
- };
+ let (rx, port) = HUB
+ .register_port(port)
+ .ok_or(TransportError::Other(MemoryTransportError::Unreachable))?;
let listener = Listener {
id,
diff --git a/core/src/upgrade.rs b/core/src/upgrade.rs
index 7db1853b56ca..69561fbebd8e 100644
--- a/core/src/upgrade.rs
+++ b/core/src/upgrade.rs
@@ -64,7 +64,6 @@ mod error;
mod pending;
mod ready;
mod select;
-mod transfer;
pub(crate) use apply::{
apply, apply_inbound, apply_outbound, InboundUpgradeApply, OutboundUpgradeApply,
@@ -73,11 +72,7 @@ pub(crate) use error::UpgradeError;
use futures::future::Future;
pub use self::{
- denied::DeniedUpgrade,
- pending::PendingUpgrade,
- ready::ReadyUpgrade,
- select::SelectUpgrade,
- transfer::{read_length_prefixed, read_varint, write_length_prefixed, write_varint},
+ denied::DeniedUpgrade, pending::PendingUpgrade, ready::ReadyUpgrade, select::SelectUpgrade,
};
pub use crate::Negotiated;
pub use multistream_select::{NegotiatedComplete, NegotiationError, ProtocolError, Version};
@@ -157,31 +152,3 @@ pub trait OutboundConnectionUpgrade: UpgradeInfo {
/// The `info` is the identifier of the protocol, as produced by `protocol_info`.
fn upgrade_outbound(self, socket: T, info: Self::Info) -> Self::Future;
}
-
-// Blanket implementation for InboundConnectionUpgrade based on InboundUpgrade for backwards compatibility
-impl InboundConnectionUpgrade for U
-where
- U: InboundUpgrade,
-{
- type Output = >::Output;
- type Error = >::Error;
- type Future = >::Future;
-
- fn upgrade_inbound(self, socket: T, info: Self::Info) -> Self::Future {
- self.upgrade_inbound(socket, info)
- }
-}
-
-// Blanket implementation for OutboundConnectionUpgrade based on OutboundUpgrade for backwards compatibility
-impl OutboundConnectionUpgrade for U
-where
- U: OutboundUpgrade,
-{
- type Output = >::Output;
- type Error = >::Error;
- type Future = >::Future;
-
- fn upgrade_outbound(self, socket: T, info: Self::Info) -> Self::Future {
- self.upgrade_outbound(socket, info)
- }
-}
diff --git a/core/src/upgrade/apply.rs b/core/src/upgrade/apply.rs
index aefce686f013..15cb0348cf35 100644
--- a/core/src/upgrade/apply.rs
+++ b/core/src/upgrade/apply.rs
@@ -21,7 +21,6 @@
use crate::upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeError};
use crate::{connection::ConnectedPoint, Negotiated};
use futures::{future::Either, prelude::*};
-use log::debug;
use multistream_select::{self, DialerSelectFuture, ListenerSelectFuture};
use std::{mem, pin::Pin, task::Context, task::Poll};
@@ -141,11 +140,11 @@ where
return Poll::Pending;
}
Poll::Ready(Ok(x)) => {
- log::trace!("Upgraded inbound stream to {name}");
+ tracing::trace!(upgrade=%name, "Upgraded inbound stream");
return Poll::Ready(Ok(x));
}
Poll::Ready(Err(e)) => {
- debug!("Failed to upgrade inbound stream to {name}");
+ tracing::debug!(upgrade=%name, "Failed to upgrade inbound stream");
return Poll::Ready(Err(UpgradeError::Apply(e)));
}
}
@@ -223,11 +222,11 @@ where
return Poll::Pending;
}
Poll::Ready(Ok(x)) => {
- log::trace!("Upgraded outbound stream to {name}",);
+ tracing::trace!(upgrade=%name, "Upgraded outbound stream");
return Poll::Ready(Ok(x));
}
Poll::Ready(Err(e)) => {
- debug!("Failed to upgrade outbound stream to {name}",);
+ tracing::debug!(upgrade=%name, "Failed to upgrade outbound stream",);
return Poll::Ready(Err(UpgradeError::Apply(e)));
}
}
diff --git a/core/src/upgrade/select.rs b/core/src/upgrade/select.rs
index 19b8b7a93f7d..037045a2f29a 100644
--- a/core/src/upgrade/select.rs
+++ b/core/src/upgrade/select.rs
@@ -19,7 +19,10 @@
// DEALINGS IN THE SOFTWARE.
use crate::either::EitherFuture;
-use crate::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
+use crate::upgrade::{
+ InboundConnectionUpgrade, InboundUpgrade, OutboundConnectionUpgrade, OutboundUpgrade,
+ UpgradeInfo,
+};
use either::Either;
use futures::future;
use std::iter::{Chain, Map};
@@ -84,6 +87,23 @@ where
}
}
+impl InboundConnectionUpgrade for SelectUpgrade
+where
+ A: InboundConnectionUpgrade,
+ B: InboundConnectionUpgrade,
+{
+ type Output = future::Either;
+ type Error = Either;
+ type Future = EitherFuture;
+
+ fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
+ match info {
+ Either::Left(info) => EitherFuture::First(self.0.upgrade_inbound(sock, info)),
+ Either::Right(info) => EitherFuture::Second(self.1.upgrade_inbound(sock, info)),
+ }
+ }
+}
+
impl OutboundUpgrade for SelectUpgrade
where
A: OutboundUpgrade,
@@ -100,3 +120,20 @@ where
}
}
}
+
+impl OutboundConnectionUpgrade for SelectUpgrade
+where
+ A: OutboundConnectionUpgrade,
+ B: OutboundConnectionUpgrade,
+{
+ type Output = future::Either;
+ type Error = Either;
+ type Future = EitherFuture;
+
+ fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
+ match info {
+ Either::Left(info) => EitherFuture::First(self.0.upgrade_outbound(sock, info)),
+ Either::Right(info) => EitherFuture::Second(self.1.upgrade_outbound(sock, info)),
+ }
+ }
+}
diff --git a/core/src/upgrade/transfer.rs b/core/src/upgrade/transfer.rs
deleted file mode 100644
index 93aeb987c8a9..000000000000
--- a/core/src/upgrade/transfer.rs
+++ /dev/null
@@ -1,220 +0,0 @@
-// Copyright 2019 Parity Technologies (UK) Ltd.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-
-//! Contains some helper futures for creating upgrades.
-
-use futures::prelude::*;
-use std::io;
-
-// TODO: these methods could be on an Ext trait to AsyncWrite
-
-/// Writes a message to the given socket with a length prefix appended to it. Also flushes the socket.
-///
-/// > **Note**: Prepends a variable-length prefix indicate the length of the message. This is
-/// > compatible with what [`read_length_prefixed`] expects.
-pub async fn write_length_prefixed(
- socket: &mut (impl AsyncWrite + Unpin),
- data: impl AsRef<[u8]>,
-) -> Result<(), io::Error> {
- write_varint(socket, data.as_ref().len()).await?;
- socket.write_all(data.as_ref()).await?;
- socket.flush().await?;
-
- Ok(())
-}
-
-/// Writes a variable-length integer to the `socket`.
-///
-/// > **Note**: Does **NOT** flush the socket.
-pub async fn write_varint(
- socket: &mut (impl AsyncWrite + Unpin),
- len: usize,
-) -> Result<(), io::Error> {
- let mut len_data = unsigned_varint::encode::usize_buffer();
- let encoded_len = unsigned_varint::encode::usize(len, &mut len_data).len();
- socket.write_all(&len_data[..encoded_len]).await?;
-
- Ok(())
-}
-
-/// Reads a variable-length integer from the `socket`.
-///
-/// As a special exception, if the `socket` is empty and EOFs right at the beginning, then we
-/// return `Ok(0)`.
-///
-/// > **Note**: This function reads bytes one by one from the `socket`. It is therefore encouraged
-/// > to use some sort of buffering mechanism.
-pub async fn read_varint(socket: &mut (impl AsyncRead + Unpin)) -> Result {
- let mut buffer = unsigned_varint::encode::usize_buffer();
- let mut buffer_len = 0;
-
- loop {
- match socket.read(&mut buffer[buffer_len..buffer_len + 1]).await? {
- 0 => {
- // Reaching EOF before finishing to read the length is an error, unless the EOF is
- // at the very beginning of the substream, in which case we assume that the data is
- // empty.
- if buffer_len == 0 {
- return Ok(0);
- } else {
- return Err(io::ErrorKind::UnexpectedEof.into());
- }
- }
- n => debug_assert_eq!(n, 1),
- }
-
- buffer_len += 1;
-
- match unsigned_varint::decode::usize(&buffer[..buffer_len]) {
- Ok((len, _)) => return Ok(len),
- Err(unsigned_varint::decode::Error::Overflow) => {
- return Err(io::Error::new(
- io::ErrorKind::InvalidData,
- "overflow in variable-length integer",
- ));
- }
- // TODO: why do we have a `__Nonexhaustive` variant in the error? I don't know how to process it
- // Err(unsigned_varint::decode::Error::Insufficient) => {}
- Err(_) => {}
- }
- }
-}
-
-/// Reads a length-prefixed message from the given socket.
-///
-/// The `max_size` parameter is the maximum size in bytes of the message that we accept. This is
-/// necessary in order to avoid DoS attacks where the remote sends us a message of several
-/// gigabytes.
-///
-/// > **Note**: Assumes that a variable-length prefix indicates the length of the message. This is
-/// > compatible with what [`write_length_prefixed`] does.
-pub async fn read_length_prefixed(
- socket: &mut (impl AsyncRead + Unpin),
- max_size: usize,
-) -> io::Result> {
- let len = read_varint(socket).await?;
- if len > max_size {
- return Err(io::Error::new(
- io::ErrorKind::InvalidData,
- format!("Received data size ({len} bytes) exceeds maximum ({max_size} bytes)"),
- ));
- }
-
- let mut buf = vec![0; len];
- socket.read_exact(&mut buf).await?;
-
- Ok(buf)
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn write_length_prefixed_works() {
- let data = (0..rand::random::() % 10_000)
- .map(|_| rand::random::())
- .collect::>();
- let mut out = vec![0; 10_000];
-
- futures::executor::block_on(async {
- let mut socket = futures::io::Cursor::new(&mut out[..]);
-
- write_length_prefixed(&mut socket, &data).await.unwrap();
- socket.close().await.unwrap();
- });
-
- let (out_len, out_data) = unsigned_varint::decode::usize(&out).unwrap();
- assert_eq!(out_len, data.len());
- assert_eq!(&out_data[..out_len], &data[..]);
- }
-
- // TODO: rewrite these tests
- /*
- #[test]
- fn read_one_works() {
- let original_data = (0..rand::random::() % 10_000)
- .map(|_| rand::random::())
- .collect::>();
-
- let mut len_buf = unsigned_varint::encode::usize_buffer();
- let len_buf = unsigned_varint::encode::usize(original_data.len(), &mut len_buf);
-
- let mut in_buffer = len_buf.to_vec();
- in_buffer.extend_from_slice(&original_data);
-
- let future = read_one_then(Cursor::new(in_buffer), 10_000, (), move |out, ()| -> Result<_, ReadOneError> {
- assert_eq!(out, original_data);
- Ok(())
- });
-
- futures::executor::block_on(future).unwrap();
- }
-
- #[test]
- fn read_one_zero_len() {
- let future = read_one_then(Cursor::new(vec![0]), 10_000, (), move |out, ()| -> Result<_, ReadOneError> {
- assert!(out.is_empty());
- Ok(())
- });
-
- futures::executor::block_on(future).unwrap();
- }
-
- #[test]
- fn read_checks_length() {
- let mut len_buf = unsigned_varint::encode::u64_buffer();
- let len_buf = unsigned_varint::encode::u64(5_000, &mut len_buf);
-
- let mut in_buffer = len_buf.to_vec();
- in_buffer.extend((0..5000).map(|_| 0));
-
- let future = read_one_then(Cursor::new(in_buffer), 100, (), move |_, ()| -> Result<_, ReadOneError> {
- Ok(())
- });
-
- match futures::executor::block_on(future) {
- Err(ReadOneError::TooLarge { .. }) => (),
- _ => panic!(),
- }
- }
-
- #[test]
- fn read_one_accepts_empty() {
- let future = read_one_then(Cursor::new([]), 10_000, (), move |out, ()| -> Result<_, ReadOneError> {
- assert!(out.is_empty());
- Ok(())
- });
-
- futures::executor::block_on(future).unwrap();
- }
-
- #[test]
- fn read_one_eof_before_len() {
- let future = read_one_then(Cursor::new([0x80]), 10_000, (), move |_, ()| -> Result<(), ReadOneError> {
- unreachable!()
- });
-
- match futures::executor::block_on(future) {
- Err(ReadOneError::Io(ref err)) if err.kind() == io::ErrorKind::UnexpectedEof => (),
- _ => panic!()
- }
- }*/
-}
diff --git a/core/tests/transport_upgrade.rs b/core/tests/transport_upgrade.rs
index 193ee73cbc86..a88720516185 100644
--- a/core/tests/transport_upgrade.rs
+++ b/core/tests/transport_upgrade.rs
@@ -20,7 +20,9 @@
use futures::prelude::*;
use libp2p_core::transport::{ListenerId, MemoryTransport, Transport};
-use libp2p_core::upgrade::{self, InboundUpgrade, OutboundUpgrade, UpgradeInfo};
+use libp2p_core::upgrade::{
+ self, InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeInfo,
+};
use libp2p_identity as identity;
use libp2p_mplex::MplexConfig;
use libp2p_noise as noise;
@@ -40,7 +42,7 @@ impl UpgradeInfo for HelloUpgrade {
}
}
-impl InboundUpgrade for HelloUpgrade
+impl InboundConnectionUpgrade for HelloUpgrade
where
C: AsyncRead + AsyncWrite + Send + Unpin + 'static,
{
@@ -58,7 +60,7 @@ where
}
}
-impl OutboundUpgrade for HelloUpgrade
+impl OutboundConnectionUpgrade for HelloUpgrade
where
C: AsyncWrite + AsyncRead + Send + Unpin + 'static,
{
@@ -108,11 +110,11 @@ fn upgrade_pipeline() {
let server = async move {
loop {
- let (upgrade, _send_back_addr) =
- match listener_transport.select_next_some().await.into_incoming() {
- Some(u) => u,
- None => continue,
- };
+ let Some((upgrade, _send_back_addr)) =
+ listener_transport.select_next_some().await.into_incoming()
+ else {
+ continue;
+ };
let (peer, _mplex) = upgrade.await.unwrap();
assert_eq!(peer, dialer_id);
}
diff --git a/docs/coding-guidelines.md b/docs/coding-guidelines.md
index aef8dd6986aa..bacbfe9509e4 100644
--- a/docs/coding-guidelines.md
+++ b/docs/coding-guidelines.md
@@ -28,7 +28,7 @@ Below is a set of coding guidelines followed across the rust-libp2p code base.
## Hierarchical State Machines
-If you sqint, rust-libp2p is just a big hierarchy of [state
+If you squint, rust-libp2p is just a big hierarchy of [state
machines](https://en.wikipedia.org/wiki/Finite-state_machine) where parents pass
events down to their children and children pass events up to their parents.
@@ -167,7 +167,7 @@ impl Stream for SomeStateMachine {
}
```
-This priotization provides:
+This prioritization provides:
- Low memory footprint as local queues (here `events_to_return_to_parent`) stay small.
- Low latency as accepted local work is not stuck in queues.
- DOS defense as a remote does not control the size of the local queue, nor starves local work with its remote work.
@@ -195,7 +195,7 @@ through a side-channel.
### Local queues
As for channels shared across potentially concurrent actors (e.g. future tasks
-or OS threads), the same applies for queues owned by a single actor only. E.g.
+or OS threads), the same applies to queues owned by a single actor only. E.g.
reading events from a socket into a `Vec` without some mechanism
bounding the size of that `Vec` again can lead to unbounded memory
growth and high latencies.
@@ -241,7 +241,7 @@ shows a speed up when running it concurrently.
## Use `async/await` for sequential execution only
Using `async/await` for sequential execution makes things significantly simpler.
-Though unfortunately using `async/await` does not allow accesing methods on the
+Though unfortunately using `async/await` does not allow accessing methods on the
object being `await`ed unless paired with some synchronization mechanism like an
`Arc>`.
@@ -308,7 +308,7 @@ response and a previous request. For example, if a user requests two new connect
peer, they should be able to match each new connection to the corresponding previous connection
request without having to guess.
-When accepting a **command** that eventually results in a response through an event require that
+When accepting a **command** that eventually results in a response through an event requires that
command to contain a unique ID, which is later on contained in the asynchronous response event. One
such example is the `Swarm` accepting a `ToSwarm::Dial` from the `NetworkBehaviour`.
diff --git a/docs/maintainer-handbook.md b/docs/maintainer-handbook.md
index 8ec6e6e8c6ad..6d36f6fe77c0 100644
--- a/docs/maintainer-handbook.md
+++ b/docs/maintainer-handbook.md
@@ -26,6 +26,14 @@ Once a PR fulfills all merge requirements (approvals, passing CI, etc), applying
In case of a trivial code change, maintainers may choose to apply the `trivial` label.
This will have mergify approve your PR, thus fulfilling all requirements to automatically queue a PR for merging.
+## Changelog entries
+
+Our CI checks that each crate which is modified gets a changelog entry.
+Whilst this is a good default safety-wise, it creates a lot of false-positives for changes that are internal and don't need a changelog entry.
+
+For PRs that in the categories `chore`, `deps`, `refactor` and `docs`, this check is disabled automatically.
+Any other PR needs to explicitly disable this check if desired by applying the `internal-change` label.
+
## Dependencies
We version our `Cargo.lock` file for better visibility into which dependencies are required for a functional build.
diff --git a/docs/release.md b/docs/release.md
index 5b4d32aedafc..50b7b0605c7d 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -17,43 +17,34 @@ Non-breaking changes are typically merged very quickly and often released as pat
Every crate that we publish on `crates.io` has a `CHANGELOG.md` file.
Substantial PRs should add an entry to each crate they modify.
-The next unreleased version is tagged with ` - unreleased`, for example: `0.17.0 - unreleased`.
+We have a CI check[^1] that enforces adding a changelog entry if you modify code in a particular crate.
+In case the current version is already released (we also check that in CI), you'll have to add a new header at the top.
+For example, the top-listed version might be `0.17.3` but it is already released.
+In that case, add a new heading `## 0.17.4` with your changelog entry in case it is a non-breaking change.
-In case there isn't a version with an ` - unreleased` postfix yet, add one for the next version.
-The next version number depends on the impact of your change (breaking vs non-breaking, see above).
-
-If you are making a non-breaking change, please also bump the version number:
-
-- in the `Cargo.toml` manifest of the respective crate
-- in the `[workspace.dependencies]` section of the workspace `Cargo.toml` manifest
-
-For breaking changes, a changelog entry itself is sufficient.
-Bumping the version in the `Cargo.toml` file would lead to many merge conflicts once we decide to merge them.
-Hence, we are going to bump those versions once we work through the milestone that collects the breaking changes.
+The version in the crate's `Cargo.toml` and the top-most version in the `CHANGELOG.md` file always have to be in sync.
+Additionally, we also enforce that all crates always depend on the latest version of other workspace-crates through workspace inheritance.
+As a consequence, you'll also have to bump the version in `[workspace.dependencies]` in the workspace `Cargo.toml` manifest.
## Releasing one or more crates
+The above changelog-management strategy means `master` is always in a state where we can make a release.
+
### Prerequisites
- [cargo release](https://github.com/crate-ci/cargo-release/)
### Steps
-1. Remove the ` - unreleased` tag for each crate to be released in the respective `CHANGELOG.md`.
- Create a pull request with the changes against the rust-libp2p `master` branch.
-
-2. Once merged, run the two commands below on the (squash-) merged commit on the `master` branch.
+1. Run the two commands below on the (squash-) merged commit on the `master` branch.
1. `cargo release publish --execute`
2. `cargo release tag --sign-tag --execute`
-3. Confirm that `cargo release` tagged the commit correctly via `git push
- $YOUR_ORIGIN --tag --dry-run` and then push the new tags via `git push
- $YOUR_ORIGIN --tag`. Make sure not to push unrelated git tags.
-
- Note that dropping the `--no-push` flag on `cargo release` might as well do
- the trick.
+2. Confirm that `cargo release` tagged the commit correctly via `git push $YOUR_ORIGIN --tag --dry-run`
+ Push the new tags via `git push $YOUR_ORIGIN --tag`.
+ Make sure not to push unrelated git tags.
## Patch release
@@ -65,15 +56,17 @@ Hence, we are going to bump those versions once we work through the milestone th
## Dealing with alphas
-Unfortunately, `cargo` has a rather uninutitive behaviour when it comes to dealing with pre-releases like `0.1.0-alpha`.
+Unfortunately, `cargo` has a rather unintuitive behaviour when it comes to dealing with pre-releases like `0.1.0-alpha`.
See this internals thread for some context: https://internals.rust-lang.org/t/changing-cargo-semver-compatibility-for-pre-releases
In short, cargo will automatically update from `0.1.0-alpha.1` to `0.1.0-alpha.2` UNLESS you pin the version directly with `=0.1.0-alpha.1`.
However, from a semver perspective, changes between pre-releases can be breaking.
-To avoid accidential breaking changes for our users, we employ the following convention for alpha releases:
+To avoid accidental breaking changes for our users, we employ the following convention for alpha releases:
- For a breaking change in a crate with an alpha release, bump the "minor" version but retain the "alpha" tag.
Example: `0.1.0-alpha` to `0.2.0-alpha`.
- For a non-breaking change in a crate with an alpha release, bump or append number to the "alpha" tag.
Example: `0.1.0-alpha` to `0.1.0-alpha.1`.
+
+[^1]: See [ci.yml](../.github/workflows/ci.yml) and look for "Ensure manifest and CHANGELOG are properly updated".
diff --git a/examples/README.md b/examples/README.md
index 28e085587b7d..0a3e55aed39a 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -20,6 +20,6 @@ A set of examples showcasing how to use rust-libp2p.
- [IPFS Private](./ipfs-private) Implementation using the gossipsub, ping and identify protocols to implement the ipfs private swarms feature.
-- [Ping](./ping) Small `ping` clone, sending a ping to a peer, expecting a pong as a response. See [tutorial](../src/tutorials/ping.rs) for a step-by-step guide building the example.
+- [Ping](./ping) Small `ping` clone, sending a ping to a peer, expecting a pong as a response. See [tutorial](../libp2p/src/tutorials/ping.rs) for a step-by-step guide building the example.
- [Rendezvous](./rendezvous) Rendezvous Protocol. See [specs](https://github.com/libp2p/specs/blob/master/rendezvous/README.md).
diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml
index 332f77f04a7f..642e621c2575 100644
--- a/examples/autonat/Cargo.toml
+++ b/examples/autonat/Cargo.toml
@@ -5,12 +5,16 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-tokio = { version = "1.32", features = ["full"] }
-clap = { version = "4.3.23", features = ["derive"] }
-env_logger = "0.10.0"
-futures = "0.3.28"
+tokio = { version = "1.36", features = ["full"] }
+clap = { version = "4.4.16", features = ["derive"] }
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/autonat/src/bin/autonat_client.rs b/examples/autonat/src/bin/autonat_client.rs
index eeb39ec52dea..3fb25aa62221 100644
--- a/examples/autonat/src/bin/autonat_client.rs
+++ b/examples/autonat/src/bin/autonat_client.rs
@@ -21,14 +21,15 @@
#![doc = include_str!("../../README.md")]
use clap::Parser;
-use futures::prelude::*;
+use futures::StreamExt;
use libp2p::core::multiaddr::Protocol;
-use libp2p::core::{upgrade::Version, Multiaddr, Transport};
-use libp2p::swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent};
+use libp2p::core::Multiaddr;
+use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
use libp2p::{autonat, identify, identity, noise, tcp, yamux, PeerId};
use std::error::Error;
use std::net::Ipv4Addr;
use std::time::Duration;
+use tracing_subscriber::EnvFilter;
#[derive(Debug, Parser)]
#[clap(name = "libp2p autonat")]
@@ -45,22 +46,23 @@ struct Opt {
#[tokio::main]
async fn main() -> Result<(), Box> {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
let opt = Opt::parse();
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|key| Behaviour::new(key.public()))?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
- let transport = tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&local_key)?)
- .multiplex(yamux::Config::default())
- .boxed();
-
- let behaviour = Behaviour::new(local_key.public());
-
- let mut swarm = SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build();
swarm.listen_on(
Multiaddr::empty()
.with(Protocol::Ip4(Ipv4Addr::UNSPECIFIED))
diff --git a/examples/autonat/src/bin/autonat_server.rs b/examples/autonat/src/bin/autonat_server.rs
index 065708f745f5..44a53f0d17fa 100644
--- a/examples/autonat/src/bin/autonat_server.rs
+++ b/examples/autonat/src/bin/autonat_server.rs
@@ -21,12 +21,14 @@
#![doc = include_str!("../../README.md")]
use clap::Parser;
-use futures::prelude::*;
-use libp2p::core::{multiaddr::Protocol, upgrade::Version, Multiaddr, Transport};
-use libp2p::swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent};
-use libp2p::{autonat, identify, identity, noise, tcp, yamux, PeerId};
+use futures::StreamExt;
+use libp2p::core::{multiaddr::Protocol, Multiaddr};
+use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
+use libp2p::{autonat, identify, identity, noise, tcp, yamux};
use std::error::Error;
use std::net::Ipv4Addr;
+use std::time::Duration;
+use tracing_subscriber::EnvFilter;
#[derive(Debug, Parser)]
#[clap(name = "libp2p autonat")]
@@ -37,22 +39,23 @@ struct Opt {
#[tokio::main]
async fn main() -> Result<(), Box> {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
let opt = Opt::parse();
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|key| Behaviour::new(key.public()))?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
- let transport = tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&local_key)?)
- .multiplex(yamux::Config::default())
- .boxed();
-
- let behaviour = Behaviour::new(local_key.public());
-
- let mut swarm = SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build();
swarm.listen_on(
Multiaddr::empty()
.with(Protocol::Ip4(Ipv4Addr::UNSPECIFIED))
diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml
index f6b47d4ded9f..79068cdca877 100644
--- a/examples/browser-webrtc/Cargo.toml
+++ b/examples/browser-webrtc/Cargo.toml
@@ -9,34 +9,37 @@ repository = "https://github.com/libp2p/rust-libp2p"
rust-version = { workspace = true }
version = "0.1.0"
+[package.metadata.release]
+release = false
+
[lib]
crate-type = ["cdylib"]
[dependencies]
-anyhow = "1.0.72"
-env_logger = "0.10"
-futures = "0.3.28"
-log = "0.4"
+anyhow = "1.0.79"
+futures = "0.3.30"
rand = "0.8"
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-axum = "0.6.19"
-libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "wasm-bindgen", "tokio"] }
+axum = "0.7.4"
+libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "tokio"] }
libp2p-webrtc = { workspace = true, features = ["tokio"] }
-rust-embed = { version = "8.0.0", features = ["include-exclude", "interpolate-folder-path"] }
-tokio = { version = "1.29", features = ["macros", "net", "rt", "signal"] }
+rust-embed = { version = "8.2.0", features = ["include-exclude", "interpolate-folder-path"] }
+tokio = { version = "1.36", features = ["macros", "net", "rt", "signal"] }
tokio-util = { version = "0.7", features = ["compat"] }
tower = "0.4"
-tower-http = { version = "0.4.0", features = ["cors"] }
+tower-http = { version = "0.5.1", features = ["cors"] }
mime_guess = "2.0.4"
[target.'cfg(target_arch = "wasm32")'.dependencies]
-js-sys = "0.3.64"
+js-sys = "0.3.67"
libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "wasm-bindgen"] }
libp2p-webrtc-websys = { workspace = true }
-wasm-bindgen = "0.2.84"
-wasm-bindgen-futures = "0.4.37"
-wasm-logger = { version = "0.2.0" }
+tracing-wasm = "0.2.1"
+wasm-bindgen = "0.2.90"
+wasm-bindgen-futures = "0.4.41"
web-sys = { version = "0.3", features = ['Document', 'Element', 'HtmlElement', 'Node', 'Response', 'Window'] }
[lints]
diff --git a/examples/browser-webrtc/README.md b/examples/browser-webrtc/README.md
index d44cf8799054..eec2c9c0494c 100644
--- a/examples/browser-webrtc/README.md
+++ b/examples/browser-webrtc/README.md
@@ -5,6 +5,8 @@ It uses [wasm-pack](https://rustwasm.github.io/docs/wasm-pack/) to build the pro
## Running the example
+Ensure you have `wasm-pack` [installed](https://rustwasm.github.io/wasm-pack/).
+
1. Build the client library:
```shell
wasm-pack build --target web --out-dir static
diff --git a/examples/browser-webrtc/src/lib.rs b/examples/browser-webrtc/src/lib.rs
index 1a9856dadcc5..9499ccbd1583 100644
--- a/examples/browser-webrtc/src/lib.rs
+++ b/examples/browser-webrtc/src/lib.rs
@@ -3,67 +3,73 @@
use futures::StreamExt;
use js_sys::Date;
use libp2p::core::Multiaddr;
-use libp2p::identity::{Keypair, PeerId};
use libp2p::ping;
-use libp2p::swarm::{keep_alive, NetworkBehaviour, SwarmBuilder, SwarmEvent};
-use std::convert::From;
+use libp2p::swarm::SwarmEvent;
+use libp2p_webrtc_websys as webrtc_websys;
use std::io;
+use std::time::Duration;
use wasm_bindgen::prelude::*;
use web_sys::{Document, HtmlElement};
#[wasm_bindgen]
pub async fn run(libp2p_endpoint: String) -> Result<(), JsError> {
- wasm_logger::init(wasm_logger::Config::default());
+ tracing_wasm::set_as_global_default();
+
+ let ping_duration = Duration::from_secs(30);
let body = Body::from_current_window()?;
- body.append_p("Let's ping the WebRTC Server!")?;
-
- let local_key = Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
- let mut swarm = SwarmBuilder::with_wasm_executor(
- libp2p_webrtc_websys::Transport::new(libp2p_webrtc_websys::Config::new(&local_key)).boxed(),
- Behaviour {
- ping: ping::Behaviour::new(ping::Config::new()),
- keep_alive: keep_alive::Behaviour,
- },
- local_peer_id,
- )
- .build();
-
- log::info!("Initialize swarm with identity: {local_peer_id}");
+ body.append_p(&format!(
+ "Let's ping the rust-libp2p server over WebRTC for {:?}:",
+ ping_duration
+ ))?;
+
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_wasm_bindgen()
+ .with_other_transport(|key| {
+ webrtc_websys::Transport::new(webrtc_websys::Config::new(&key))
+ })?
+ .with_behaviour(|_| ping::Behaviour::new(ping::Config::new()))?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(ping_duration))
+ .build();
let addr = libp2p_endpoint.parse::()?;
- log::info!("Dialing {addr}");
+ tracing::info!("Dialing {addr}");
swarm.dial(addr)?;
loop {
match swarm.next().await.unwrap() {
- SwarmEvent::Behaviour(BehaviourEvent::Ping(ping::Event { result: Err(e), .. })) => {
- log::error!("Ping failed: {:?}", e);
+ SwarmEvent::Behaviour(ping::Event { result: Err(e), .. }) => {
+ tracing::error!("Ping failed: {:?}", e);
break;
}
- SwarmEvent::Behaviour(BehaviourEvent::Ping(ping::Event {
+ SwarmEvent::Behaviour(ping::Event {
peer,
result: Ok(rtt),
..
- })) => {
- log::info!("Ping successful: RTT: {rtt:?}, from {peer}");
+ }) => {
+ tracing::info!("Ping successful: RTT: {rtt:?}, from {peer}");
body.append_p(&format!("RTT: {rtt:?} at {}", Date::new_0().to_string()))?;
}
- evt => log::info!("Swarm event: {:?}", evt),
+ SwarmEvent::ConnectionClosed {
+ cause: Some(cause), ..
+ } => {
+ tracing::info!("Swarm event: {:?}", cause);
+
+ if let libp2p::swarm::ConnectionError::KeepAliveTimeout = cause {
+ body.append_p("All done with pinging! ")?;
+
+ break;
+ }
+ body.append_p(&format!("Connection closed due to: {:?}", cause))?;
+ }
+ evt => tracing::info!("Swarm event: {:?}", evt),
}
}
Ok(())
}
-#[derive(NetworkBehaviour)]
-struct Behaviour {
- ping: ping::Behaviour,
- keep_alive: keep_alive::Behaviour,
-}
-
/// Convenience wrapper around the current document body
struct Body {
body: HtmlElement,
diff --git a/examples/browser-webrtc/src/main.rs b/examples/browser-webrtc/src/main.rs
index 8a4034a436ee..7f06b0d0d998 100644
--- a/examples/browser-webrtc/src/main.rs
+++ b/examples/browser-webrtc/src/main.rs
@@ -10,37 +10,39 @@ use futures::StreamExt;
use libp2p::{
core::muxing::StreamMuxerBox,
core::Transport,
- identity,
multiaddr::{Multiaddr, Protocol},
ping,
- swarm::{SwarmBuilder, SwarmEvent},
+ swarm::SwarmEvent,
};
use libp2p_webrtc as webrtc;
use rand::thread_rng;
use std::net::{Ipv4Addr, SocketAddr};
use std::time::Duration;
+use tokio::net::TcpListener;
use tower_http::cors::{Any, CorsLayer};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- env_logger::builder()
- .parse_filters("browser_webrtc_example=debug,libp2p_webrtc=info,libp2p_ping=debug")
- .parse_default_env()
- .init();
-
- let id_keys = identity::Keypair::generate_ed25519();
- let local_peer_id = id_keys.public().to_peer_id();
- let transport = webrtc::tokio::Transport::new(
- id_keys,
- webrtc::tokio::Certificate::generate(&mut thread_rng())?,
- )
- .map(|(peer_id, conn), _| (peer_id, StreamMuxerBox::new(conn)))
- .boxed();
-
- let mut swarm =
- SwarmBuilder::with_tokio_executor(transport, ping::Behaviour::default(), local_peer_id)
- .idle_connection_timeout(Duration::from_secs(30)) // Allows us to observe the pings.
- .build();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter("browser_webrtc_example=debug,libp2p_webrtc=info,libp2p_ping=debug")
+ .try_init();
+
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_other_transport(|id_keys| {
+ Ok(webrtc::tokio::Transport::new(
+ id_keys.clone(),
+ webrtc::tokio::Certificate::generate(&mut thread_rng())?,
+ )
+ .map(|(peer_id, conn), _| (peer_id, StreamMuxerBox::new(conn))))
+ })?
+ .with_behaviour(|_| ping::Behaviour::default())?
+ .with_swarm_config(|cfg| {
+ cfg.with_idle_connection_timeout(
+ Duration::from_secs(u64::MAX), // Allows us to observe the pings.
+ )
+ })
+ .build();
let address_webrtc = Multiaddr::from(Ipv4Addr::UNSPECIFIED)
.with(Protocol::Udp(0))
@@ -54,11 +56,13 @@ async fn main() -> anyhow::Result<()> {
.iter()
.any(|e| e == Protocol::Ip4(Ipv4Addr::LOCALHOST))
{
- log::debug!("Ignoring localhost address to make sure the example works in Firefox");
+ tracing::debug!(
+ "Ignoring localhost address to make sure the example works in Firefox"
+ );
continue;
}
- log::info!("Listening on: {address}");
+ tracing::info!(%address, "Listening");
break address;
}
@@ -72,7 +76,7 @@ async fn main() -> anyhow::Result<()> {
loop {
tokio::select! {
swarm_event = swarm.next() => {
- log::trace!("Swarm Event: {:?}", swarm_event)
+ tracing::trace!(?swarm_event)
},
_ = tokio::signal::ctrl_c() => {
break;
@@ -89,9 +93,8 @@ struct StaticFiles;
/// Serve the Multiaddr we are listening on and the host files.
pub(crate) async fn serve(libp2p_transport: Multiaddr) {
- let listen_addr = match libp2p_transport.iter().next() {
- Some(Protocol::Ip4(addr)) => addr,
- _ => panic!("Expected 1st protocol to be IP4"),
+ let Some(Protocol::Ip4(listen_addr)) = libp2p_transport.iter().next() else {
+ panic!("Expected 1st protocol to be IP4")
};
let server = Router::new()
@@ -108,12 +111,14 @@ pub(crate) async fn serve(libp2p_transport: Multiaddr) {
let addr = SocketAddr::new(listen_addr.into(), 8080);
- log::info!("Serving client files at http://{addr}");
+ tracing::info!(url=%format!("http://{addr}"), "Serving client files at url");
- axum::Server::bind(&addr)
- .serve(server.into_make_service())
- .await
- .unwrap();
+ axum::serve(
+ TcpListener::bind((listen_addr, 8080)).await.unwrap(),
+ server.into_make_service(),
+ )
+ .await
+ .unwrap();
}
#[derive(Clone)]
@@ -139,7 +144,7 @@ async fn get_index(
/// Serves the static files generated by `wasm-pack`.
async fn get_static_file(Path(path): Path) -> Result {
- log::debug!("Serving static file: {path}");
+ tracing::debug!(file_path=%path, "Serving static file");
let content = StaticFiles::get(&path).ok_or(StatusCode::NOT_FOUND)?.data;
let content_type = mime_guess::from_path(path)
diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml
index cee9e553e279..a16c930e5b3a 100644
--- a/examples/chat/Cargo.toml
+++ b/examples/chat/Cargo.toml
@@ -5,12 +5,16 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-tokio = { version = "1.32", features = ["full"] }
+tokio = { version = "1.36", features = ["full"] }
async-trait = "0.1"
-env_logger = "0.10.0"
-futures = "0.3.28"
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/chat/src/main.rs b/examples/chat/src/main.rs
index 312ca2d30870..c785d301c2fe 100644
--- a/examples/chat/src/main.rs
+++ b/examples/chat/src/main.rs
@@ -20,19 +20,14 @@
#![doc = include_str!("../README.md")]
-use futures::{future::Either, stream::StreamExt};
-use libp2p::{
- core::{muxing::StreamMuxerBox, transport::OrTransport, upgrade},
- gossipsub, identity, mdns, noise, quic,
- swarm::NetworkBehaviour,
- swarm::{SwarmBuilder, SwarmEvent},
- tcp, yamux, PeerId, Transport,
-};
+use futures::stream::StreamExt;
+use libp2p::{gossipsub, mdns, noise, swarm::NetworkBehaviour, swarm::SwarmEvent, tcp, yamux};
use std::collections::hash_map::DefaultHasher;
use std::error::Error;
use std::hash::{Hash, Hasher};
use std::time::Duration;
use tokio::{io, io::AsyncBufReadExt, select};
+use tracing_subscriber::EnvFilter;
// We create a custom network behaviour that combines Gossipsub and Mdns.
#[derive(NetworkBehaviour)]
@@ -43,58 +38,51 @@ struct MyBehaviour {
#[tokio::main]
async fn main() -> Result<(), Box> {
- // Create a random PeerId
- env_logger::init();
- let id_keys = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(id_keys.public());
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- // Set up an encrypted DNS-enabled TCP Transport over the yamux protocol.
- let tcp_transport = tcp::tokio::Transport::new(tcp::Config::default().nodelay(true))
- .upgrade(upgrade::Version::V1Lazy)
- .authenticate(noise::Config::new(&id_keys).expect("signing libp2p-noise static keypair"))
- .multiplex(yamux::Config::default())
- .timeout(std::time::Duration::from_secs(20))
- .boxed();
- let quic_transport = quic::tokio::Transport::new(quic::Config::new(&id_keys));
- let transport = OrTransport::new(quic_transport, tcp_transport)
- .map(|either_output, _| match either_output {
- Either::Left((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)),
- Either::Right((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)),
- })
- .boxed();
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_quic()
+ .with_behaviour(|key| {
+ // 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())
+ };
- // 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()
+ .map_err(|msg| io::Error::new(io::ErrorKind::Other, msg))?; // Temporary hack because `build` does not return a proper `std::error::Error`.
- // 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 gossipsub = gossipsub::Behaviour::new(
+ gossipsub::MessageAuthenticity::Signed(key.clone()),
+ gossipsub_config,
+ )?;
+
+ let mdns =
+ mdns::tokio::Behaviour::new(mdns::Config::default(), key.public().to_peer_id())?;
+ Ok(MyBehaviour { gossipsub, mdns })
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
- // build a gossipsub network behaviour
- let mut gossipsub = gossipsub::Behaviour::new(
- gossipsub::MessageAuthenticity::Signed(id_keys),
- gossipsub_config,
- )
- .expect("Correct configuration");
// Create a Gossipsub topic
let topic = gossipsub::IdentTopic::new("test-net");
// subscribes to our topic
- gossipsub.subscribe(&topic)?;
-
- // Create a Swarm to manage peers and events
- let mut swarm = {
- let mdns = mdns::tokio::Behaviour::new(mdns::Config::default(), local_peer_id)?;
- let behaviour = MyBehaviour { gossipsub, mdns };
- SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()
- };
+ swarm.behaviour_mut().gossipsub.subscribe(&topic)?;
// Read full lines from stdin
let mut stdin = io::BufReader::new(io::stdin()).lines();
diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml
index 49e1ada2e968..8443e9a59c7a 100644
--- a/examples/dcutr/Cargo.toml
+++ b/examples/dcutr/Cargo.toml
@@ -5,13 +5,18 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-clap = { version = "4.3.23", features = ["derive"] }
-env_logger = "0.10.0"
-futures = "0.3.28"
+clap = { version = "4.4.16", features = ["derive"] }
+futures = "0.3.30"
futures-timer = "3.0"
-libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] }
+libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] }
log = "0.4"
+tokio = { version = "1.36", features = ["macros", "net", "rt", "signal"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/dcutr/src/main.rs b/examples/dcutr/src/main.rs
index 099867df7444..51df670f8a70 100644
--- a/examples/dcutr/src/main.rs
+++ b/examples/dcutr/src/main.rs
@@ -21,25 +21,16 @@
#![doc = include_str!("../README.md")]
use clap::Parser;
-use futures::{
- executor::{block_on, ThreadPool},
- future::{Either, FutureExt},
- stream::StreamExt,
-};
+use futures::{executor::block_on, future::FutureExt, stream::StreamExt};
use libp2p::{
- core::{
- multiaddr::{Multiaddr, Protocol},
- muxing::StreamMuxerBox,
- transport::Transport,
- upgrade,
- },
- dcutr, dns, identify, identity, noise, ping, quic, relay,
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
+ core::multiaddr::{Multiaddr, Protocol},
+ dcutr, identify, identity, noise, ping, relay,
+ swarm::{NetworkBehaviour, SwarmEvent},
tcp, yamux, PeerId,
};
-use log::info;
-use std::error::Error;
use std::str::FromStr;
+use std::{error::Error, time::Duration};
+use tracing_subscriber::EnvFilter;
#[derive(Debug, Parser)]
#[clap(name = "libp2p DCUtR client")]
@@ -78,37 +69,14 @@ impl FromStr for Mode {
}
}
-fn main() -> Result<(), Box> {
- env_logger::init();
+#[tokio::main]
+async fn main() -> Result<(), Box> {
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
let opts = Opts::parse();
- let local_key = generate_ed25519(opts.secret_key_seed);
- let local_peer_id = PeerId::from(local_key.public());
-
- let (relay_transport, client) = relay::client::new(local_peer_id);
-
- let transport = {
- let relay_tcp_quic_transport = relay_transport
- .or_transport(tcp::async_io::Transport::new(
- tcp::Config::default().port_reuse(true),
- ))
- .upgrade(upgrade::Version::V1)
- .authenticate(noise::Config::new(&local_key).unwrap())
- .multiplex(yamux::Config::default())
- .or_transport(quic::async_std::Transport::new(quic::Config::new(
- &local_key,
- )));
-
- block_on(dns::async_std::Transport::system(relay_tcp_quic_transport))
- .unwrap()
- .map(|either_output, _| match either_output {
- Either::Left((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)),
- Either::Right((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)),
- })
- .boxed()
- };
-
#[derive(NetworkBehaviour)]
struct Behaviour {
relay_client: relay::client::Behaviour,
@@ -117,21 +85,28 @@ fn main() -> Result<(), Box> {
dcutr: dcutr::Behaviour,
}
- let behaviour = Behaviour {
- relay_client: client,
- ping: ping::Behaviour::new(ping::Config::new()),
- identify: identify::Behaviour::new(identify::Config::new(
- "/TODO/0.0.1".to_string(),
- local_key.public(),
- )),
- dcutr: dcutr::Behaviour::new(local_peer_id),
- };
-
- let mut swarm = match ThreadPool::new() {
- Ok(tp) => SwarmBuilder::with_executor(transport, behaviour, local_peer_id, tp),
- Err(_) => SwarmBuilder::without_executor(transport, behaviour, local_peer_id),
- }
- .build();
+ let mut swarm =
+ libp2p::SwarmBuilder::with_existing_identity(generate_ed25519(opts.secret_key_seed))
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default().port_reuse(true).nodelay(true),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_quic()
+ .with_dns()?
+ .with_relay_client(noise::Config::new, yamux::Config::default)?
+ .with_behaviour(|keypair, relay_behaviour| Behaviour {
+ relay_client: relay_behaviour,
+ ping: ping::Behaviour::new(ping::Config::new()),
+ identify: identify::Behaviour::new(identify::Config::new(
+ "/TODO/0.0.1".to_string(),
+ keypair.public(),
+ )),
+ dcutr: dcutr::Behaviour::new(keypair.public().to_peer_id()),
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
swarm
.listen_on("/ip4/0.0.0.0/udp/0/quic-v1".parse().unwrap())
@@ -148,7 +123,7 @@ fn main() -> Result<(), Box> {
event = swarm.next() => {
match event.unwrap() {
SwarmEvent::NewListenAddr { address, .. } => {
- info!("Listening on {:?}", address);
+ tracing::info!(%address, "Listening on address");
}
event => panic!("{event:?}"),
}
@@ -177,15 +152,14 @@ fn main() -> Result<(), Box> {
SwarmEvent::Behaviour(BehaviourEvent::Identify(identify::Event::Sent {
..
})) => {
- info!("Told relay its public address.");
+ tracing::info!("Told relay its public address");
told_relay_observed_addr = true;
}
SwarmEvent::Behaviour(BehaviourEvent::Identify(identify::Event::Received {
info: identify::Info { observed_addr, .. },
..
})) => {
- info!("Relay told us our public address: {:?}", observed_addr);
- swarm.add_external_address(observed_addr);
+ tracing::info!(address=%observed_addr, "Relay told us our observed address");
learned_observed_addr = true;
}
event => panic!("{event:?}"),
@@ -218,31 +192,31 @@ fn main() -> Result<(), Box> {
loop {
match swarm.next().await.unwrap() {
SwarmEvent::NewListenAddr { address, .. } => {
- info!("Listening on {:?}", address);
+ tracing::info!(%address, "Listening on address");
}
SwarmEvent::Behaviour(BehaviourEvent::RelayClient(
relay::client::Event::ReservationReqAccepted { .. },
)) => {
assert!(opts.mode == Mode::Listen);
- info!("Relay accepted our reservation request.");
+ tracing::info!("Relay accepted our reservation request");
}
SwarmEvent::Behaviour(BehaviourEvent::RelayClient(event)) => {
- info!("{:?}", event)
+ tracing::info!(?event)
}
SwarmEvent::Behaviour(BehaviourEvent::Dcutr(event)) => {
- info!("{:?}", event)
+ tracing::info!(?event)
}
SwarmEvent::Behaviour(BehaviourEvent::Identify(event)) => {
- info!("{:?}", event)
+ tracing::info!(?event)
}
SwarmEvent::Behaviour(BehaviourEvent::Ping(_)) => {}
SwarmEvent::ConnectionEstablished {
peer_id, endpoint, ..
} => {
- info!("Established connection to {:?} via {:?}", peer_id, endpoint);
+ tracing::info!(peer=%peer_id, ?endpoint, "Established new connection");
}
SwarmEvent::OutgoingConnectionError { peer_id, error, .. } => {
- info!("Outgoing connection error to {:?}: {:?}", peer_id, error);
+ tracing::info!(peer=?peer_id, "Outgoing connection failed: {error}");
}
_ => {}
}
diff --git a/examples/distributed-key-value-store/Cargo.toml b/examples/distributed-key-value-store/Cargo.toml
index aa9a875be5ad..a7efe3c06978 100644
--- a/examples/distributed-key-value-store/Cargo.toml
+++ b/examples/distributed-key-value-store/Cargo.toml
@@ -5,12 +5,16 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
-env_logger = "0.10"
-futures = "0.3.28"
-libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "kad", "mdns", "noise", "macros", "tcp", "websocket", "yamux"] }
+futures = "0.3.30"
+libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "kad", "mdns", "noise", "macros", "tcp", "yamux"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/distributed-key-value-store/src/main.rs b/examples/distributed-key-value-store/src/main.rs
index cd9857b1482e..404333f3d203 100644
--- a/examples/distributed-key-value-store/src/main.rs
+++ b/examples/distributed-key-value-store/src/main.rs
@@ -22,30 +22,23 @@
use async_std::io;
use futures::{prelude::*, select};
-use libp2p::core::upgrade::Version;
use libp2p::kad;
-use libp2p::kad::record::store::MemoryStore;
+use libp2p::kad::store::MemoryStore;
use libp2p::kad::Mode;
use libp2p::{
- identity, mdns, noise,
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
- tcp, yamux, PeerId, Transport,
+ mdns, noise,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux,
};
use std::error::Error;
+use std::time::Duration;
+use tracing_subscriber::EnvFilter;
#[async_std::main]
async fn main() -> Result<(), Box> {
- env_logger::init();
-
- // Create a random key for ourselves.
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
-
- let transport = tcp::async_io::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&local_key)?)
- .multiplex(yamux::Config::default())
- .boxed();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
// We create a custom network behaviour that combines Kademlia and mDNS.
#[derive(NetworkBehaviour)]
@@ -54,15 +47,27 @@ async fn main() -> Result<(), Box> {
mdns: mdns::async_io::Behaviour,
}
- // Create a swarm to manage peers and events.
- let mut swarm = {
- // Create a Kademlia behaviour.
- let store = MemoryStore::new(local_peer_id);
- let kademlia = kad::Behaviour::new(local_peer_id, store);
- let mdns = mdns::async_io::Behaviour::new(mdns::Config::default(), local_peer_id)?;
- let behaviour = Behaviour { kademlia, mdns };
- SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id).build()
- };
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|key| {
+ Ok(Behaviour {
+ kademlia: kad::Behaviour::new(
+ key.public().to_peer_id(),
+ MemoryStore::new(key.public().to_peer_id()),
+ ),
+ mdns: mdns::async_io::Behaviour::new(
+ mdns::Config::default(),
+ key.public().to_peer_id(),
+ )?,
+ })
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
swarm.behaviour_mut().kademlia.set_mode(Some(Mode::Server));
@@ -148,7 +153,7 @@ fn handle_input_line(kademlia: &mut kad::Behaviour, line: String) {
Some("GET") => {
let key = {
match args.next() {
- Some(key) => kad::record::Key::new(&key),
+ Some(key) => kad::RecordKey::new(&key),
None => {
eprintln!("Expected key");
return;
@@ -160,7 +165,7 @@ fn handle_input_line(kademlia: &mut kad::Behaviour, line: String) {
Some("GET_PROVIDERS") => {
let key = {
match args.next() {
- Some(key) => kad::record::Key::new(&key),
+ Some(key) => kad::RecordKey::new(&key),
None => {
eprintln!("Expected key");
return;
@@ -172,7 +177,7 @@ fn handle_input_line(kademlia: &mut kad::Behaviour, line: String) {
Some("PUT") => {
let key = {
match args.next() {
- Some(key) => kad::record::Key::new(&key),
+ Some(key) => kad::RecordKey::new(&key),
None => {
eprintln!("Expected key");
return;
@@ -201,7 +206,7 @@ fn handle_input_line(kademlia: &mut kad::Behaviour, line: String) {
Some("PUT_PROVIDER") => {
let key = {
match args.next() {
- Some(key) => kad::record::Key::new(&key),
+ Some(key) => kad::RecordKey::new(&key),
None => {
eprintln!("Expected key");
return;
diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml
index 90462790c115..e38039a11bbb 100644
--- a/examples/file-sharing/Cargo.toml
+++ b/examples/file-sharing/Cargo.toml
@@ -5,14 +5,18 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
serde = { version = "1.0", features = ["derive"] }
async-std = { version = "1.12", features = ["attributes"] }
-clap = { version = "4.3.23", features = ["derive"] }
+clap = { version = "4.4.16", features = ["derive"] }
either = "1.9"
-env_logger = "0.10"
-futures = "0.3.28"
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = [ "async-std", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
void = "1.0.2"
[lints]
diff --git a/examples/file-sharing/src/main.rs b/examples/file-sharing/src/main.rs
index 4b6d368fc472..a834ee0600ec 100644
--- a/examples/file-sharing/src/main.rs
+++ b/examples/file-sharing/src/main.rs
@@ -31,10 +31,13 @@ use libp2p::{core::Multiaddr, multiaddr::Protocol};
use std::error::Error;
use std::io::Write;
use std::path::PathBuf;
+use tracing_subscriber::EnvFilter;
#[async_std::main]
async fn main() -> Result<(), Box> {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
let opt = Opt::parse();
@@ -59,9 +62,8 @@ async fn main() -> Result<(), Box> {
// In case the user provided an address of a peer on the CLI, dial it.
if let Some(addr) = opt.peer {
- let peer_id = match addr.iter().last() {
- Some(Protocol::P2p(peer_id)) => peer_id,
- _ => return Err("Expect peer multiaddr to contain peer ID.".into()),
+ let Some(Protocol::P2p(peer_id)) = addr.iter().last() else {
+ return Err("Expect peer multiaddr to contain peer ID.".into());
};
network_client
.dial(peer_id, addr)
diff --git a/examples/file-sharing/src/network.rs b/examples/file-sharing/src/network.rs
index f13e72f0000c..59625fc39ea4 100644
--- a/examples/file-sharing/src/network.rs
+++ b/examples/file-sharing/src/network.rs
@@ -1,5 +1,3 @@
-use async_std::io;
-use either::Either;
use futures::channel::{mpsc, oneshot};
use futures::prelude::*;
@@ -8,16 +6,16 @@ use libp2p::{
identity, kad,
multiaddr::Protocol,
noise,
- request_response::{self, ProtocolSupport, RequestId, ResponseChannel},
- swarm::{NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent},
- tcp, yamux, PeerId, Transport,
+ request_response::{self, OutboundRequestId, ProtocolSupport, ResponseChannel},
+ swarm::{NetworkBehaviour, Swarm, SwarmEvent},
+ tcp, yamux, PeerId,
};
-use libp2p::core::upgrade::Version;
use libp2p::StreamProtocol;
use serde::{Deserialize, Serialize};
use std::collections::{hash_map, HashMap, HashSet};
use std::error::Error;
+use std::time::Duration;
/// Creates the network components, namely:
///
@@ -41,18 +39,18 @@ pub(crate) async fn new(
};
let peer_id = id_keys.public().to_peer_id();
- let transport = tcp::async_io::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&id_keys)?)
- .multiplex(yamux::Config::default())
- .boxed();
-
- // Build the Swarm, connecting the lower layer transport logic with the
- // higher layer network behaviour logic.
- let mut swarm = SwarmBuilder::with_async_std_executor(
- transport,
- Behaviour {
- kademlia: kad::Behaviour::new(peer_id, kad::record::store::MemoryStore::new(peer_id)),
+ let mut swarm = libp2p::SwarmBuilder::with_existing_identity(id_keys)
+ .with_async_std()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|key| Behaviour {
+ kademlia: kad::Behaviour::new(
+ peer_id,
+ kad::store::MemoryStore::new(key.public().to_peer_id()),
+ ),
request_response: request_response::cbor::Behaviour::new(
[(
StreamProtocol::new("/file-exchange/1"),
@@ -60,10 +58,9 @@ pub(crate) async fn new(
)],
request_response::Config::default(),
),
- },
- peer_id,
- )
- .build();
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
swarm
.behaviour_mut()
@@ -178,7 +175,7 @@ pub(crate) struct EventLoop {
pending_start_providing: HashMap>,
pending_get_providers: HashMap>>,
pending_request_file:
- HashMap, Box>>>,
+ HashMap, Box>>>,
}
impl EventLoop {
@@ -211,10 +208,7 @@ impl EventLoop {
}
}
- async fn handle_event(
- &mut self,
- event: SwarmEvent>,
- ) {
+ async fn handle_event(&mut self, event: SwarmEvent) {
match event {
SwarmEvent::Behaviour(BehaviourEvent::Kademlia(
kad::Event::OutboundQueryProgressed {
@@ -408,7 +402,7 @@ impl EventLoop {
#[derive(NetworkBehaviour)]
struct Behaviour {
request_response: request_response::cbor::Behaviour,
- kademlia: kad::Behaviour,
+ kademlia: kad::Behaviour,
}
#[derive(Debug)]
diff --git a/examples/identify/Cargo.toml b/examples/identify/Cargo.toml
index cc30a0c614ca..2dcc780ac224 100644
--- a/examples/identify/Cargo.toml
+++ b/examples/identify/Cargo.toml
@@ -5,12 +5,16 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
-env_logger = "0.10"
-futures = "0.3.28"
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/identify/src/main.rs b/examples/identify/src/main.rs
index dc98fb582955..916317a5a438 100644
--- a/examples/identify/src/main.rs
+++ b/examples/identify/src/main.rs
@@ -20,35 +20,32 @@
#![doc = include_str!("../README.md")]
-use futures::prelude::*;
-use libp2p::{
- core::{multiaddr::Multiaddr, upgrade::Version},
- identify, identity, noise,
- swarm::{SwarmBuilder, SwarmEvent},
- tcp, yamux, PeerId, Transport,
-};
-use std::error::Error;
+use futures::StreamExt;
+use libp2p::{core::multiaddr::Multiaddr, identify, noise, swarm::SwarmEvent, tcp, yamux};
+use std::{error::Error, time::Duration};
+use tracing_subscriber::EnvFilter;
#[async_std::main]
async fn main() -> Result<(), Box> {
- env_logger::init();
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- let transport = tcp::async_io::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&local_key).unwrap())
- .multiplex(yamux::Config::default())
- .boxed();
-
- // Create a identify network behaviour.
- let behaviour = identify::Behaviour::new(identify::Config::new(
- "/ipfs/id/1.0.0".to_string(),
- local_key.public(),
- ));
-
- let mut swarm =
- SwarmBuilder::with_async_std_executor(transport, behaviour, local_peer_id).build();
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|key| {
+ identify::Behaviour::new(identify::Config::new(
+ "/ipfs/id/1.0.0".to_string(),
+ key.public(),
+ ))
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
// Tell the swarm to listen on all interfaces and a random, OS-assigned
// port.
diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml
index ae524e3857b6..e82031ce64f3 100644
--- a/examples/ipfs-kad/Cargo.toml
+++ b/examples/ipfs-kad/Cargo.toml
@@ -5,14 +5,19 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-tokio = { version = "1.12", features = ["rt-multi-thread", "macros"] }
+tokio = { version = "1.36", features = ["rt-multi-thread", "macros"] }
async-trait = "0.1"
-clap = { version = "4.3.23", features = ["derive"] }
+clap = { version = "4.4.16", features = ["derive"] }
env_logger = "0.10"
-futures = "0.3.28"
-anyhow = "1.0.75"
-libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "websocket", "yamux", "rsa"] }
+futures = "0.3.30"
+anyhow = "1.0.79"
+libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/ipfs-kad/src/main.rs b/examples/ipfs-kad/src/main.rs
index f912bd0565af..95921d6fa359 100644
--- a/examples/ipfs-kad/src/main.rs
+++ b/examples/ipfs-kad/src/main.rs
@@ -27,12 +27,9 @@ use std::time::{Duration, Instant};
use anyhow::{bail, Result};
use clap::Parser;
use futures::StreamExt;
-use libp2p::{
- bytes::BufMut,
- identity, kad,
- swarm::{SwarmBuilder, SwarmEvent},
- tokio_development_transport, PeerId,
-};
+use libp2p::swarm::{StreamProtocol, SwarmEvent};
+use libp2p::{bytes::BufMut, identity, kad, noise, tcp, yamux, PeerId};
+use tracing_subscriber::EnvFilter;
const BOOTNODES: [&str; 4] = [
"QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
@@ -41,34 +38,43 @@ const BOOTNODES: [&str; 4] = [
"QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
];
+const IPFS_PROTO_NAME: StreamProtocol = StreamProtocol::new("/ipfs/kad/1.0.0");
+
#[tokio::main]
async fn main() -> Result<()> {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
// Create a random key for ourselves.
let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
-
- // Set up a an encrypted DNS-enabled TCP Transport over the yamux protocol
- let transport = tokio_development_transport(local_key.clone())?;
-
- // Create a swarm to manage peers and events.
- let mut swarm = {
- // Create a Kademlia behaviour.
- let mut cfg = kad::Config::default();
- cfg.set_query_timeout(Duration::from_secs(5 * 60));
- let store = kad::store::MemoryStore::new(local_peer_id);
- let mut behaviour = kad::Behaviour::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 {
- behaviour.add_address(&peer.parse()?, "/dnsaddr/bootstrap.libp2p.io".parse()?);
- }
- SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()
- };
+ let mut swarm = libp2p::SwarmBuilder::with_existing_identity(local_key.clone())
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_dns()?
+ .with_behaviour(|key| {
+ // Create a Kademlia behaviour.
+ let mut cfg = kad::Config::new(IPFS_PROTO_NAME);
+ cfg.set_query_timeout(Duration::from_secs(5 * 60));
+ let store = kad::store::MemoryStore::new(key.public().to_peer_id());
+ kad::Behaviour::with_config(key.public().to_peer_id(), store, cfg)
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build();
+
+ // 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 {
+ swarm
+ .behaviour_mut()
+ .add_address(&peer.parse()?, "/dnsaddr/bootstrap.libp2p.io".parse()?);
+ }
let cli_opt = Opt::parse();
@@ -83,11 +89,11 @@ async fn main() -> Result<()> {
let mut pk_record_key = vec![];
pk_record_key.put_slice("/pk/".as_bytes());
- pk_record_key.put_slice(local_peer_id.to_bytes().as_slice());
+ pk_record_key.put_slice(swarm.local_peer_id().to_bytes().as_slice());
let mut pk_record =
kad::Record::new(pk_record_key, local_key.public().encode_protobuf());
- pk_record.publisher = Some(local_peer_id);
+ pk_record.publisher = Some(*swarm.local_peer_id());
pk_record.expires = Some(Instant::now().add(Duration::from_secs(60)));
swarm
diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml
index 4bf501886dbf..daa68cd8f5a1 100644
--- a/examples/ipfs-private/Cargo.toml
+++ b/examples/ipfs-private/Cargo.toml
@@ -5,13 +5,17 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-tokio = { version = "1.32", features = ["rt-multi-thread", "macros", "io-std"] }
+tokio = { version = "1.36", features = ["rt-multi-thread", "macros", "io-std"] }
async-trait = "0.1"
either = "1.9"
-env_logger = "0.10"
-futures = "0.3.28"
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/ipfs-private/src/main.rs b/examples/ipfs-private/src/main.rs
index fe83e891cfc6..a57bfd465e0f 100644
--- a/examples/ipfs-private/src/main.rs
+++ b/examples/ipfs-private/src/main.rs
@@ -23,39 +23,17 @@
use either::Either;
use futures::prelude::*;
use libp2p::{
- core::{muxing::StreamMuxerBox, transport, transport::upgrade::Version},
- gossipsub, identify, identity,
+ core::transport::upgrade::Version,
+ gossipsub, identify,
multiaddr::Protocol,
noise, ping,
pnet::{PnetConfig, PreSharedKey},
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
- tcp, yamux, Multiaddr, PeerId, Transport,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux, Multiaddr, Transport,
};
use std::{env, error::Error, fs, path::Path, str::FromStr, time::Duration};
use tokio::{io, io::AsyncBufReadExt, select};
-
-/// Builds the transport that serves as a common ground for all connections.
-pub fn build_transport(
- key_pair: identity::Keypair,
- psk: Option,
-) -> transport::Boxed<(PeerId, StreamMuxerBox)> {
- let noise_config = noise::Config::new(&key_pair).unwrap();
- let yamux_config = yamux::Config::default();
-
- let base_transport = tcp::tokio::Transport::new(tcp::Config::default().nodelay(true));
- let maybe_encrypted = match psk {
- Some(psk) => Either::Left(
- base_transport.and_then(move |socket, _| PnetConfig::new(psk).handshake(socket)),
- ),
- None => Either::Right(base_transport),
- };
- maybe_encrypted
- .upgrade(Version::V1Lazy)
- .authenticate(noise_config)
- .multiplex(yamux_config)
- .timeout(Duration::from_secs(20))
- .boxed()
-}
+use tracing_subscriber::EnvFilter;
/// Get the current ipfs repo path, either from the IPFS_PATH environment variable or
/// from the default $HOME/.ipfs
@@ -110,7 +88,9 @@ fn parse_legacy_multiaddr(text: &str) -> Result> {
#[tokio::main]
async fn main() -> Result<(), Box> {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
let ipfs_path = get_ipfs_path();
println!("using IPFS_PATH {ipfs_path:?}");
@@ -118,76 +98,68 @@ async fn main() -> Result<(), Box> {
.map(|text| PreSharedKey::from_str(&text))
.transpose()?;
- // Create a random PeerId
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
- println!("using random peer id: {local_peer_id:?}");
if let Some(psk) = psk {
println!("using swarm key with fingerprint: {}", psk.fingerprint());
}
- // Set up a an encrypted DNS-enabled TCP Transport over and Yamux protocol
- let transport = build_transport(local_key.clone(), psk);
-
// Create a Gosspipsub topic
let gossipsub_topic = gossipsub::IdentTopic::new("chat");
// We create a custom network behaviour that combines gossipsub, ping and identify.
#[derive(NetworkBehaviour)]
- #[behaviour(to_swarm = "MyBehaviourEvent")]
struct MyBehaviour {
gossipsub: gossipsub::Behaviour,
identify: identify::Behaviour,
ping: ping::Behaviour,
}
- enum MyBehaviourEvent {
- Gossipsub(gossipsub::Event),
- Identify(identify::Event),
- Ping(ping::Event),
- }
-
- impl From for MyBehaviourEvent {
- fn from(event: gossipsub::Event) -> Self {
- MyBehaviourEvent::Gossipsub(event)
- }
- }
-
- impl From for MyBehaviourEvent {
- fn from(event: identify::Event) -> Self {
- MyBehaviourEvent::Identify(event)
- }
- }
-
- impl From for MyBehaviourEvent {
- fn from(event: ping::Event) -> Self {
- MyBehaviourEvent::Ping(event)
- }
- }
-
- // Create a Swarm to manage peers and events
- let mut swarm = {
- let gossipsub_config = gossipsub::ConfigBuilder::default()
- .max_transmit_size(262144)
- .build()
- .expect("valid config");
- let mut behaviour = MyBehaviour {
- gossipsub: gossipsub::Behaviour::new(
- gossipsub::MessageAuthenticity::Signed(local_key.clone()),
- gossipsub_config,
- )
- .expect("Valid configuration"),
- identify: identify::Behaviour::new(identify::Config::new(
- "/ipfs/0.1.0".into(),
- local_key.public(),
- )),
- ping: ping::Behaviour::new(ping::Config::new()),
- };
-
- println!("Subscribing to {gossipsub_topic:?}");
- behaviour.gossipsub.subscribe(&gossipsub_topic).unwrap();
- SwarmBuilder::with_tokio_executor(transport, behaviour, local_peer_id).build()
- };
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_other_transport(|key| {
+ let noise_config = noise::Config::new(key).unwrap();
+ let yamux_config = yamux::Config::default();
+
+ let base_transport = tcp::tokio::Transport::new(tcp::Config::default().nodelay(true));
+ let maybe_encrypted = match psk {
+ Some(psk) => Either::Left(
+ base_transport
+ .and_then(move |socket, _| PnetConfig::new(psk).handshake(socket)),
+ ),
+ None => Either::Right(base_transport),
+ };
+ maybe_encrypted
+ .upgrade(Version::V1Lazy)
+ .authenticate(noise_config)
+ .multiplex(yamux_config)
+ })?
+ .with_dns()?
+ .with_behaviour(|key| {
+ let gossipsub_config = gossipsub::ConfigBuilder::default()
+ .max_transmit_size(262144)
+ .build()
+ .map_err(|msg| io::Error::new(io::ErrorKind::Other, msg))?; // Temporary hack because `build` does not return a proper `std::error::Error`.
+ Ok(MyBehaviour {
+ gossipsub: gossipsub::Behaviour::new(
+ gossipsub::MessageAuthenticity::Signed(key.clone()),
+ gossipsub_config,
+ )
+ .expect("Valid configuration"),
+ identify: identify::Behaviour::new(identify::Config::new(
+ "/ipfs/0.1.0".into(),
+ key.public(),
+ )),
+ ping: ping::Behaviour::new(ping::Config::new()),
+ })
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
+
+ println!("Subscribing to {gossipsub_topic:?}");
+ swarm
+ .behaviour_mut()
+ .gossipsub
+ .subscribe(&gossipsub_topic)
+ .unwrap();
// Reach out to other nodes if specified
for to_dial in std::env::args().skip(1) {
diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml
index 8cf7e1fc4068..39412d29aeaf 100644
--- a/examples/metrics/Cargo.toml
+++ b/examples/metrics/Cargo.toml
@@ -5,14 +5,21 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-env_logger = "0.10.0"
-futures = "0.3.27"
+futures = "0.3.30"
hyper = { version = "0.14", features = ["server", "tcp", "http1"] }
-libp2p = { path = "../../libp2p", features = ["async-std", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] }
-log = "0.4.20"
-tokio = { version = "1", features = ["rt-multi-thread"] }
-prometheus-client = "0.21.2"
+libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] }
+opentelemetry = { version = "0.20.0", features = ["rt-tokio", "metrics"] }
+opentelemetry-otlp = { version = "0.13.0", features = ["metrics"]}
+opentelemetry_api = "0.20.0"
+prometheus-client = { workspace = true }
+tokio = { version = "1", features = ["full"] }
+tracing = "0.1.37"
+tracing-opentelemetry = "0.21.0"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/metrics/README.md b/examples/metrics/README.md
index fc73cbd74106..160536985f15 100644
--- a/examples/metrics/README.md
+++ b/examples/metrics/README.md
@@ -1,6 +1,6 @@
## Description
-The example showcases how to run a p2p network with **libp2p** and collect metrics using `libp2p-metrics`.
+The example showcases how to run a p2p network with **libp2p** and collect metrics using `libp2p-metrics` as well as span data via `opentelemetry`.
It sets up multiple nodes in the network and measures various metrics, such as `libp2p_ping`, to evaluate the network's performance.
## Usage
@@ -34,6 +34,45 @@ To run the example, follow these steps:
After executing the command, you should see a long list of metrics printed to the terminal.
Make sure to check the `libp2p_ping` metrics, which should have a value greater than zero (`>0`).
+## Opentelemetry
+
+To see the span data collected as part of the `Swarm`s activity, start up an opentelemetry collector:
+
+```sh
+docker compose up
+```
+
+Then, configure tracing to output spans:
+
+```shell
+export RUST_LOG=info,[ConnectionHandler::poll]=trace,[NetworkBehaviour::poll]=trace
+```
+
+Next, (re)-start the two example for it to connect to the OTEL collector.
+Finally, open the Jaeger UI in a browser and explore the spans: http://localhost:16686.
+
+### Filtering spans
+
+For a precise documentation, please see the following documentation in tracing: .
+
+`rust-libp2p` consistently applies spans to the following functions:
+
+- `ConnectionHandler::poll` implementations
+- `NetworkBehaviour::poll` implementations
+
+The above spans are all called exactly that: `ConnectionHandler::poll` and `NetworkBehaviour::poll`.
+You can activate _all_ of them by setting:
+
+```
+RUST_LOG=[ConnectionHandler::poll]=trace
+```
+
+If you just wanted to see the spans of the `libp2p_ping` crate, you can filter like this:
+
+```
+RUST_LOG=libp2p_ping[ConnectionHandler::poll]=trace
+```
+
## Conclusion
This example demonstrates how to utilize the `libp2p-metrics` crate to collect and analyze metrics in a libp2p network.
diff --git a/examples/metrics/docker-compose.yml b/examples/metrics/docker-compose.yml
new file mode 100644
index 000000000000..06d8d5becfeb
--- /dev/null
+++ b/examples/metrics/docker-compose.yml
@@ -0,0 +1,23 @@
+version: "2"
+services:
+ # Jaeger
+ jaeger-all-in-one:
+ image: jaegertracing/all-in-one:latest
+ restart: always
+ ports:
+ - "16686:16686"
+ - "14268"
+ - "14250"
+
+ # Collector
+ otel-collector:
+ image: otel/opentelemetry-collector:0.88.0
+ restart: always
+ command: ["--config=/etc/otel-collector-config.yaml"]
+ volumes:
+ - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
+ ports:
+ - "13133:13133" # health_check extension
+ - "4317:4317" # OTLP gRPC receiver
+ depends_on:
+ - jaeger-all-in-one
diff --git a/examples/metrics/otel-collector-config.yaml b/examples/metrics/otel-collector-config.yaml
new file mode 100644
index 000000000000..8755848cd6e9
--- /dev/null
+++ b/examples/metrics/otel-collector-config.yaml
@@ -0,0 +1,25 @@
+receivers:
+ otlp:
+ protocols:
+ grpc:
+ endpoint: 0.0.0.0:4317
+
+exporters:
+ debug:
+ otlp:
+ endpoint: jaeger-all-in-one:4317
+ tls:
+ insecure: true
+
+processors:
+ batch:
+
+service:
+ telemetry:
+ logs:
+ level: "debug"
+ pipelines:
+ traces:
+ receivers: [otlp]
+ processors: [batch]
+ exporters: [debug, otlp]
diff --git a/examples/metrics/src/http_service.rs b/examples/metrics/src/http_service.rs
index 46cb7aacb842..8c77d724ea30 100644
--- a/examples/metrics/src/http_service.rs
+++ b/examples/metrics/src/http_service.rs
@@ -21,7 +21,6 @@
use hyper::http::StatusCode;
use hyper::service::Service;
use hyper::{Body, Method, Request, Response, Server};
-use log::{error, info};
use prometheus_client::encoding::text::encode;
use prometheus_client::registry::Registry;
use std::future::Future;
@@ -33,18 +32,14 @@ const METRICS_CONTENT_TYPE: &str = "application/openmetrics-text;charset=utf-8;v
pub(crate) async fn metrics_server(registry: Registry) -> Result<(), std::io::Error> {
// Serve on localhost.
- let addr = ([127, 0, 0, 1], 8080).into();
-
- // Use the tokio runtime to run the hyper server.
- let rt = tokio::runtime::Runtime::new()?;
- rt.block_on(async {
- let server = Server::bind(&addr).serve(MakeMetricService::new(registry));
- info!("Metrics server on http://{}/metrics", server.local_addr());
- if let Err(e) = server.await {
- error!("server error: {}", e);
- }
- Ok(())
- })
+ let addr = ([127, 0, 0, 1], 0).into();
+
+ let server = Server::bind(&addr).serve(MakeMetricService::new(registry));
+ tracing::info!(metrics_server=%format!("http://{}/metrics", server.local_addr()));
+ if let Err(e) = server.await {
+ tracing::error!("server error: {}", e);
+ }
+ Ok(())
}
pub(crate) struct MetricService {
diff --git a/examples/metrics/src/main.rs b/examples/metrics/src/main.rs
index b28abaee9418..3ab6815cb32d 100644
--- a/examples/metrics/src/main.rs
+++ b/examples/metrics/src/main.rs
@@ -20,71 +20,90 @@
#![doc = include_str!("../README.md")]
-use env_logger::Env;
-use futures::executor::block_on;
-use futures::stream::StreamExt;
-use libp2p::core::{upgrade::Version, Multiaddr, Transport};
-use libp2p::identity::PeerId;
+use futures::StreamExt;
+use libp2p::core::Multiaddr;
use libp2p::metrics::{Metrics, Recorder};
-use libp2p::swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent};
+use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
use libp2p::{identify, identity, noise, ping, tcp, yamux};
-use log::info;
+use opentelemetry::sdk;
+use opentelemetry_api::KeyValue;
use prometheus_client::registry::Registry;
use std::error::Error;
-use std::thread;
use std::time::Duration;
+use tracing_subscriber::layer::SubscriberExt;
+use tracing_subscriber::util::SubscriberInitExt;
+use tracing_subscriber::{EnvFilter, Layer};
mod http_service;
-fn main() -> Result<(), Box> {
- env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
+#[tokio::main]
+async fn main() -> Result<(), Box> {
+ setup_tracing()?;
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
- let local_pub_key = local_key.public();
+ let mut metric_registry = Registry::default();
- let mut swarm = SwarmBuilder::without_executor(
- tcp::async_io::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&local_key)?)
- .multiplex(yamux::Config::default())
- .boxed(),
- Behaviour::new(local_pub_key),
- local_peer_id,
- )
- .idle_connection_timeout(Duration::from_secs(60))
- .build();
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_bandwidth_metrics(&mut metric_registry)
+ .with_behaviour(|key| Behaviour::new(key.public()))?
+ .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX)))
+ .build();
swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse()?)?;
if let Some(addr) = std::env::args().nth(1) {
let remote: Multiaddr = addr.parse()?;
swarm.dial(remote)?;
- info!("Dialed {}", addr)
+ tracing::info!(address=%addr, "Dialed address")
}
- let mut metric_registry = Registry::default();
let metrics = Metrics::new(&mut metric_registry);
- thread::spawn(move || block_on(http_service::metrics_server(metric_registry)));
+ tokio::spawn(http_service::metrics_server(metric_registry));
- block_on(async {
- loop {
- match swarm.select_next_some().await {
- SwarmEvent::Behaviour(BehaviourEvent::Ping(ping_event)) => {
- info!("{:?}", ping_event);
- metrics.record(&ping_event);
- }
- SwarmEvent::Behaviour(BehaviourEvent::Identify(identify_event)) => {
- info!("{:?}", identify_event);
- metrics.record(&identify_event);
- }
- swarm_event => {
- info!("{:?}", swarm_event);
- metrics.record(&swarm_event);
- }
+ loop {
+ match swarm.select_next_some().await {
+ SwarmEvent::Behaviour(BehaviourEvent::Ping(ping_event)) => {
+ tracing::info!(?ping_event);
+ metrics.record(&ping_event);
+ }
+ SwarmEvent::Behaviour(BehaviourEvent::Identify(identify_event)) => {
+ tracing::info!(?identify_event);
+ metrics.record(&identify_event);
+ }
+ swarm_event => {
+ tracing::info!(?swarm_event);
+ metrics.record(&swarm_event);
}
}
- });
+ }
+}
+
+fn setup_tracing() -> Result<(), Box> {
+ let tracer = opentelemetry_otlp::new_pipeline()
+ .tracing()
+ .with_exporter(opentelemetry_otlp::new_exporter().tonic())
+ .with_trace_config(
+ sdk::trace::Config::default().with_resource(sdk::Resource::new(vec![KeyValue::new(
+ "service.name",
+ "libp2p",
+ )])),
+ )
+ .install_batch(opentelemetry::runtime::Tokio)?;
+
+ tracing_subscriber::registry()
+ .with(tracing_subscriber::fmt::layer().with_filter(EnvFilter::from_default_env()))
+ .with(
+ tracing_opentelemetry::layer()
+ .with_tracer(tracer)
+ .with_filter(EnvFilter::from_default_env()),
+ )
+ .try_init()?;
+
Ok(())
}
diff --git a/examples/ping/Cargo.toml b/examples/ping/Cargo.toml
index b39df505b4ac..db47e4e2d8eb 100644
--- a/examples/ping/Cargo.toml
+++ b/examples/ping/Cargo.toml
@@ -5,11 +5,15 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-env_logger = "0.10.0"
-futures = "0.3.28"
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = ["noise", "ping", "tcp", "tokio", "yamux"] }
-tokio = { version = "1.32.0", features = ["full"] }
+tokio = { version = "1.36.0", features = ["full"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/ping/src/main.rs b/examples/ping/src/main.rs
index 25939a132c1b..911b0384f899 100644
--- a/examples/ping/src/main.rs
+++ b/examples/ping/src/main.rs
@@ -21,31 +21,26 @@
#![doc = include_str!("../README.md")]
use futures::prelude::*;
-use libp2p::core::upgrade::Version;
-use libp2p::{
- identity, noise, ping,
- swarm::{SwarmBuilder, SwarmEvent},
- tcp, yamux, Multiaddr, PeerId, Transport,
-};
-use std::error::Error;
-use std::time::Duration;
+use libp2p::{noise, ping, swarm::SwarmEvent, tcp, yamux, Multiaddr};
+use std::{error::Error, time::Duration};
+use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() -> Result<(), Box> {
- env_logger::init();
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- let transport = tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&local_key)?)
- .multiplex(yamux::Config::default())
- .boxed();
-
- let mut swarm =
- SwarmBuilder::with_tokio_executor(transport, ping::Behaviour::default(), local_peer_id)
- .idle_connection_timeout(Duration::from_secs(60)) // For illustrative purposes, keep idle connections alive for a minute so we can observe a few pings.
- .build();
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|_| ping::Behaviour::default())?
+ .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX)))
+ .build();
// Tell the swarm to listen on all interfaces and a random, OS-assigned
// port.
diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml
index 39d899f5573d..65c7c7070877 100644
--- a/examples/relay-server/Cargo.toml
+++ b/examples/relay-server/Cargo.toml
@@ -5,13 +5,17 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
-clap = { version = "4.3.23", features = ["derive"] }
+clap = { version = "4.4.16", features = ["derive"] }
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
-env_logger = "0.10.0"
-futures = "0.3.28"
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = [ "async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/relay-server/src/main.rs b/examples/relay-server/src/main.rs
index ab87615d74e5..bf5817454f8e 100644
--- a/examples/relay-server/src/main.rs
+++ b/examples/relay-server/src/main.rs
@@ -22,61 +22,46 @@
#![doc = include_str!("../README.md")]
use clap::Parser;
+use futures::executor::block_on;
use futures::stream::StreamExt;
-use futures::{executor::block_on, future::Either};
use libp2p::{
core::multiaddr::Protocol,
- core::muxing::StreamMuxerBox,
- core::upgrade,
- core::{Multiaddr, Transport},
- identify, identity,
- identity::PeerId,
- noise, ping, quic, relay,
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
- tcp,
+ core::Multiaddr,
+ identify, identity, noise, ping, relay,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux,
};
use std::error::Error;
use std::net::{Ipv4Addr, Ipv6Addr};
+use tracing_subscriber::EnvFilter;
fn main() -> Result<(), Box> {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
let opt = Opt::parse();
- println!("opt: {opt:?}");
// Create a static known PeerId based on given secret
let local_key: identity::Keypair = generate_ed25519(opt.secret_key_seed);
- let local_peer_id = PeerId::from(local_key.public());
- let tcp_transport = tcp::async_io::Transport::default();
-
- let tcp_transport = tcp_transport
- .upgrade(upgrade::Version::V1Lazy)
- .authenticate(
- noise::Config::new(&local_key).expect("Signing libp2p-noise static DH keypair failed."),
- )
- .multiplex(libp2p::yamux::Config::default());
-
- let quic_transport = quic::async_std::Transport::new(quic::Config::new(&local_key));
-
- let transport = quic_transport
- .or_transport(tcp_transport)
- .map(|either_output, _| match either_output {
- Either::Left((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)),
- Either::Right((peer_id, muxer)) => (peer_id, StreamMuxerBox::new(muxer)),
- })
- .boxed();
-
- let behaviour = Behaviour {
- relay: relay::Behaviour::new(local_peer_id, Default::default()),
- ping: ping::Behaviour::new(ping::Config::new()),
- identify: identify::Behaviour::new(identify::Config::new(
- "/TODO/0.0.1".to_string(),
- local_key.public(),
- )),
- };
-
- let mut swarm = SwarmBuilder::without_executor(transport, behaviour, local_peer_id).build();
+ let mut swarm = libp2p::SwarmBuilder::with_existing_identity(local_key)
+ .with_async_std()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_quic()
+ .with_behaviour(|key| Behaviour {
+ relay: relay::Behaviour::new(key.public().to_peer_id(), Default::default()),
+ ping: ping::Behaviour::new(ping::Config::new()),
+ identify: identify::Behaviour::new(identify::Config::new(
+ "/TODO/0.0.1".to_string(),
+ key.public(),
+ )),
+ })?
+ .build();
// Listen on all interfaces
let listen_addr_tcp = Multiaddr::empty()
diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml
index e98f465bc3bd..edd5b8031a4e 100644
--- a/examples/rendezvous/Cargo.toml
+++ b/examples/rendezvous/Cargo.toml
@@ -5,14 +5,17 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
-env_logger = "0.10.0"
-futures = "0.3.28"
+futures = "0.3.30"
libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] }
-log = "0.4"
-tokio = { version = "1.32", features = ["rt-multi-thread", "macros", "time"] }
+tokio = { version = "1.36", features = ["rt-multi-thread", "macros", "time"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/rendezvous/src/bin/rzv-discover.rs b/examples/rendezvous/src/bin/rzv-discover.rs
index ac45afae8408..edd3d10a0ce0 100644
--- a/examples/rendezvous/src/bin/rzv-discover.rs
+++ b/examples/rendezvous/src/bin/rzv-discover.rs
@@ -20,41 +20,41 @@
use futures::StreamExt;
use libp2p::{
- core::transport::upgrade::Version,
- identity,
multiaddr::Protocol,
noise, ping, rendezvous,
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
- tcp, yamux, Multiaddr, PeerId, Transport,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux, Multiaddr,
};
+use std::error::Error;
use std::time::Duration;
+use tracing_subscriber::EnvFilter;
const NAMESPACE: &str = "rendezvous";
#[tokio::main]
-async fn main() {
- env_logger::init();
+async fn main() -> Result<(), Box> {
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- let key_pair = identity::Keypair::generate_ed25519();
let rendezvous_point_address = "/ip4/127.0.0.1/tcp/62649".parse::().unwrap();
let rendezvous_point = "12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN"
.parse()
.unwrap();
- let mut swarm = SwarmBuilder::with_tokio_executor(
- tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&key_pair).unwrap())
- .multiplex(yamux::Config::default())
- .boxed(),
- MyBehaviour {
- rendezvous: rendezvous::client::Behaviour::new(key_pair.clone()),
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|key| MyBehaviour {
+ rendezvous: rendezvous::client::Behaviour::new(key.clone()),
ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
- },
- PeerId::from(key_pair.public()),
- )
- .idle_connection_timeout(Duration::from_secs(5))
- .build();
+ })?
+ .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build();
swarm.dial(rendezvous_point_address.clone()).unwrap();
@@ -65,7 +65,7 @@ async fn main() {
tokio::select! {
event = swarm.select_next_some() => match event {
SwarmEvent::ConnectionEstablished { peer_id, .. } if peer_id == rendezvous_point => {
- log::info!(
+ tracing::info!(
"Connected to rendezvous point, discovering nodes in '{}' namespace ...",
NAMESPACE
);
@@ -87,7 +87,7 @@ async fn main() {
for registration in registrations {
for address in registration.record.addresses() {
let peer = registration.record.peer_id();
- log::info!("Discovered peer {} at {}", peer, address);
+ tracing::info!(%peer, %address, "Discovered peer");
let p2p_suffix = Protocol::P2p(peer);
let address_with_p2p =
@@ -106,10 +106,10 @@ async fn main() {
result: Ok(rtt),
..
})) if peer != rendezvous_point => {
- log::info!("Ping to {} is {}ms", peer, rtt.as_millis())
+ tracing::info!(%peer, "Ping is {}ms", rtt.as_millis())
}
other => {
- log::debug!("Unhandled {:?}", other);
+ tracing::debug!("Unhandled {:?}", other);
}
},
_ = discover_tick.tick(), if cookie.is_some() =>
diff --git a/examples/rendezvous/src/bin/rzv-identify.rs b/examples/rendezvous/src/bin/rzv-identify.rs
index 95ed7a5ccd8a..1d5455928298 100644
--- a/examples/rendezvous/src/bin/rzv-identify.rs
+++ b/examples/rendezvous/src/bin/rzv-identify.rs
@@ -20,41 +20,43 @@
use futures::StreamExt;
use libp2p::{
- core::transport::upgrade::Version,
- identify, identity, noise, ping, rendezvous,
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
- tcp, yamux, Multiaddr, PeerId, Transport,
+ identify, noise, ping, rendezvous,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux, Multiaddr,
};
use std::time::Duration;
+use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- let key_pair = identity::Keypair::generate_ed25519();
let rendezvous_point_address = "/ip4/127.0.0.1/tcp/62649".parse::().unwrap();
let rendezvous_point = "12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN"
.parse()
.unwrap();
- let mut swarm = SwarmBuilder::with_tokio_executor(
- tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&key_pair).unwrap())
- .multiplex(yamux::Config::default())
- .boxed(),
- MyBehaviour {
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )
+ .unwrap()
+ .with_behaviour(|key| MyBehaviour {
identify: identify::Behaviour::new(identify::Config::new(
"rendezvous-example/1.0.0".to_string(),
- key_pair.public(),
+ key.public(),
)),
- rendezvous: rendezvous::client::Behaviour::new(key_pair.clone()),
+ rendezvous: rendezvous::client::Behaviour::new(key.clone()),
ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
- },
- PeerId::from(key_pair.public()),
- )
- .idle_connection_timeout(Duration::from_secs(5))
- .build();
+ })
+ .unwrap()
+ .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build();
let _ = swarm.listen_on("/ip4/0.0.0.0/tcp/0".parse().unwrap());
@@ -63,14 +65,14 @@ async fn main() {
while let Some(event) = swarm.next().await {
match event {
SwarmEvent::NewListenAddr { address, .. } => {
- log::info!("Listening on {}", address);
+ tracing::info!("Listening on {}", address);
}
SwarmEvent::ConnectionClosed {
peer_id,
cause: Some(error),
..
} if peer_id == rendezvous_point => {
- log::error!("Lost connection to rendezvous point {}", error);
+ tracing::error!("Lost connection to rendezvous point {}", error);
}
// once `/identify` did its job, we know our external address and can register
SwarmEvent::Behaviour(MyBehaviourEvent::Identify(identify::Event::Received {
@@ -81,7 +83,7 @@ async fn main() {
rendezvous_point,
None,
) {
- log::error!("Failed to register: {error}");
+ tracing::error!("Failed to register: {error}");
return;
}
}
@@ -92,7 +94,7 @@ async fn main() {
rendezvous_node,
},
)) => {
- log::info!(
+ tracing::info!(
"Registered for namespace '{}' at rendezvous point {} for the next {} seconds",
namespace,
rendezvous_node,
@@ -106,7 +108,7 @@ async fn main() {
error,
},
)) => {
- log::error!(
+ tracing::error!(
"Failed to register: rendezvous_node={}, namespace={}, error_code={:?}",
rendezvous_node,
namespace,
@@ -119,10 +121,10 @@ async fn main() {
result: Ok(rtt),
..
})) if peer != rendezvous_point => {
- log::info!("Ping to {} is {}ms", peer, rtt.as_millis())
+ tracing::info!("Ping to {} is {}ms", peer, rtt.as_millis())
}
other => {
- log::debug!("Unhandled {:?}", other);
+ tracing::debug!("Unhandled {:?}", other);
}
}
}
diff --git a/examples/rendezvous/src/bin/rzv-register.rs b/examples/rendezvous/src/bin/rzv-register.rs
index 51acfee2a71b..bd848238d4a1 100644
--- a/examples/rendezvous/src/bin/rzv-register.rs
+++ b/examples/rendezvous/src/bin/rzv-register.rs
@@ -20,37 +20,39 @@
use futures::StreamExt;
use libp2p::{
- core::transport::upgrade::Version,
- identity, noise, ping, rendezvous,
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
- tcp, yamux, Multiaddr, PeerId, Transport,
+ noise, ping, rendezvous,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux, Multiaddr,
};
use std::time::Duration;
+use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() {
- env_logger::init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- let key_pair = identity::Keypair::generate_ed25519();
let rendezvous_point_address = "/ip4/127.0.0.1/tcp/62649".parse::().unwrap();
let rendezvous_point = "12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN"
.parse()
.unwrap();
- let mut swarm = SwarmBuilder::with_tokio_executor(
- tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&key_pair).unwrap())
- .multiplex(yamux::Config::default())
- .boxed(),
- MyBehaviour {
- rendezvous: rendezvous::client::Behaviour::new(key_pair.clone()),
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )
+ .unwrap()
+ .with_behaviour(|key| MyBehaviour {
+ rendezvous: rendezvous::client::Behaviour::new(key.clone()),
ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
- },
- PeerId::from(key_pair.public()),
- )
- .idle_connection_timeout(Duration::from_secs(5))
- .build();
+ })
+ .unwrap()
+ .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build();
// In production the external address should be the publicly facing IP address of the rendezvous point.
// This address is recorded in the registration entry by the rendezvous point.
@@ -62,14 +64,14 @@ async fn main() {
while let Some(event) = swarm.next().await {
match event {
SwarmEvent::NewListenAddr { address, .. } => {
- log::info!("Listening on {}", address);
+ tracing::info!("Listening on {}", address);
}
SwarmEvent::ConnectionClosed {
peer_id,
cause: Some(error),
..
} if peer_id == rendezvous_point => {
- log::error!("Lost connection to rendezvous point {}", error);
+ tracing::error!("Lost connection to rendezvous point {}", error);
}
SwarmEvent::ConnectionEstablished { peer_id, .. } if peer_id == rendezvous_point => {
if let Err(error) = swarm.behaviour_mut().rendezvous.register(
@@ -77,10 +79,10 @@ async fn main() {
rendezvous_point,
None,
) {
- log::error!("Failed to register: {error}");
+ tracing::error!("Failed to register: {error}");
return;
}
- log::info!("Connection established with rendezvous point {}", peer_id);
+ tracing::info!("Connection established with rendezvous point {}", peer_id);
}
// once `/identify` did its job, we know our external address and can register
SwarmEvent::Behaviour(MyBehaviourEvent::Rendezvous(
@@ -90,7 +92,7 @@ async fn main() {
rendezvous_node,
},
)) => {
- log::info!(
+ tracing::info!(
"Registered for namespace '{}' at rendezvous point {} for the next {} seconds",
namespace,
rendezvous_node,
@@ -104,7 +106,7 @@ async fn main() {
error,
},
)) => {
- log::error!(
+ tracing::error!(
"Failed to register: rendezvous_node={}, namespace={}, error_code={:?}",
rendezvous_node,
namespace,
@@ -117,10 +119,10 @@ async fn main() {
result: Ok(rtt),
..
})) if peer != rendezvous_point => {
- log::info!("Ping to {} is {}ms", peer, rtt.as_millis())
+ tracing::info!("Ping to {} is {}ms", peer, rtt.as_millis())
}
other => {
- log::debug!("Unhandled {:?}", other);
+ tracing::debug!("Unhandled {:?}", other);
}
}
}
diff --git a/examples/rendezvous/src/main.rs b/examples/rendezvous/src/main.rs
index a3ed3c0fce5c..a15bc1ca2d37 100644
--- a/examples/rendezvous/src/main.rs
+++ b/examples/rendezvous/src/main.rs
@@ -22,52 +22,56 @@
use futures::StreamExt;
use libp2p::{
- core::transport::upgrade::Version,
- identify, identity, noise, ping, rendezvous,
- swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent},
- tcp, yamux, PeerId, Transport,
+ identify, noise, ping, rendezvous,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux,
};
+use std::error::Error;
use std::time::Duration;
+use tracing_subscriber::EnvFilter;
#[tokio::main]
-async fn main() {
- env_logger::init();
+async fn main() -> Result<(), Box> {
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- let key_pair = identity::Keypair::generate_ed25519();
+ // Results in PeerID 12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN which is
+ // used as the rendezvous point by the other peer examples.
+ let keypair = libp2p::identity::Keypair::ed25519_from_bytes([0; 32]).unwrap();
- let mut swarm = SwarmBuilder::with_tokio_executor(
- tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&key_pair).unwrap())
- .multiplex(yamux::Config::default())
- .boxed(),
- MyBehaviour {
+ let mut swarm = libp2p::SwarmBuilder::with_existing_identity(keypair)
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|key| MyBehaviour {
identify: identify::Behaviour::new(identify::Config::new(
"rendezvous-example/1.0.0".to_string(),
- key_pair.public(),
+ key.public(),
)),
rendezvous: rendezvous::server::Behaviour::new(rendezvous::server::Config::default()),
ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
- },
- PeerId::from(key_pair.public()),
- )
- .idle_connection_timeout(Duration::from_secs(5))
- .build();
+ })?
+ .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build();
let _ = swarm.listen_on("/ip4/0.0.0.0/tcp/62649".parse().unwrap());
while let Some(event) = swarm.next().await {
match event {
SwarmEvent::ConnectionEstablished { peer_id, .. } => {
- log::info!("Connected to {}", peer_id);
+ tracing::info!("Connected to {}", peer_id);
}
SwarmEvent::ConnectionClosed { peer_id, .. } => {
- log::info!("Disconnected from {}", peer_id);
+ tracing::info!("Disconnected from {}", peer_id);
}
SwarmEvent::Behaviour(MyBehaviourEvent::Rendezvous(
rendezvous::server::Event::PeerRegistered { peer, registration },
)) => {
- log::info!(
+ tracing::info!(
"Peer {} registered for namespace '{}'",
peer,
registration.namespace
@@ -79,17 +83,19 @@ async fn main() {
registrations,
},
)) => {
- log::info!(
+ tracing::info!(
"Served peer {} with {} registrations",
enquirer,
registrations.len()
);
}
other => {
- log::debug!("Unhandled {:?}", other);
+ tracing::debug!("Unhandled {:?}", other);
}
}
}
+
+ Ok(())
}
#[derive(NetworkBehaviour)]
diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml
new file mode 100644
index 000000000000..37f84e6ed62d
--- /dev/null
+++ b/examples/stream/Cargo.toml
@@ -0,0 +1,22 @@
+[package]
+name = "stream-example"
+version = "0.1.0"
+edition = "2021"
+publish = false
+license = "MIT"
+
+[package.metadata.release]
+release = false
+
+[dependencies]
+anyhow = "1"
+futures = "0.3.29"
+libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] }
+libp2p-stream = { path = "../../protocols/stream", version = "0.1.0-alpha" }
+rand = "0.8"
+tokio = { version = "1.36", features = ["full"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
+
+[lints]
+workspace = true
diff --git a/examples/stream/README.md b/examples/stream/README.md
new file mode 100644
index 000000000000..8437a5ea21e7
--- /dev/null
+++ b/examples/stream/README.md
@@ -0,0 +1,35 @@
+## Description
+
+This example shows the usage of the `stream::Behaviour`.
+As a counter-part to the `request_response::Behaviour`, the `stream::Behaviour` allows users to write stream-oriented protocols whilst having minimal interaction with the `Swarm`.
+
+In this showcase, we implement an echo protocol: All incoming data is echoed back to the dialer, until the stream is closed.
+
+## Usage
+
+To run the example, follow these steps:
+
+1. Start an instance of the example in one terminal:
+
+ ```sh
+ cargo run --bin stream-example
+ ```
+
+ Observe printed listen address.
+
+2. Start another instance in a new terminal, providing the listen address of the first one.
+
+ ```sh
+ cargo run --bin stream-example --
+ ```
+
+3. Both terminals should now continuosly print messages.
+
+## Conclusion
+
+The `stream::Behaviour` is an "escape-hatch" from the way typical rust-libp2p protocols are written.
+It is suitable for several scenarios including:
+
+- prototyping of new protocols
+- experimentation with rust-libp2p
+- integration in `async/await`-heavy applications
\ No newline at end of file
diff --git a/examples/stream/src/main.rs b/examples/stream/src/main.rs
new file mode 100644
index 000000000000..872ab8c3b980
--- /dev/null
+++ b/examples/stream/src/main.rs
@@ -0,0 +1,154 @@
+use std::{io, time::Duration};
+
+use anyhow::{Context, Result};
+use futures::{AsyncReadExt, AsyncWriteExt, StreamExt};
+use libp2p::{multiaddr::Protocol, Multiaddr, PeerId, Stream, StreamProtocol};
+use libp2p_stream as stream;
+use rand::RngCore;
+use tracing::level_filters::LevelFilter;
+use tracing_subscriber::EnvFilter;
+
+const ECHO_PROTOCOL: StreamProtocol = StreamProtocol::new("/echo");
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ tracing_subscriber::fmt()
+ .with_env_filter(
+ EnvFilter::builder()
+ .with_default_directive(LevelFilter::INFO.into())
+ .from_env()?,
+ )
+ .init();
+
+ let maybe_address = std::env::args()
+ .nth(1)
+ .map(|arg| arg.parse::())
+ .transpose()
+ .context("Failed to parse argument as `Multiaddr`")?;
+
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_quic()
+ .with_behaviour(|_| stream::Behaviour::new())?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(10)))
+ .build();
+
+ swarm.listen_on("/ip4/127.0.0.1/udp/0/quic-v1".parse()?)?;
+
+ let mut incoming_streams = swarm
+ .behaviour()
+ .new_control()
+ .accept(ECHO_PROTOCOL)
+ .unwrap();
+
+ // Deal with incoming streams.
+ // Spawning a dedicated task is just one way of doing this.
+ // libp2p doesn't care how you handle incoming streams but you _must_ handle them somehow.
+ // To mitigate DoS attacks, libp2p will internally drop incoming streams if your application cannot keep up processing them.
+ tokio::spawn(async move {
+ // This loop handles incoming streams _sequentially_ but that doesn't have to be the case.
+ // You can also spawn a dedicated task per stream if you want to.
+ // Be aware that this breaks backpressure though as spawning new tasks is equivalent to an unbounded buffer.
+ // Each task needs memory meaning an aggressive remote peer may force you OOM this way.
+
+ while let Some((peer, stream)) = incoming_streams.next().await {
+ match echo(stream).await {
+ Ok(n) => {
+ tracing::info!(%peer, "Echoed {n} bytes!");
+ }
+ Err(e) => {
+ tracing::warn!(%peer, "Echo failed: {e}");
+ continue;
+ }
+ };
+ }
+ });
+
+ // In this demo application, the dialing peer initiates the protocol.
+ if let Some(address) = maybe_address {
+ let Some(Protocol::P2p(peer_id)) = address.iter().last() else {
+ anyhow::bail!("Provided address does not end in `/p2p`");
+ };
+
+ swarm.dial(address)?;
+
+ tokio::spawn(connection_handler(peer_id, swarm.behaviour().new_control()));
+ }
+
+ // Poll the swarm to make progress.
+ loop {
+ let event = swarm.next().await.expect("never terminates");
+
+ match event {
+ libp2p::swarm::SwarmEvent::NewListenAddr { address, .. } => {
+ let listen_address = address.with_p2p(*swarm.local_peer_id()).unwrap();
+ tracing::info!(%listen_address);
+ }
+ event => tracing::trace!(?event),
+ }
+ }
+}
+
+/// A very simple, `async fn`-based connection handler for our custom echo protocol.
+async fn connection_handler(peer: PeerId, mut control: stream::Control) {
+ loop {
+ tokio::time::sleep(Duration::from_secs(1)).await; // Wait a second between echos.
+
+ let stream = match control.open_stream(peer, ECHO_PROTOCOL).await {
+ Ok(stream) => stream,
+ Err(error @ stream::OpenStreamError::UnsupportedProtocol(_)) => {
+ tracing::info!(%peer, %error);
+ return;
+ }
+ Err(error) => {
+ // Other errors may be temporary.
+ // In production, something like an exponential backoff / circuit-breaker may be more appropriate.
+ tracing::debug!(%peer, %error);
+ continue;
+ }
+ };
+
+ if let Err(e) = send(stream).await {
+ tracing::warn!(%peer, "Echo protocol failed: {e}");
+ continue;
+ }
+
+ tracing::info!(%peer, "Echo complete!")
+ }
+}
+
+async fn echo(mut stream: Stream) -> io::Result {
+ let mut total = 0;
+
+ let mut buf = [0u8; 100];
+
+ loop {
+ let read = stream.read(&mut buf).await?;
+ if read == 0 {
+ return Ok(total);
+ }
+
+ total += read;
+ stream.write_all(&buf[..read]).await?;
+ }
+}
+
+async fn send(mut stream: Stream) -> io::Result<()> {
+ let num_bytes = rand::random::() % 1000;
+
+ let mut bytes = vec![0; num_bytes];
+ rand::thread_rng().fill_bytes(&mut bytes);
+
+ stream.write_all(&bytes).await?;
+
+ let mut buf = vec![0; num_bytes];
+ stream.read_exact(&mut buf).await?;
+
+ if bytes != buf {
+ return Err(io::Error::new(io::ErrorKind::Other, "incorrect echo"));
+ }
+
+ stream.close().await?;
+
+ Ok(())
+}
diff --git a/examples/upnp/Cargo.toml b/examples/upnp/Cargo.toml
index 74e88bf82bd6..db9825c8742b 100644
--- a/examples/upnp/Cargo.toml
+++ b/examples/upnp/Cargo.toml
@@ -5,10 +5,14 @@ edition = "2021"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
-futures = "0.3.28"
-libp2p = { path = "../../libp2p", features = ["tokio", "dns", "macros", "noise", "ping", "tcp", "websocket", "yamux", "upnp"] }
+futures = "0.3.30"
+libp2p = { path = "../../libp2p", features = ["tokio", "dns", "macros", "noise", "ping", "tcp", "yamux", "upnp"] }
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[lints]
workspace = true
diff --git a/examples/upnp/src/main.rs b/examples/upnp/src/main.rs
index b4350dc82adc..fd0764990d13 100644
--- a/examples/upnp/src/main.rs
+++ b/examples/upnp/src/main.rs
@@ -21,32 +21,25 @@
#![doc = include_str!("../README.md")]
use futures::prelude::*;
-use libp2p::core::upgrade::Version;
-use libp2p::{
- identity, noise,
- swarm::{SwarmBuilder, SwarmEvent},
- tcp, upnp, yamux, Multiaddr, PeerId, Transport,
-};
+use libp2p::{noise, swarm::SwarmEvent, upnp, yamux, Multiaddr};
use std::error::Error;
+use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() -> Result<(), Box> {
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
- println!("Local peer id: {local_peer_id:?}");
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
- let transport = tcp::tokio::Transport::default()
- .upgrade(Version::V1Lazy)
- .authenticate(noise::Config::new(&local_key)?)
- .multiplex(yamux::Config::default())
- .boxed();
-
- let mut swarm = SwarmBuilder::with_tokio_executor(
- transport,
- upnp::tokio::Behaviour::default(),
- local_peer_id,
- )
- .build();
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(|_| upnp::tokio::Behaviour::default())?
+ .build();
// Tell the swarm to listen on all interfaces and a random, OS-assigned
// port.
diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml
new file mode 100644
index 000000000000..9e6fb15965d3
--- /dev/null
+++ b/hole-punching-tests/Cargo.toml
@@ -0,0 +1,18 @@
+[package]
+name = "hole-punching-tests"
+version = "0.1.0"
+edition = "2021"
+publish = false
+license = "MIT"
+
+[dependencies]
+anyhow = "1"
+env_logger = "0.10.2"
+futures = "0.3.30"
+libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] }
+tracing = "0.1.37"
+redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] }
+tokio = { version = "1.36.0", features = ["full"] }
+serde = { version = "1.0.196", features = ["derive"] }
+serde_json = "1.0.113"
+either = "1.9.0"
diff --git a/hole-punching-tests/Dockerfile b/hole-punching-tests/Dockerfile
new file mode 100644
index 000000000000..864f058799e4
--- /dev/null
+++ b/hole-punching-tests/Dockerfile
@@ -0,0 +1,19 @@
+# syntax=docker/dockerfile:1.5-labs
+FROM rust:1.73.0 as builder
+
+# Run with access to the target cache to speed up builds
+WORKDIR /workspace
+ADD . .
+
+# Build the relay as a statically-linked binary. Unfortunately, we must specify the `--target` explicitly. See https://msfjarvis.dev/posts/building-static-rust-binaries-for-linux/.
+RUN --mount=type=cache,target=./target \
+ --mount=type=cache,target=/usr/local/cargo/registry \
+ RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --package hole-punching-tests --target $(rustc -vV | grep host | awk '{print $2}')
+
+RUN --mount=type=cache,target=./target \
+ mv ./target/$(rustc -vV | grep host | awk '{print $2}')/release/hole-punching-tests /usr/local/bin/hole-punching-tests
+
+FROM alpine:3
+COPY --from=builder /usr/local/bin/hole-punching-tests /usr/bin/hole-punch-client
+RUN --mount=type=cache,target=/var/cache/apk apk add bind-tools jq curl tcpdump iproute2-tc
+ENV RUST_BACKTRACE=1
diff --git a/hole-punching-tests/src/main.rs b/hole-punching-tests/src/main.rs
new file mode 100644
index 000000000000..4f81cd654806
--- /dev/null
+++ b/hole-punching-tests/src/main.rs
@@ -0,0 +1,369 @@
+// Copyright 2023 Protocol Labs.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+use anyhow::{Context, Result};
+use either::Either;
+use futures::stream::StreamExt;
+use libp2p::core::transport::ListenerId;
+use libp2p::swarm::dial_opts::DialOpts;
+use libp2p::swarm::ConnectionId;
+use libp2p::{
+ core::multiaddr::{Multiaddr, Protocol},
+ dcutr, identify, noise, ping, relay,
+ swarm::{NetworkBehaviour, SwarmEvent},
+ tcp, yamux, Swarm,
+};
+use redis::AsyncCommands;
+use std::collections::HashMap;
+use std::net::{IpAddr, Ipv4Addr};
+use std::str::FromStr;
+use std::time::Duration;
+use std::{fmt, io};
+
+/// The redis key we push the relay's TCP listen address to.
+const RELAY_TCP_ADDRESS: &str = "RELAY_TCP_ADDRESS";
+/// The redis key we push the relay's QUIC listen address to.
+const RELAY_QUIC_ADDRESS: &str = "RELAY_QUIC_ADDRESS";
+/// The redis key we push the listen client's PeerId to.
+const LISTEN_CLIENT_PEER_ID: &str = "LISTEN_CLIENT_PEER_ID";
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ env_logger::builder()
+ .parse_filters("debug,netlink_proto=warn,rustls=warn,multistream_select=warn,libp2p_core::transport::choice=off,libp2p_swarm::connection=warn,libp2p_quic=trace")
+ .parse_default_env()
+ .init();
+
+ let mode = get_env("MODE")?;
+ let transport = get_env("TRANSPORT")?;
+
+ let mut redis = RedisClient::new("redis", 6379).await?;
+
+ let relay_addr = match transport {
+ TransportProtocol::Tcp => redis.pop::(RELAY_TCP_ADDRESS).await?,
+ TransportProtocol::Quic => redis.pop::(RELAY_QUIC_ADDRESS).await?,
+ };
+
+ let mut swarm = libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::new().port_reuse(true).nodelay(true),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_quic()
+ .with_relay_client(noise::Config::new, yamux::Config::default)?
+ .with_behaviour(|key, relay_client| {
+ Ok(Behaviour {
+ relay_client,
+ identify: identify::Behaviour::new(identify::Config::new(
+ "/hole-punch-tests/1".to_owned(),
+ key.public(),
+ )),
+ dcutr: dcutr::Behaviour::new(key.public().to_peer_id()),
+ ping: ping::Behaviour::new(
+ ping::Config::default().with_interval(Duration::from_secs(1)),
+ ),
+ })
+ })?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
+ .build();
+
+ client_listen_on_transport(&mut swarm, transport).await?;
+ let id = client_setup(&mut swarm, &mut redis, relay_addr.clone(), mode).await?;
+
+ let mut hole_punched_peer_connection = None;
+
+ loop {
+ match (
+ swarm.next().await.unwrap(),
+ hole_punched_peer_connection,
+ id,
+ ) {
+ (
+ SwarmEvent::Behaviour(BehaviourEvent::RelayClient(
+ relay::client::Event::ReservationReqAccepted { .. },
+ )),
+ _,
+ _,
+ ) => {
+ tracing::info!("Relay accepted our reservation request.");
+
+ redis
+ .push(LISTEN_CLIENT_PEER_ID, swarm.local_peer_id())
+ .await?;
+ }
+ (
+ SwarmEvent::Behaviour(BehaviourEvent::Dcutr(dcutr::Event {
+ remote_peer_id,
+ result: Ok(connection_id),
+ })),
+ _,
+ _,
+ ) => {
+ tracing::info!("Successfully hole-punched to {remote_peer_id}");
+
+ hole_punched_peer_connection = Some(connection_id);
+ }
+ (
+ SwarmEvent::Behaviour(BehaviourEvent::Ping(ping::Event {
+ connection,
+ result: Ok(rtt),
+ ..
+ })),
+ Some(hole_punched_connection),
+ _,
+ ) if mode == Mode::Dial && connection == hole_punched_connection => {
+ println!("{}", serde_json::to_string(&Report::new(rtt))?);
+
+ return Ok(());
+ }
+ (
+ SwarmEvent::Behaviour(BehaviourEvent::Dcutr(dcutr::Event {
+ remote_peer_id,
+ result: Err(error),
+ ..
+ })),
+ _,
+ _,
+ ) => {
+ tracing::info!("Failed to hole-punched to {remote_peer_id}");
+ return Err(anyhow::Error::new(error));
+ }
+ (
+ SwarmEvent::ListenerClosed {
+ listener_id,
+ reason: Err(e),
+ ..
+ },
+ _,
+ Either::Left(reservation),
+ ) if listener_id == reservation => {
+ anyhow::bail!("Reservation on relay failed: {e}");
+ }
+ (
+ SwarmEvent::OutgoingConnectionError {
+ connection_id,
+ error,
+ ..
+ },
+ _,
+ Either::Right(circuit),
+ ) if connection_id == circuit => {
+ anyhow::bail!("Circuit request relay failed: {error}");
+ }
+ _ => {}
+ }
+ }
+}
+
+#[derive(serde::Serialize)]
+struct Report {
+ rtt_to_holepunched_peer_millis: u128,
+}
+
+impl Report {
+ fn new(rtt: Duration) -> Self {
+ Self {
+ rtt_to_holepunched_peer_millis: rtt.as_millis(),
+ }
+ }
+}
+
+fn get_env(key: &'static str) -> Result
+where
+ T: FromStr,
+ T::Err: std::error::Error + Send + Sync + 'static,
+{
+ let val = std::env::var(key)
+ .with_context(|| format!("Missing env var `{key}`"))?
+ .parse()
+ .with_context(|| format!("Failed to parse `{key}`)"))?;
+
+ Ok(val)
+}
+
+async fn client_listen_on_transport(
+ swarm: &mut Swarm,
+ transport: TransportProtocol,
+) -> Result<()> {
+ let listen_addr = match transport {
+ TransportProtocol::Tcp => tcp_addr(Ipv4Addr::UNSPECIFIED.into()),
+ TransportProtocol::Quic => quic_addr(Ipv4Addr::UNSPECIFIED.into()),
+ };
+ let expected_listener_id = swarm
+ .listen_on(listen_addr)
+ .context("Failed to listen on address")?;
+
+ let mut listen_addresses = 0;
+
+ // We should have at least two listen addresses, one for localhost and the actual interface.
+ while listen_addresses < 2 {
+ if let SwarmEvent::NewListenAddr {
+ listener_id,
+ address,
+ } = swarm.next().await.unwrap()
+ {
+ if listener_id == expected_listener_id {
+ listen_addresses += 1;
+ }
+
+ tracing::info!("Listening on {address}");
+ }
+ }
+ Ok(())
+}
+
+async fn client_setup(
+ swarm: &mut Swarm,
+ redis: &mut RedisClient,
+ relay_addr: Multiaddr,
+ mode: Mode,
+) -> Result> {
+ let either = match mode {
+ Mode::Listen => {
+ let id = swarm.listen_on(relay_addr.with(Protocol::P2pCircuit))?;
+
+ Either::Left(id)
+ }
+ Mode::Dial => {
+ let remote_peer_id = redis.pop(LISTEN_CLIENT_PEER_ID).await?;
+
+ let opts = DialOpts::from(
+ relay_addr
+ .with(Protocol::P2pCircuit)
+ .with(Protocol::P2p(remote_peer_id)),
+ );
+ let id = opts.connection_id();
+
+ swarm.dial(opts)?;
+
+ Either::Right(id)
+ }
+ };
+
+ Ok(either)
+}
+
+fn tcp_addr(addr: IpAddr) -> Multiaddr {
+ Multiaddr::empty().with(addr.into()).with(Protocol::Tcp(0))
+}
+
+fn quic_addr(addr: IpAddr) -> Multiaddr {
+ Multiaddr::empty()
+ .with(addr.into())
+ .with(Protocol::Udp(0))
+ .with(Protocol::QuicV1)
+}
+
+struct RedisClient {
+ inner: redis::aio::Connection,
+}
+
+impl RedisClient {
+ async fn new(host: &str, port: u16) -> Result {
+ let client = redis::Client::open(format!("redis://{host}:{port}/"))
+ .context("Bad redis server URL")?;
+ let connection = client
+ .get_async_connection()
+ .await
+ .context("Failed to connect to redis server")?;
+
+ Ok(Self { inner: connection })
+ }
+
+ async fn push(&mut self, key: &str, value: impl ToString) -> Result<()> {
+ let value = value.to_string();
+
+ tracing::debug!("Pushing {key}={value} to redis");
+
+ self.inner.rpush(key, value).await?;
+
+ Ok(())
+ }
+
+ async fn pop(&mut self, key: &str) -> Result
+ where
+ V: FromStr + fmt::Display,
+ V::Err: std::error::Error + Send + Sync + 'static,
+ {
+ tracing::debug!("Fetching {key} from redis");
+
+ let value = self
+ .inner
+ .blpop::<_, HashMap>(key, 0)
+ .await?
+ .remove(key)
+ .with_context(|| format!("Failed to get value for {key} from redis"))?
+ .parse()?;
+
+ tracing::debug!("{key}={value}");
+
+ Ok(value)
+ }
+}
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+enum TransportProtocol {
+ Tcp,
+ Quic,
+}
+
+impl FromStr for TransportProtocol {
+ type Err = io::Error;
+ fn from_str(mode: &str) -> Result {
+ match mode {
+ "tcp" => Ok(TransportProtocol::Tcp),
+ "quic" => Ok(TransportProtocol::Quic),
+ _ => Err(io::Error::new(
+ io::ErrorKind::Other,
+ "Expected either 'tcp' or 'quic'",
+ )),
+ }
+ }
+}
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+enum Mode {
+ Dial,
+ Listen,
+}
+
+impl FromStr for Mode {
+ type Err = io::Error;
+ fn from_str(mode: &str) -> Result {
+ match mode {
+ "dial" => Ok(Mode::Dial),
+ "listen" => Ok(Mode::Listen),
+ _ => Err(io::Error::new(
+ io::ErrorKind::Other,
+ "Expected either 'dial' or 'listen'",
+ )),
+ }
+ }
+}
+
+#[derive(NetworkBehaviour)]
+struct Behaviour {
+ relay_client: relay::client::Behaviour,
+ identify: identify::Behaviour,
+ dcutr: dcutr::Behaviour,
+ ping: ping::Behaviour,
+}
diff --git a/hole-punching-tests/version.json b/hole-punching-tests/version.json
new file mode 100644
index 000000000000..f5db52d1c2dd
--- /dev/null
+++ b/hole-punching-tests/version.json
@@ -0,0 +1,8 @@
+{
+ "id": "rust-libp2p-head",
+ "containerImageID": "rust-libp2p-head",
+ "transports": [
+ "tcp",
+ "quic"
+ ]
+}
diff --git a/identity/CHANGELOG.md b/identity/CHANGELOG.md
index 27873e88e016..004943ce1950 100644
--- a/identity/CHANGELOG.md
+++ b/identity/CHANGELOG.md
@@ -1,3 +1,19 @@
+## 0.2.8
+
+- Bump `ring` to `0.17.5.
+ See [PR 4779](https://github.com/libp2p/rust-libp2p/pull/4779).
+
+## 0.2.7
+
+- Add `rand` feature to gate methods requiring a random number generator, enabling use in restricted environments (e.g. smartcontracts).
+ This feature is not enabled by default.
+ See [PR 4349](https://github.com/libp2p/rust-libp2p/pull/4349).
+
+## 0.2.6
+
+- Make `PeerId::to_bytes` and `PeerId::to_base58` take `self` by value to follow Rust convention of `Copy` types.
+ See [PR 4653](https://github.com/libp2p/rust-libp2p/pull/4653).
+
## 0.2.5
- Fix usage of HKDF within `Keypair::derive_secret`.
diff --git a/identity/Cargo.toml b/identity/Cargo.toml
index 69f8bf55f02a..920b9a990e4f 100644
--- a/identity/Cargo.toml
+++ b/identity/Cargo.toml
@@ -1,9 +1,9 @@
[package]
name = "libp2p-identity"
-version = "0.2.5"
+version = "0.2.8"
edition = "2021"
description = "Data structures and algorithms for identifying peers in libp2p."
-rust-version = { workspace = true }
+rust-version = "1.73.0" # MUST NOT inherit from workspace because we don't want to publish breaking changes to `libp2p-identity`.
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking", "cryptography"]
@@ -14,10 +14,10 @@ categories = ["cryptography"]
[dependencies]
asn1_der = { version = "0.7.6", optional = true }
bs58 = { version = "0.5.0", optional = true }
-ed25519-dalek = { version = "2.0", optional = true, features = ["rand_core"] }
-hkdf = { version = "0.12.3", optional = true }
+ed25519-dalek = { version = "2.1", optional = true }
+hkdf = { version = "0.12.4", optional = true }
libsecp256k1 = { version = "0.7.0", optional = true }
-log = "0.4"
+tracing = "0.1.37"
multihash = { version = "0.19.1", optional = true }
p256 = { version = "0.13", default-features = false, features = [ "ecdsa", "std", "pem"], optional = true }
quick-protobuf = "0.8.1"
@@ -27,21 +27,22 @@ serde = { version = "1", optional = true, features = ["derive"] }
sha2 = { version = "0.10.8", optional = true }
thiserror = { version = "1.0", optional = true }
void = { version = "1.0", optional = true }
-zeroize = { version = "1.6", optional = true }
+zeroize = { version = "1.7", optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-ring = { version = "0.16.9", features = [ "alloc", "std"], default-features = false, optional = true }
+ring = { version = "0.17.5", features = [ "alloc", "std"], default-features = false, optional = true }
[features]
-secp256k1 = ["dep:libsecp256k1", "dep:asn1_der", "dep:rand", "dep:sha2", "dep:hkdf", "dep:zeroize"]
-ecdsa = ["dep:p256", "dep:rand", "dep:void", "dep:zeroize", "dep:sec1", "dep:sha2", "dep:hkdf"]
+secp256k1 = ["dep:libsecp256k1", "dep:asn1_der", "dep:sha2", "dep:hkdf", "dep:zeroize"]
+ecdsa = ["dep:p256", "dep:void", "dep:zeroize", "dep:sec1", "dep:sha2", "dep:hkdf"]
rsa = ["dep:ring", "dep:asn1_der", "dep:rand", "dep:zeroize"]
-ed25519 = ["dep:ed25519-dalek", "dep:rand", "dep:zeroize", "dep:sha2", "dep:hkdf"]
-peerid = ["dep:multihash", "dep:bs58", "dep:rand", "dep:thiserror", "dep:sha2", "dep:hkdf" ]
+ed25519 = ["dep:ed25519-dalek", "dep:zeroize", "dep:sha2", "dep:hkdf"]
+peerid = ["dep:multihash", "dep:bs58", "dep:thiserror", "dep:sha2", "dep:hkdf"]
+rand = ["dep:rand", "ed25519-dalek?/rand_core"]
[dev-dependencies]
quickcheck = { workspace = true }
-base64 = "0.21.4"
+base64 = "0.21.7"
serde_json = "1.0"
rmp-serde = "1.1"
criterion = "0.5"
diff --git a/identity/src/ecdsa.rs b/identity/src/ecdsa.rs
index 21970f2ffdca..2f1a286d46d3 100644
--- a/identity/src/ecdsa.rs
+++ b/identity/src/ecdsa.rs
@@ -44,6 +44,7 @@ pub struct Keypair {
impl Keypair {
/// Generate a new random ECDSA keypair.
+ #[cfg(feature = "rand")]
pub fn generate() -> Keypair {
Keypair::from(SecretKey::generate())
}
@@ -150,9 +151,8 @@ pub struct PublicKey(VerifyingKey);
impl PublicKey {
/// Verify an ECDSA signature on a message using the public key.
pub fn verify(&self, msg: &[u8], sig: &[u8]) -> bool {
- let sig = match Signature::from_der(sig) {
- Ok(sig) => sig,
- Err(_) => return false,
+ let Ok(sig) = Signature::from_der(sig) else {
+ return false;
};
self.0.verify(msg, &sig).is_ok()
}
@@ -265,6 +265,7 @@ mod tests {
use super::*;
#[test]
+ #[cfg(feature = "rand")]
fn sign_verify() {
let pair = Keypair::generate();
let pk = pair.public();
diff --git a/identity/src/ed25519.rs b/identity/src/ed25519.rs
index 8b6b9e0d1e0b..529a4dddea1c 100644
--- a/identity/src/ed25519.rs
+++ b/identity/src/ed25519.rs
@@ -34,6 +34,7 @@ pub struct Keypair(ed25519::SigningKey);
impl Keypair {
/// Generate a new random Ed25519 keypair.
+ #[cfg(feature = "rand")]
pub fn generate() -> Keypair {
Keypair::from(SecretKey::generate())
}
@@ -181,6 +182,7 @@ impl fmt::Debug for SecretKey {
impl SecretKey {
/// Generate a new Ed25519 secret key.
+ #[cfg(feature = "rand")]
pub fn generate() -> SecretKey {
let signing = ed25519::SigningKey::generate(&mut rand::rngs::OsRng);
SecretKey(signing.to_bytes())
@@ -213,6 +215,7 @@ mod tests {
}
#[test]
+ #[cfg(feature = "rand")]
fn ed25519_keypair_encode_decode() {
fn prop() -> bool {
let kp1 = Keypair::generate();
@@ -224,6 +227,7 @@ mod tests {
}
#[test]
+ #[cfg(feature = "rand")]
fn ed25519_keypair_from_secret() {
fn prop() -> bool {
let kp1 = Keypair::generate();
@@ -235,6 +239,7 @@ mod tests {
}
#[test]
+ #[cfg(feature = "rand")]
fn ed25519_signature() {
let kp = Keypair::generate();
let pk = kp.public();
diff --git a/identity/src/keypair.rs b/identity/src/keypair.rs
index 198296fa4fad..bdfb68c0091c 100644
--- a/identity/src/keypair.rs
+++ b/identity/src/keypair.rs
@@ -102,7 +102,7 @@ enum KeyPairInner {
impl Keypair {
/// Generate a new Ed25519 keypair.
- #[cfg(feature = "ed25519")]
+ #[cfg(all(feature = "ed25519", feature = "rand"))]
pub fn generate_ed25519() -> Keypair {
Keypair {
keypair: KeyPairInner::Ed25519(ed25519::Keypair::generate()),
@@ -110,7 +110,7 @@ impl Keypair {
}
/// Generate a new Secp256k1 keypair.
- #[cfg(feature = "secp256k1")]
+ #[cfg(all(feature = "secp256k1", feature = "rand"))]
pub fn generate_secp256k1() -> Keypair {
Keypair {
keypair: KeyPairInner::Secp256k1(secp256k1::Keypair::generate()),
@@ -118,7 +118,7 @@ impl Keypair {
}
/// Generate a new ECDSA keypair.
- #[cfg(feature = "ecdsa")]
+ #[cfg(all(feature = "ecdsa", feature = "rand"))]
pub fn generate_ecdsa() -> Keypair {
Keypair {
keypair: KeyPairInner::Ecdsa(ecdsa::Keypair::generate()),
@@ -352,7 +352,6 @@ impl Keypair {
/// ```
/// # fn main() {
/// # use libp2p_identity as identity;
- ///
/// let key = identity::Keypair::generate_ed25519();
///
/// let new_key = key.derive_secret(b"my encryption key").expect("can derive secret for ed25519");
@@ -673,7 +672,7 @@ impl TryFrom for PublicKey {
)?),
#[cfg(not(feature = "ed25519"))]
proto::KeyType::Ed25519 => {
- log::debug!("support for ed25519 was disabled at compile-time");
+ tracing::debug!("support for ed25519 was disabled at compile-time");
Err(DecodingError::missing_feature("ed25519"))
}
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
@@ -686,7 +685,7 @@ impl TryFrom for PublicKey {
}
#[cfg(any(not(feature = "rsa"), target_arch = "wasm32"))]
proto::KeyType::RSA => {
- log::debug!("support for RSA was disabled at compile-time");
+ tracing::debug!("support for RSA was disabled at compile-time");
Err(DecodingError::missing_feature("rsa"))
}
#[cfg(feature = "secp256k1")]
@@ -696,7 +695,7 @@ impl TryFrom for PublicKey {
})?),
#[cfg(not(feature = "secp256k1"))]
proto::KeyType::Secp256k1 => {
- log::debug!("support for secp256k1 was disabled at compile-time");
+ tracing::debug!("support for secp256k1 was disabled at compile-time");
Err(DecodingError::missing_feature("secp256k1"))
}
#[cfg(feature = "ecdsa")]
@@ -707,7 +706,7 @@ impl TryFrom for PublicKey {
)?),
#[cfg(not(feature = "ecdsa"))]
proto::KeyType::ECDSA => {
- log::debug!("support for ECDSA was disabled at compile-time");
+ tracing::debug!("support for ECDSA was disabled at compile-time");
Err(DecodingError::missing_feature("ecdsa"))
}
}
@@ -926,7 +925,7 @@ mod tests {
}
#[test]
- #[cfg(feature = "ed25519")]
+ #[cfg(all(feature = "ed25519", feature = "rand"))]
fn test_publickey_from_ed25519_public_key() {
let pubkey = Keypair::generate_ed25519().public();
let ed25519_pubkey = pubkey
@@ -941,7 +940,7 @@ mod tests {
}
#[test]
- #[cfg(feature = "secp256k1")]
+ #[cfg(all(feature = "secp256k1", feature = "rand"))]
fn test_publickey_from_secp256k1_public_key() {
let pubkey = Keypair::generate_secp256k1().public();
let secp256k1_pubkey = pubkey
@@ -955,7 +954,7 @@ mod tests {
}
#[test]
- #[cfg(feature = "ecdsa")]
+ #[cfg(all(feature = "ecdsa", feature = "rand"))]
fn test_publickey_from_ecdsa_public_key() {
let pubkey = Keypair::generate_ecdsa().public();
let ecdsa_pubkey = pubkey.clone().try_into_ecdsa().expect("A ecdsa keypair");
diff --git a/identity/src/lib.rs b/identity/src/lib.rs
index 9a6c42374f66..c78e68d1652a 100644
--- a/identity/src/lib.rs
+++ b/identity/src/lib.rs
@@ -114,8 +114,9 @@ pub use keypair::{Keypair, PublicKey};
#[cfg(feature = "peerid")]
pub use peer_id::{ParseError, PeerId};
-#[derive(Debug, PartialEq, Eq)]
/// The type of key a `KeyPair` is holding.
+#[derive(Debug, PartialEq, Eq)]
+#[allow(clippy::upper_case_acronyms)]
pub enum KeyType {
Ed25519,
RSA,
diff --git a/identity/src/peer_id.rs b/identity/src/peer_id.rs
index 60ded4ad37c1..1d85fe66ffad 100644
--- a/identity/src/peer_id.rs
+++ b/identity/src/peer_id.rs
@@ -18,6 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
+#[cfg(feature = "rand")]
use rand::Rng;
use sha2::Digest as _;
use std::{convert::TryFrom, fmt, str::FromStr};
@@ -101,6 +102,7 @@ impl PeerId {
/// Generates a random peer ID from a cryptographically secure PRNG.
///
/// This is useful for randomly walking on a DHT, or for testing purposes.
+ #[cfg(feature = "rand")]
pub fn random() -> PeerId {
let peer_id = rand::thread_rng().gen::<[u8; 32]>();
PeerId {
@@ -109,12 +111,12 @@ impl PeerId {
}
/// Returns a raw bytes representation of this `PeerId`.
- pub fn to_bytes(&self) -> Vec {
+ pub fn to_bytes(self) -> Vec {
self.multihash.to_bytes()
}
/// Returns a base-58 encoded string of this `PeerId`.
- pub fn to_base58(&self) -> String {
+ pub fn to_base58(self) -> String {
bs58::encode(self.to_bytes()).into_string()
}
}
@@ -247,7 +249,7 @@ mod tests {
use super::*;
#[test]
- #[cfg(feature = "ed25519")]
+ #[cfg(all(feature = "ed25519", feature = "rand"))]
fn peer_id_into_bytes_then_from_bytes() {
let peer_id = crate::Keypair::generate_ed25519().public().to_peer_id();
let second = PeerId::from_bytes(&peer_id.to_bytes()).unwrap();
@@ -255,7 +257,7 @@ mod tests {
}
#[test]
- #[cfg(feature = "ed25519")]
+ #[cfg(all(feature = "ed25519", feature = "rand"))]
fn peer_id_to_base58_then_back() {
let peer_id = crate::Keypair::generate_ed25519().public().to_peer_id();
let second: PeerId = peer_id.to_base58().parse().unwrap();
@@ -263,6 +265,7 @@ mod tests {
}
#[test]
+ #[cfg(feature = "rand")]
fn random_peer_id_is_valid() {
for _ in 0..5000 {
let peer_id = PeerId::random();
diff --git a/identity/src/rsa.rs b/identity/src/rsa.rs
index f14b19750231..cbfe3c1b919b 100644
--- a/identity/src/rsa.rs
+++ b/identity/src/rsa.rs
@@ -71,7 +71,7 @@ impl Keypair {
/// Sign a message with this keypair.
pub fn sign(&self, data: &[u8]) -> Result, SigningError> {
- let mut signature = vec![0; self.0.public_modulus_len()];
+ let mut signature = vec![0; self.0.public().modulus_len()];
let rng = SystemRandom::new();
match self.0.sign(&RSA_PKCS1_SHA256, &rng, data, &mut signature) {
Ok(()) => Ok(signature),
diff --git a/identity/src/secp256k1.rs b/identity/src/secp256k1.rs
index 94b9b9177876..5e1fda2933b7 100644
--- a/identity/src/secp256k1.rs
+++ b/identity/src/secp256k1.rs
@@ -38,6 +38,7 @@ pub struct Keypair {
impl Keypair {
/// Generate a new sec256k1 `Keypair`.
+ #[cfg(feature = "rand")]
pub fn generate() -> Keypair {
Keypair::from(SecretKey::generate())
}
@@ -88,6 +89,7 @@ impl fmt::Debug for SecretKey {
impl SecretKey {
/// Generate a new random Secp256k1 secret key.
+ #[cfg(feature = "rand")]
pub fn generate() -> SecretKey {
SecretKey(libsecp256k1::SecretKey::random(&mut rand::thread_rng()))
}
@@ -226,6 +228,7 @@ mod tests {
use super::*;
#[test]
+ #[cfg(feature = "rand")]
fn secp256k1_secret_from_bytes() {
let sk1 = SecretKey::generate();
let mut sk_bytes = [0; 32];
diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml
index ac046da69cdf..81c17e193036 100644
--- a/interop-tests/Cargo.toml
+++ b/interop-tests/Cargo.toml
@@ -5,37 +5,43 @@ version = "0.1.0"
publish = false
license = "MIT"
+[package.metadata.release]
+release = false
+
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
anyhow = "1"
either = "1.9.0"
-env_logger = "0.10.0"
-futures = "0.3.28"
-log = "0.4"
-serde = { version = "1", features = ["derive"] }
+futures = "0.3.30"
rand = "0.8.5"
+serde = { version = "1", features = ["derive"] }
+tracing = "0.1.37"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-axum = "0.6"
+axum = "0.7"
libp2p = { path = "../libp2p", features = [ "ping", "noise", "tls", "rsa", "macros", "websocket", "tokio", "yamux", "tcp", "dns", "identify", "quic"] }
-libp2p-webrtc = { workspace = true, features = ["tokio"] }
libp2p-mplex = { path = "../muxers/mplex" }
+libp2p-noise = { workspace = true }
+libp2p-tls = { workspace = true }
+libp2p-webrtc = { workspace = true, features = ["tokio"] }
mime_guess = "2.0"
redis = { version = "0.23.3", default-features = false, features = [
"tokio-comp",
] }
-rust-embed = "8.0"
+rust-embed = "8.2"
serde_json = "1"
thirtyfour = "=0.32.0-rc.8" # https://github.com/stevepryde/thirtyfour/issues/169
-tokio = { version = "1.32.0", features = ["full"] }
-tower-http = { version = "0.4", features = ["cors", "fs", "trace"] }
-tracing = "0.1"
+tokio = { version = "1.36.0", features = ["full"] }
+tower-http = { version = "0.5", features = ["cors", "fs", "trace"] }
+tracing = "0.1.37"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
-libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "wasm-bindgen", "identify"] }
+libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "wasm-bindgen", "identify", "websocket-websys", "yamux", "noise"] }
+libp2p-mplex = { path = "../muxers/mplex" }
libp2p-webrtc-websys = { workspace = true }
wasm-bindgen = { version = "0.2" }
wasm-bindgen-futures = { version = "0.4" }
diff --git a/interop-tests/Dockerfile.chromium b/interop-tests/Dockerfile.chromium
index ab720c4d3175..5ec46e313aa8 100644
--- a/interop-tests/Dockerfile.chromium
+++ b/interop-tests/Dockerfile.chromium
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.5-labs
-FROM rust:1.67.0 as chef
+FROM rust:1.73.0 as chef
RUN rustup target add wasm32-unknown-unknown
RUN wget -q -O- https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | tar -zx -C /usr/local/bin --strip-components 1 --wildcards "wasm-pack-*/wasm-pack"
RUN wget -q -O- https://github.com/WebAssembly/binaryen/releases/download/version_115/binaryen-version_115-x86_64-linux.tar.gz | tar -zx -C /usr/local/bin --strip-components 2 --wildcards "binaryen-version_*/bin/wasm-opt"
@@ -14,13 +14,13 @@ FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --package interop-tests --target wasm32-unknown-unknown --recipe-path recipe.json
-RUN cargo chef cook --release --package interop-tests --bin wasm_ping --recipe-path recipe.json
+RUN RUSTFLAGS='-C target-feature=+crt-static' cargo chef cook --release --package interop-tests --target x86_64-unknown-linux-gnu --bin wasm_ping --recipe-path recipe.json
# Build application
COPY . .
RUN wasm-pack build --target web interop-tests
-RUN cargo build --release --package interop-tests --bin wasm_ping
+RUN RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --package interop-tests --target x86_64-unknown-linux-gnu --bin wasm_ping
FROM selenium/standalone-chrome:115.0
-COPY --from=builder /app/target/release/wasm_ping /usr/local/bin/testplan
+COPY --from=builder /app/target/x86_64-unknown-linux-gnu/release/wasm_ping /usr/local/bin/testplan
ENV RUST_BACKTRACE=1
ENTRYPOINT ["testplan"]
diff --git a/interop-tests/Dockerfile.native b/interop-tests/Dockerfile.native
index df5eb9a1240c..91e6cf8893e4 100644
--- a/interop-tests/Dockerfile.native
+++ b/interop-tests/Dockerfile.native
@@ -1,6 +1,5 @@
# syntax=docker/dockerfile:1.5-labs
-FROM rust:1.67.0 as chef
-RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin
+FROM lukemathwalker/cargo-chef:0.1.62-rust-1.73.0 as chef
WORKDIR /app
FROM chef AS planner
@@ -10,12 +9,13 @@ RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
-RUN cargo chef cook --release --package interop-tests --bin native_ping --recipe-path recipe.json
+RUN RUSTFLAGS='-C target-feature=+crt-static' cargo chef cook --release --package interop-tests --target $(rustc -vV | grep host | awk '{print $2}') --bin native_ping --recipe-path recipe.json
# Build application
COPY . .
-RUN cargo build --release --package interop-tests --bin native_ping
+RUN RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --package interop-tests --target $(rustc -vV | grep host | awk '{print $2}') --bin native_ping
+RUN cp /app/target/$(rustc -vV | grep host | awk '{print $2}')/release/native_ping /usr/local/bin/testplan
-FROM gcr.io/distroless/cc
-COPY --from=builder /app/target/release/native_ping /usr/local/bin/testplan
+FROM scratch
+COPY --from=builder /usr/local/bin/testplan /usr/local/bin/testplan
ENV RUST_BACKTRACE=1
ENTRYPOINT ["testplan"]
diff --git a/interop-tests/README.md b/interop-tests/README.md
index bab98df7987c..c2805ddf7072 100644
--- a/interop-tests/README.md
+++ b/interop-tests/README.md
@@ -8,9 +8,11 @@ You can run this test locally by having a local Redis instance and by having
another peer that this test can dial or listen for. For example to test that we
can dial/listen for ourselves we can do the following:
-1. Start redis (needed by the tests): `docker run --rm -p 6379:6379 redis:7-alpine`.
-2. In one terminal run the dialer: `redis_addr=localhost:6379 ip="0.0.0.0" transport=quic-v1 security=quic muxer=quic is_dialer="true" cargo run --bin ping`
-3. In another terminal, run the listener: `redis_addr=localhost:6379 ip="0.0.0.0" transport=quic-v1 security=quic muxer=quic is_dialer="false" cargo run --bin native_ping`
+1. Start redis (needed by the tests): `docker run --rm -p 6379:6379 redis:7-alpine`
+2. In one terminal run the dialer: `RUST_LOG=debug redis_addr=localhost:6379 ip="0.0.0.0" transport=tcp security=noise muxer=yamux is_dialer="true" cargo run --bin native_ping`
+3. In another terminal, run the listener: `RUST_LOG=debug redis_addr=localhost:6379 ip="0.0.0.0" transport=tcp security=noise muxer=yamux is_dialer="false" cargo run --bin native_ping`
+
+If testing `transport=quic-v1`, then remove `security` and `muxer` variables from command line, because QUIC protocol comes with its own encryption and multiplexing.
To test the interop with other versions do something similar, except replace one
of these nodes with the other version's interop test.
@@ -30,9 +32,9 @@ Firefox is not yet supported as it doesn't support all required features yet
To run the webrtc-direct test, you'll need the `chromedriver` in your `$PATH`, compatible with your Chrome browser.
1. Start redis: `docker run --rm -p 6379:6379 redis:7-alpine`.
-1. Build the wasm package: `wasm-pack build --target web`
-1. With the webrtc-direct listener `RUST_LOG=debug,webrtc=off,webrtc_sctp=off redis_addr="127.0.0.1:6379" ip="0.0.0.0" transport=webrtc-direct is_dialer="false" cargo run --bin native_ping`
-1. Run the webrtc-direct dialer: `RUST_LOG=debug,hyper=off redis_addr="127.0.0.1:6379" ip="0.0.0.0" transport=webrtc-direct is_dialer=true cargo run --bin wasm_ping`
+2. Build the wasm package: `wasm-pack build --target web`
+3. With the webrtc-direct listener `RUST_LOG=debug,webrtc=off,webrtc_sctp=off redis_addr="127.0.0.1:6379" ip="0.0.0.0" transport=webrtc-direct is_dialer="false" cargo run --bin native_ping`
+4. Run the webrtc-direct dialer: `RUST_LOG=debug,hyper=off redis_addr="127.0.0.1:6379" ip="0.0.0.0" transport=webrtc-direct is_dialer=true cargo run --bin wasm_ping`
# Running all interop tests locally with Compose
@@ -41,8 +43,8 @@ To run this test against all released libp2p versions you'll need to have the
the following (from the root directory of this repository):
1. Build the image: `docker build -t rust-libp2p-head . -f interop-tests/Dockerfile`.
-1. Build the images for all released versions in `libp2p/test-plans`: `(cd /libp2p/test-plans/multidim-interop/ && make)`.
-1. Run the test:
+2. Build the images for all released versions in `libp2p/test-plans`: `(cd /libp2p/test-plans/multidim-interop/ && make)`.
+3. Run the test:
```
RUST_LIBP2P="$PWD"; (cd /libp2p/test-plans/multidim-interop/ && npm run test -- --extra-version=$RUST_LIBP2P/interop-tests/ping-version.json --name-filter="rust-libp2p-head")
```
diff --git a/interop-tests/chromium-ping-version.json b/interop-tests/chromium-ping-version.json
index ae5c6e10eddd..6ee0a0756d4a 100644
--- a/interop-tests/chromium-ping-version.json
+++ b/interop-tests/chromium-ping-version.json
@@ -3,8 +3,9 @@
"containerImageID": "chromium-rust-libp2p-head",
"transports": [
{ "name": "webtransport", "onlyDial": true },
- { "name": "webrtc-direct", "onlyDial": true }
+ { "name": "webrtc-direct", "onlyDial": true },
+ { "name": "ws", "onlyDial": true }
],
- "secureChannels": [],
- "muxers": []
+ "secureChannels": ["noise"],
+ "muxers": ["mplex", "yamux"]
}
diff --git a/interop-tests/src/arch.rs b/interop-tests/src/arch.rs
index b30c3ad1e31f..52000f90a86f 100644
--- a/interop-tests/src/arch.rs
+++ b/interop-tests/src/arch.rs
@@ -1,133 +1,166 @@
-use libp2p::core::muxing::StreamMuxerBox;
-use libp2p::core::transport::Boxed;
-use libp2p::PeerId;
-
// Native re-exports
#[cfg(not(target_arch = "wasm32"))]
-pub(crate) use native::{build_transport, init_logger, sleep, swarm_builder, Instant, RedisClient};
+pub(crate) use native::{build_swarm, init_logger, sleep, Instant, RedisClient};
// Wasm re-exports
#[cfg(target_arch = "wasm32")]
-pub(crate) use wasm::{build_transport, init_logger, sleep, swarm_builder, Instant, RedisClient};
-
-type BoxedTransport = Boxed<(PeerId, StreamMuxerBox)>;
+pub(crate) use wasm::{build_swarm, init_logger, sleep, Instant, RedisClient};
#[cfg(not(target_arch = "wasm32"))]
pub(crate) mod native {
use std::time::Duration;
use anyhow::{bail, Context, Result};
- use either::Either;
- use env_logger::{Env, Target};
use futures::future::BoxFuture;
use futures::FutureExt;
- use libp2p::core::muxing::StreamMuxerBox;
- use libp2p::core::upgrade::Version;
use libp2p::identity::Keypair;
- use libp2p::swarm::{NetworkBehaviour, SwarmBuilder};
- use libp2p::websocket::WsConfig;
- use libp2p::{noise, quic, tcp, tls, yamux, PeerId, Transport as _};
+ use libp2p::swarm::{NetworkBehaviour, Swarm};
+ use libp2p::{noise, tcp, tls, yamux};
use libp2p_mplex as mplex;
use libp2p_webrtc as webrtc;
use redis::AsyncCommands;
+ use tracing_subscriber::EnvFilter;
- use crate::{from_env, Muxer, SecProtocol, Transport};
-
- use super::BoxedTransport;
+ use crate::{Muxer, SecProtocol, Transport};
pub(crate) type Instant = std::time::Instant;
pub(crate) fn init_logger() {
- env_logger::Builder::from_env(Env::default().default_filter_or("info"))
- .target(Target::Stdout)
- .init();
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(EnvFilter::from_default_env())
+ .try_init();
}
pub(crate) fn sleep(duration: Duration) -> BoxFuture<'static, ()> {
tokio::time::sleep(duration).boxed()
}
- fn muxer_protocol_from_env() -> Result> {
- Ok(match from_env("muxer")? {
- Muxer::Yamux => Either::Left(yamux::Config::default()),
- Muxer::Mplex => Either::Right(mplex::MplexConfig::new()),
- })
- }
-
- pub(crate) fn build_transport(
- local_key: Keypair,
+ pub(crate) async fn build_swarm(
ip: &str,
transport: Transport,
- ) -> Result<(BoxedTransport, String)> {
- let (transport, addr) = match (transport, from_env::("security")) {
- (Transport::QuicV1, _) => (
- quic::tokio::Transport::new(quic::Config::new(&local_key))
- .map(|(p, c), _| (p, StreamMuxerBox::new(c)))
- .boxed(),
+ sec_protocol: Option,
+ muxer: Option,
+ behaviour_constructor: impl FnOnce(&Keypair) -> B,
+ ) -> Result<(Swarm, String)> {
+ let (swarm, addr) = match (transport, sec_protocol, muxer) {
+ (Transport::QuicV1, None, None) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_quic()
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/udp/0/quic-v1"),
),
- (Transport::Tcp, Ok(SecProtocol::Tls)) => (
- tcp::tokio::Transport::new(tcp::Config::new())
- .upgrade(Version::V1Lazy)
- .authenticate(tls::Config::new(&local_key).context("failed to initialise tls")?)
- .multiplex(muxer_protocol_from_env()?)
- .timeout(Duration::from_secs(5))
- .boxed(),
+ (Transport::Tcp, Some(SecProtocol::Tls), Some(Muxer::Mplex)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ tls::Config::new,
+ mplex::MplexConfig::default,
+ )?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/tcp/0"),
),
- (Transport::Tcp, Ok(SecProtocol::Noise)) => (
- tcp::tokio::Transport::new(tcp::Config::new())
- .upgrade(Version::V1Lazy)
- .authenticate(
- noise::Config::new(&local_key).context("failed to intialise noise")?,
- )
- .multiplex(muxer_protocol_from_env()?)
- .timeout(Duration::from_secs(5))
- .boxed(),
+ (Transport::Tcp, Some(SecProtocol::Tls), Some(Muxer::Yamux)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ tls::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/tcp/0"),
),
- (Transport::Ws, Ok(SecProtocol::Tls)) => (
- WsConfig::new(tcp::tokio::Transport::new(tcp::Config::new()))
- .upgrade(Version::V1Lazy)
- .authenticate(tls::Config::new(&local_key).context("failed to initialise tls")?)
- .multiplex(muxer_protocol_from_env()?)
- .timeout(Duration::from_secs(5))
- .boxed(),
+ (Transport::Tcp, Some(SecProtocol::Noise), Some(Muxer::Mplex)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ mplex::MplexConfig::default,
+ )?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
+ format!("/ip4/{ip}/tcp/0"),
+ ),
+ (Transport::Tcp, Some(SecProtocol::Noise), Some(Muxer::Yamux)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ tcp::Config::default(),
+ noise::Config::new,
+ yamux::Config::default,
+ )?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
+ format!("/ip4/{ip}/tcp/0"),
+ ),
+ (Transport::Ws, Some(SecProtocol::Tls), Some(Muxer::Mplex)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_websocket(tls::Config::new, mplex::MplexConfig::default)
+ .await?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
+ format!("/ip4/{ip}/tcp/0/ws"),
+ ),
+ (Transport::Ws, Some(SecProtocol::Tls), Some(Muxer::Yamux)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_websocket(tls::Config::new, yamux::Config::default)
+ .await?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
+ format!("/ip4/{ip}/tcp/0/ws"),
+ ),
+ (Transport::Ws, Some(SecProtocol::Noise), Some(Muxer::Mplex)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_websocket(noise::Config::new, mplex::MplexConfig::default)
+ .await?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/tcp/0/ws"),
),
- (Transport::Ws, Ok(SecProtocol::Noise)) => (
- WsConfig::new(tcp::tokio::Transport::new(tcp::Config::new()))
- .upgrade(Version::V1Lazy)
- .authenticate(
- noise::Config::new(&local_key).context("failed to intialise noise")?,
- )
- .multiplex(muxer_protocol_from_env()?)
- .timeout(Duration::from_secs(5))
- .boxed(),
+ (Transport::Ws, Some(SecProtocol::Noise), Some(Muxer::Yamux)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_websocket(noise::Config::new, yamux::Config::default)
+ .await?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/tcp/0/ws"),
),
- (Transport::WebRtcDirect, _) => (
- webrtc::tokio::Transport::new(
- local_key,
- webrtc::tokio::Certificate::generate(&mut rand::thread_rng())?,
- )
- .map(|(peer_id, conn), _| (peer_id, StreamMuxerBox::new(conn)))
- .boxed(),
+ (Transport::WebRtcDirect, None, None) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_other_transport(|key| {
+ Ok(webrtc::tokio::Transport::new(
+ key.clone(),
+ webrtc::tokio::Certificate::generate(&mut rand::thread_rng())?,
+ ))
+ })?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/udp/0/webrtc-direct"),
),
- (Transport::Tcp, Err(_)) => bail!("Missing security protocol for TCP transport"),
- (Transport::Ws, Err(_)) => bail!("Missing security protocol for Websocket transport"),
- (Transport::Webtransport, _) => bail!("Webtransport can only be used with wasm"),
+ (t, s, m) => bail!("Unsupported combination: {t:?} {s:?} {m:?}"),
};
- Ok((transport, addr))
- }
-
- pub(crate) fn swarm_builder(
- transport: BoxedTransport,
- behaviour: TBehaviour,
- peer_id: PeerId,
- ) -> SwarmBuilder {
- SwarmBuilder::with_tokio_executor(transport, behaviour, peer_id)
+ Ok((swarm, addr))
}
pub(crate) struct RedisClient(redis::Client);
@@ -154,17 +187,17 @@ pub(crate) mod native {
#[cfg(target_arch = "wasm32")]
pub(crate) mod wasm {
- use anyhow::{bail, Result};
+ use anyhow::{bail, Context, Result};
use futures::future::{BoxFuture, FutureExt};
+ use libp2p::core::upgrade::Version;
use libp2p::identity::Keypair;
- use libp2p::swarm::{NetworkBehaviour, SwarmBuilder};
- use libp2p::PeerId;
- use libp2p_webrtc_websys as webrtc;
+ use libp2p::swarm::{NetworkBehaviour, Swarm};
+ use libp2p::{noise, websocket_websys, webtransport_websys, yamux, Transport as _};
+ use libp2p_mplex as mplex;
+ use libp2p_webrtc_websys as webrtc_websys;
use std::time::Duration;
- use crate::{BlpopRequest, Transport};
-
- use super::BoxedTransport;
+ use crate::{BlpopRequest, Muxer, SecProtocol, Transport};
pub(crate) type Instant = instant::Instant;
@@ -177,33 +210,74 @@ pub(crate) mod wasm {
futures_timer::Delay::new(duration).boxed()
}
- pub(crate) fn build_transport(
- local_key: Keypair,
+ pub(crate) async fn build_swarm(
ip: &str,
transport: Transport,
- ) -> Result<(BoxedTransport, String)> {
- match transport {
- Transport::Webtransport => Ok((
- libp2p::webtransport_websys::Transport::new(
- libp2p::webtransport_websys::Config::new(&local_key),
- )
- .boxed(),
+ sec_protocol: Option,
+ muxer: Option,
+ behaviour_constructor: impl FnOnce(&Keypair) -> B,
+ ) -> Result<(Swarm, String)> {
+ Ok(match (transport, sec_protocol, muxer) {
+ (Transport::Webtransport, None, None) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_wasm_bindgen()
+ .with_other_transport(|local_key| {
+ webtransport_websys::Transport::new(webtransport_websys::Config::new(
+ &local_key,
+ ))
+ })?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/udp/0/quic/webtransport"),
- )),
- Transport::WebRtcDirect => Ok((
- webrtc::Transport::new(webrtc::Config::new(&local_key)).boxed(),
+ ),
+ (Transport::Ws, Some(SecProtocol::Noise), Some(Muxer::Mplex)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_wasm_bindgen()
+ .with_other_transport(|local_key| {
+ Ok(websocket_websys::Transport::default()
+ .upgrade(Version::V1Lazy)
+ .authenticate(
+ noise::Config::new(&local_key)
+ .context("failed to initialise noise")?,
+ )
+ .multiplex(mplex::MplexConfig::new()))
+ })?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
+ format!("/ip4/{ip}/tcp/0/wss"),
+ ),
+ (Transport::Ws, Some(SecProtocol::Noise), Some(Muxer::Yamux)) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_wasm_bindgen()
+ .with_other_transport(|local_key| {
+ Ok(websocket_websys::Transport::default()
+ .upgrade(Version::V1Lazy)
+ .authenticate(
+ noise::Config::new(&local_key)
+ .context("failed to initialise noise")?,
+ )
+ .multiplex(yamux::Config::default()))
+ })?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
+ format!("/ip4/{ip}/tcp/0/wss"),
+ ),
+ (Transport::WebRtcDirect, None, None) => (
+ libp2p::SwarmBuilder::with_new_identity()
+ .with_wasm_bindgen()
+ .with_other_transport(|local_key| {
+ webrtc_websys::Transport::new(webrtc_websys::Config::new(&local_key))
+ })?
+ .with_behaviour(behaviour_constructor)?
+ .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
+ .build(),
format!("/ip4/{ip}/udp/0/webrtc-direct"),
- )),
- _ => bail!("Only webtransport and webrtc-direct are supported with wasm"),
- }
- }
-
- pub(crate) fn swarm_builder(
- transport: BoxedTransport,
- behaviour: TBehaviour,
- peer_id: PeerId,
- ) -> SwarmBuilder {
- SwarmBuilder::with_wasm_executor(transport, behaviour, peer_id)
+ ),
+ (t, s, m) => bail!("Unsupported combination: {t:?} {s:?} {m:?}"),
+ })
}
pub(crate) struct RedisClient(String);
diff --git a/interop-tests/src/bin/config/mod.rs b/interop-tests/src/bin/config/mod.rs
index 82747e82802b..dff297ef412e 100644
--- a/interop-tests/src/bin/config/mod.rs
+++ b/interop-tests/src/bin/config/mod.rs
@@ -5,6 +5,8 @@ use anyhow::{Context, Result};
#[derive(Debug, Clone)]
pub(crate) struct Config {
pub(crate) transport: String,
+ pub(crate) sec_protocol: Option,
+ pub(crate) muxer: Option,
pub(crate) ip: String,
pub(crate) is_dialer: bool,
pub(crate) test_timeout: u64,
@@ -26,8 +28,13 @@ impl Config {
.map(|addr| format!("redis://{addr}"))
.unwrap_or_else(|_| "redis://redis:6379".into());
+ let sec_protocol = env::var("security").ok();
+ let muxer = env::var("muxer").ok();
+
Ok(Self {
transport,
+ sec_protocol,
+ muxer,
ip,
is_dialer,
test_timeout,
diff --git a/interop-tests/src/bin/native_ping.rs b/interop-tests/src/bin/native_ping.rs
index 88905803d26d..2fb6ce12e29d 100644
--- a/interop-tests/src/bin/native_ping.rs
+++ b/interop-tests/src/bin/native_ping.rs
@@ -12,6 +12,8 @@ async fn main() -> Result<()> {
config.is_dialer,
config.test_timeout,
&config.redis_addr,
+ config.sec_protocol,
+ config.muxer,
)
.await?;
diff --git a/interop-tests/src/bin/wasm_ping.rs b/interop-tests/src/bin/wasm_ping.rs
index b3a918192261..e1bb2ea49fb5 100644
--- a/interop-tests/src/bin/wasm_ping.rs
+++ b/interop-tests/src/bin/wasm_ping.rs
@@ -1,9 +1,10 @@
#![allow(non_upper_case_globals)]
+
+use std::future::IntoFuture;
use std::process::Stdio;
use std::time::Duration;
use anyhow::{bail, Context, Result};
-use axum::body;
use axum::http::{header, Uri};
use axum::response::{Html, IntoResponse, Response};
use axum::routing::get;
@@ -11,11 +12,11 @@ use axum::{extract::State, http::StatusCode, routing::post, Json, Router};
use redis::{AsyncCommands, Client};
use thirtyfour::prelude::*;
use tokio::io::{AsyncBufReadExt, BufReader};
+use tokio::net::TcpListener;
use tokio::process::Child;
use tokio::sync::mpsc;
use tower_http::cors::CorsLayer;
use tower_http::trace::TraceLayer;
-use tracing::{error, warn};
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use interop_tests::{BlpopRequest, Report};
@@ -77,7 +78,7 @@ async fn main() -> Result<()> {
.with_state(state);
// Run the service in background
- tokio::spawn(axum::Server::bind(&BIND_ADDR.parse()?).serve(app.into_make_service()));
+ tokio::spawn(axum::serve(TcpListener::bind(BIND_ADDR).await?, app).into_future());
// Start executing the test in a browser
let (mut chrome, driver) = open_in_browser().await?;
@@ -144,16 +145,17 @@ async fn redis_blpop(
) -> Result>, StatusCode> {
let client = state.0.redis_client;
let mut conn = client.get_async_connection().await.map_err(|e| {
- warn!("Failed to connect to redis: {e}");
+ tracing::warn!("Failed to connect to redis: {e}");
StatusCode::INTERNAL_SERVER_ERROR
})?;
let res = conn
.blpop(&request.key, request.timeout as usize)
.await
.map_err(|e| {
- warn!(
- "Failed to get list elem {} within timeout {}: {e}",
- request.key, request.timeout
+ tracing::warn!(
+ key=%request.key,
+ timeout=%request.timeout,
+ "Failed to get list elem key within timeout: {e}"
);
StatusCode::INTERNAL_SERVER_ERROR
})?;
@@ -167,7 +169,7 @@ async fn post_results(
request: Json>,
) -> Result<(), StatusCode> {
state.0.results_tx.send(request.0).await.map_err(|_| {
- error!("Failed to send results");
+ tracing::error!("Failed to send results");
StatusCode::INTERNAL_SERVER_ERROR
})
}
@@ -179,8 +181,18 @@ async fn serve_index_html(state: State) -> Result
@@ -200,7 +212,9 @@ async fn serve_index_html(state: State) -> Result
@@ -217,7 +231,7 @@ async fn serve_wasm_pkg(uri: Uri) -> Result {
let mime = mime_guess::from_path(&path).first_or_octet_stream();
Ok(Response::builder()
.header(header::CONTENT_TYPE, mime.as_ref())
- .body(body::boxed(body::Full::from(content.data)))
+ .body(content.data.into())
.unwrap())
} else {
Err(StatusCode::NOT_FOUND)
diff --git a/interop-tests/src/lib.rs b/interop-tests/src/lib.rs
index 40c06b57810e..0154bec51a4e 100644
--- a/interop-tests/src/lib.rs
+++ b/interop-tests/src/lib.rs
@@ -3,14 +3,15 @@ use std::time::Duration;
use anyhow::{bail, Context, Result};
use futures::{FutureExt, StreamExt};
+use libp2p::identity::Keypair;
use libp2p::swarm::SwarmEvent;
-use libp2p::{identify, identity, ping, swarm::NetworkBehaviour, Multiaddr, PeerId};
+use libp2p::{identify, ping, swarm::NetworkBehaviour, Multiaddr};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
mod arch;
-use arch::{build_transport, init_logger, swarm_builder, Instant, RedisClient};
+use arch::{build_swarm, init_logger, Instant, RedisClient};
pub async fn run_test(
transport: &str,
@@ -18,42 +19,45 @@ pub async fn run_test(
is_dialer: bool,
test_timeout_seconds: u64,
redis_addr: &str,
+ sec_protocol: Option,
+ muxer: Option,
) -> Result {
init_logger();
let test_timeout = Duration::from_secs(test_timeout_seconds);
let transport = transport.parse().context("Couldn't parse transport")?;
+ let sec_protocol = sec_protocol
+ .map(|sec_protocol| {
+ sec_protocol
+ .parse()
+ .context("Couldn't parse security protocol")
+ })
+ .transpose()?;
+ let muxer = muxer
+ .map(|sec_protocol| {
+ sec_protocol
+ .parse()
+ .context("Couldn't parse muxer protocol")
+ })
+ .transpose()?;
- let local_key = identity::Keypair::generate_ed25519();
- let local_peer_id = PeerId::from(local_key.public());
let redis_client = RedisClient::new(redis_addr).context("Could not connect to redis")?;
// Build the transport from the passed ENV var.
- let (boxed_transport, local_addr) = build_transport(local_key.clone(), ip, transport)?;
- let mut swarm = swarm_builder(
- boxed_transport,
- Behaviour {
- ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(10))),
- // Need to include identify until https://github.com/status-im/nim-libp2p/issues/924 is resolved.
- identify: identify::Behaviour::new(identify::Config::new(
- "/interop-tests".to_owned(),
- local_key.public(),
- )),
- },
- local_peer_id,
- )
- .idle_connection_timeout(Duration::from_secs(5))
- .build();
-
- log::info!("Running ping test: {}", swarm.local_peer_id());
+ let (mut swarm, local_addr) =
+ build_swarm(ip, transport, sec_protocol, muxer, build_behaviour).await?;
- let mut maybe_id = None;
+ tracing::info!(local_peer=%swarm.local_peer_id(), "Running ping test");
// See https://github.com/libp2p/rust-libp2p/issues/4071.
#[cfg(not(target_arch = "wasm32"))]
- if transport == Transport::WebRtcDirect {
- maybe_id = Some(swarm.listen_on(local_addr.parse()?)?);
- }
+ let maybe_id = if transport == Transport::WebRtcDirect {
+ Some(swarm.listen_on(local_addr.parse()?)?)
+ } else {
+ None
+ };
+ #[cfg(target_arch = "wasm32")]
+ let maybe_id = None;
// Run a ping interop test. Based on `is_dialer`, either dial the address
// retrieved via `listenAddr` key over the redis connection. Or wait to be pinged and have
@@ -70,7 +74,7 @@ pub async fn run_test(
let handshake_start = Instant::now();
swarm.dial(other.parse::()?)?;
- log::info!("Test instance, dialing multiaddress on: {}.", other);
+ tracing::info!(listener=%other, "Test instance, dialing multiaddress");
let rtt = loop {
if let Some(SwarmEvent::Behaviour(BehaviourEvent::Ping(ping::Event {
@@ -78,7 +82,7 @@ pub async fn run_test(
..
}))) = swarm.next().await
{
- log::info!("Ping successful: {rtt:?}");
+ tracing::info!(?rtt, "Ping successful");
break rtt.as_micros() as f32 / 1000.;
}
};
@@ -97,9 +101,9 @@ pub async fn run_test(
Some(id) => id,
};
- log::info!(
- "Test instance, listening for incoming connections on: {:?}.",
- local_addr
+ tracing::info!(
+ address=%local_addr,
+ "Test instance, listening for incoming connections on address"
);
loop {
@@ -112,8 +116,8 @@ pub async fn run_test(
continue;
}
if listener_id == id {
- let ma = format!("{address}/p2p/{local_peer_id}");
- redis_client.rpush("listenerAddr", ma).await?;
+ let ma = format!("{address}/p2p/{}", swarm.local_peer_id());
+ redis_client.rpush("listenerAddr", ma.clone()).await?;
break;
}
}
@@ -123,7 +127,9 @@ pub async fn run_test(
futures::future::select(
async move {
loop {
- swarm.next().await;
+ let event = swarm.next().await.unwrap();
+
+ tracing::debug!("{event:?}");
}
}
.boxed(),
@@ -145,9 +151,20 @@ pub async fn run_test_wasm(
is_dialer: bool,
test_timeout_secs: u64,
base_url: &str,
+ sec_protocol: Option,
+ muxer: Option,
) -> Result<(), JsValue> {
- let result = run_test(transport, ip, is_dialer, test_timeout_secs, base_url).await;
- log::info!("Sending test result: {result:?}");
+ let result = run_test(
+ transport,
+ ip,
+ is_dialer,
+ test_timeout_secs,
+ base_url,
+ sec_protocol,
+ muxer,
+ )
+ .await;
+ tracing::info!(?result, "Sending test result");
reqwest::Client::new()
.post(&format!("http://{}/results", base_url))
.json(&result.map_err(|e| e.to_string()))
@@ -240,18 +257,18 @@ impl FromStr for SecProtocol {
}
#[derive(NetworkBehaviour)]
-struct Behaviour {
+pub(crate) struct Behaviour {
ping: ping::Behaviour,
identify: identify::Behaviour,
}
-/// Helper function to get a ENV variable into an test parameter like `Transport`.
-pub fn from_env(env_var: &str) -> Result
-where
- T: FromStr,
-{
- std::env::var(env_var)
- .with_context(|| format!("{env_var} environment variable is not set"))?
- .parse()
- .map_err(Into::into)
+pub(crate) fn build_behaviour(key: &Keypair) -> Behaviour {
+ Behaviour {
+ ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
+ // Need to include identify until https://github.com/status-im/nim-libp2p/issues/924 is resolved.
+ identify: identify::Behaviour::new(identify::Config::new(
+ "/interop-tests".to_owned(),
+ key.public(),
+ )),
+ }
}
diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md
index 9ae0d1c28aac..80b32c35643b 100644
--- a/libp2p/CHANGELOG.md
+++ b/libp2p/CHANGELOG.md
@@ -1,3 +1,50 @@
+## 0.53.2
+
+- Allow `SwarmBuilder::with_bandwidth_metrics` after `SwarmBuilder::with_websocket`.
+ See [PR 4937](https://github.com/libp2p/rust-libp2p/pull/4937).
+
+## 0.53.1
+
+- Allow `SwarmBuilder::with_quic_config` to be called without `with_tcp` first.
+ See [PR 4821](https://github.com/libp2p/rust-libp2p/pull/4821).
+- Introduce `SwarmBuilder::with_dns_config`.
+ See [PR 4808](https://github.com/libp2p/rust-libp2p/pull/4808).
+
+## 0.53.0
+
+- Raise MSRV to 1.73.
+ See [PR 4692](https://github.com/libp2p/rust-libp2p/pull/4692).
+- Remove deprecated `libp2p-wasm-ext`.
+ Users should use `libp2p-websocket-websys` instead.
+ See [PR 4694](https://github.com/libp2p/rust-libp2p/pull/4694).
+- Remove deprecated `libp2p-deflate`.
+ See [issue 4522](https://github.com/libp2p/rust-libp2p/issues/4522) for details.
+ See [PR 4729](https://github.com/libp2p/rust-libp2p/pull/4729).
+- Remove deprecated `development_transport`.
+ Use `libp2p::SwarmBuilder` instead.
+ See [PR 4732](https://github.com/libp2p/rust-libp2p/pull/4732).
+- Introduce `SwarmBuilder::with_bandwidth_metrics` exposing Prometheus bandwidth metrics per transport protocol stack and direction (in-/ outbound).
+ Deprecate `Transport::with_bandwidth_logging` and `SwarmBuilder::with_bandwidth_logging` in favor of the new `SwarmBuilder::with_bandwidth_metrics`.
+ See [PR 4727](https://github.com/libp2p/rust-libp2p/pull/4727).
+
+## 0.52.4
+
+- Introduce `libp2p::websocket_websys` module behind `websocket-websys` feature flag.
+ This supersedes the existing `libp2p::wasm_ext` module which is now deprecated.
+ See [PR 3679].
+
+- Introduce a new `libp2p::SwarmBuilder` in favor of the now deprecated `libp2p::swarm::SwarmBuilder`.
+ See `libp2p::SwarmBuilder` docs on how to use the new builder.
+ Also see [PR 4120].
+
+- Update `libp2p-identity` version to 0.2.6.
+ Under the hood, we feature-flagged `libp2p-identity`'s `rand` dependency but it is enabled by default when using `libp2p`.
+ See [PR 4349].
+
+[PR 3679]: https://github.com/libp2p/rust-libp2p/pull/3679
+[PR 4120]: https://github.com/libp2p/rust-libp2p/pull/4120
+[PR 4349]: https://github.com/libp2p/rust-libp2p/pull/4349
+
## 0.52.3
- Add `libp2p-quic` stable release.
@@ -64,8 +111,8 @@
## 0.51.3
- Deprecate the `mplex` feature.
-The recommended baseline stream multiplexer is `yamux`.
-See [PR 3689].
+ The recommended baseline stream multiplexer is `yamux`.
+ See [PR 3689].
[PR 3689]: https://github.com/libp2p/rust-libp2p/pull/3689
diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml
index 1264a0505618..9dc9667be105 100644
--- a/libp2p/Cargo.toml
+++ b/libp2p/Cargo.toml
@@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021"
rust-version = { workspace = true }
description = "Peer-to-peer networking library"
-version = "0.52.3"
+version = "0.53.2"
authors = ["Parity Technologies "]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -16,7 +16,6 @@ full = [
"autonat",
"cbor",
"dcutr",
- "deflate",
"dns",
"ecdsa",
"ed25519",
@@ -45,8 +44,7 @@ full = [
"tokio",
"uds",
"wasm-bindgen",
- "wasm-ext",
- "wasm-ext-websocket",
+ "websocket-websys",
"websocket",
"webtransport-websys",
"yamux",
@@ -57,7 +55,6 @@ async-std = [ "libp2p-swarm/async-std", "libp2p-mdns?/async-io", "libp2p-tcp?/as
autonat = ["dep:libp2p-autonat"]
cbor = ["libp2p-request-response?/cbor"]
dcutr = ["dep:libp2p-dcutr", "libp2p-metrics?/dcutr"]
-deflate = ["dep:libp2p-deflate"]
dns = ["dep:libp2p-dns"]
ecdsa = ["libp2p-identity/ecdsa"]
ed25519 = ["libp2p-identity/ed25519"]
@@ -86,8 +83,7 @@ tls = ["dep:libp2p-tls"]
tokio = [ "libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = [ "futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen",]
-wasm-ext = ["dep:libp2p-wasm-ext"]
-wasm-ext-websocket = ["wasm-ext", "libp2p-wasm-ext?/websocket"]
+websocket-websys = ["dep:libp2p-websocket-websys"]
websocket = ["dep:libp2p-websocket"]
webtransport-websys = ["dep:libp2p-webtransport-websys"]
yamux = ["dep:libp2p-yamux"]
@@ -95,10 +91,13 @@ upnp = ["dep:libp2p-upnp"]
[dependencies]
bytes = "1"
+either = "1.9.0"
futures = "0.3.26"
futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.12" # Explicit dependency to be used in `wasm-bindgen` feature
+# TODO feature flag?
+rw-stream-sink = { workspace = true }
libp2p-allow-block-list = { workspace = true }
libp2p-autonat = { workspace = true, optional = true }
@@ -108,7 +107,7 @@ libp2p-dcutr = { workspace = true, optional = true }
libp2p-floodsub = { workspace = true, optional = true }
libp2p-gossipsub = { workspace = true, optional = true }
libp2p-identify = { workspace = true, optional = true }
-libp2p-identity = { workspace = true }
+libp2p-identity = { workspace = true, features = ["rand"] }
libp2p-kad = { workspace = true, optional = true }
libp2p-metrics = { workspace = true, optional = true }
libp2p-noise = { workspace = true, optional = true }
@@ -119,15 +118,14 @@ libp2p-relay = { workspace = true, optional = true }
libp2p-rendezvous = { workspace = true, optional = true }
libp2p-request-response = { workspace = true, optional = true }
libp2p-swarm = { workspace = true }
-libp2p-wasm-ext = { workspace = true, optional = true }
+libp2p-websocket-websys = { workspace = true, optional = true }
libp2p-webtransport-websys = { workspace = true, optional = true }
libp2p-yamux = { workspace = true, optional = true }
-
multiaddr = { workspace = true }
pin-project = "1.0.0"
+thiserror = "1.0"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-libp2p-deflate = { workspace = true, optional = true }
libp2p-dns = { workspace = true, optional = true }
libp2p-mdns = { workspace = true, optional = true }
libp2p-memory-connection-limits = { workspace = true, optional = true }
@@ -141,13 +139,13 @@ libp2p-websocket = { workspace = true, optional = true }
[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
async-trait = "0.1"
-either = "1.8.0"
-env_logger = "0.10.0"
clap = { version = "4.1.6", features = ["derive"] }
tokio = { version = "1.15", features = [ "io-util", "io-std", "macros", "rt", "rt-multi-thread"] }
+libp2p-mplex = { workspace = true }
libp2p-noise = { workspace = true }
libp2p-tcp = { workspace = true, features = ["tokio"] }
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Passing arguments to the docsrs builder in order to properly document cfg's.
# More information: https://docs.rs/about/builds#cross-compiling
diff --git a/libp2p/src/bandwidth.rs b/libp2p/src/bandwidth.rs
index dc696ce07e2c..b84cbb7e27b1 100644
--- a/libp2p/src/bandwidth.rs
+++ b/libp2p/src/bandwidth.rs
@@ -18,6 +18,8 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
+#![allow(deprecated)]
+
use crate::core::muxing::{StreamMuxer, StreamMuxerEvent};
use futures::{
@@ -101,6 +103,9 @@ where
}
/// Allows obtaining the average bandwidth of the streams.
+#[deprecated(
+ note = "Use `libp2p::SwarmBuilder::with_bandwidth_metrics` or `libp2p_metrics::BandwidthTransport` instead."
+)]
pub struct BandwidthSinks {
inbound: AtomicU64,
outbound: AtomicU64,
diff --git a/libp2p/src/builder.rs b/libp2p/src/builder.rs
new file mode 100644
index 000000000000..c96c20d470a3
--- /dev/null
+++ b/libp2p/src/builder.rs
@@ -0,0 +1,603 @@
+use std::marker::PhantomData;
+
+mod phase;
+mod select_muxer;
+mod select_security;
+
+/// Build a [`Swarm`](libp2p_swarm::Swarm) by combining an identity, a set of
+/// [`Transport`](libp2p_core::Transport)s and a
+/// [`NetworkBehaviour`](libp2p_swarm::NetworkBehaviour).
+///
+/// ```
+/// # use libp2p::{swarm::NetworkBehaviour, SwarmBuilder};
+/// # use libp2p::core::transport::dummy::DummyTransport;
+/// # use libp2p::core::muxing::StreamMuxerBox;
+/// # use libp2p::identity::PeerId;
+/// # use std::error::Error;
+/// #
+/// # #[cfg(all(
+/// # not(target_arch = "wasm32"),
+/// # feature = "tokio",
+/// # feature = "tcp",
+/// # feature = "tls",
+/// # feature = "noise",
+/// # feature = "quic",
+/// # feature = "dns",
+/// # feature = "relay",
+/// # feature = "websocket",
+/// # ))]
+/// # async fn build_swarm() -> Result<(), Box> {
+/// # #[derive(NetworkBehaviour)]
+/// # #[behaviour(prelude = "libp2p_swarm::derive_prelude")]
+/// # struct MyBehaviour {
+/// # relay: libp2p_relay::client::Behaviour,
+/// # }
+///
+/// let swarm = SwarmBuilder::with_new_identity()
+/// .with_tokio()
+/// .with_tcp(
+/// Default::default(),
+/// (libp2p_tls::Config::new, libp2p_noise::Config::new),
+/// libp2p_yamux::Config::default,
+/// )?
+/// .with_quic()
+/// .with_other_transport(|_key| DummyTransport::<(PeerId, StreamMuxerBox)>::new())?
+/// .with_dns()?
+/// .with_websocket(
+/// (libp2p_tls::Config::new, libp2p_noise::Config::new),
+/// libp2p_yamux::Config::default,
+/// )
+/// .await?
+/// .with_relay_client(
+/// (libp2p_tls::Config::new, libp2p_noise::Config::new),
+/// libp2p_yamux::Config::default,
+/// )?
+/// .with_behaviour(|_key, relay| MyBehaviour { relay })?
+/// .with_swarm_config(|cfg| {
+/// // Edit cfg here.
+/// cfg
+/// })
+/// .build();
+/// #
+/// # Ok(())
+/// # }
+/// ```
+pub struct SwarmBuilder {
+ keypair: libp2p_identity::Keypair,
+ phantom: PhantomData,
+ phase: Phase,
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::SwarmBuilder;
+ use libp2p_core::{muxing::StreamMuxerBox, transport::dummy::DummyTransport};
+ use libp2p_identity::PeerId;
+ use libp2p_swarm::NetworkBehaviour;
+
+ #[test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ ))]
+ fn tcp() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ libp2p_tls::Config::new,
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(
+ feature = "async-std",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ ))]
+ fn async_std_tcp() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_tcp(
+ Default::default(),
+ libp2p_tls::Config::new,
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(feature = "tokio", feature = "quic"))]
+ fn quic() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_quic()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(feature = "async-std", feature = "quic"))]
+ fn async_std_quic() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_quic()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(feature = "tokio", feature = "quic"))]
+ fn quic_config() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_quic_config(|config| config)
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(feature = "async-std", feature = "quic"))]
+ fn async_std_quic_config() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_quic_config(|config| config)
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(feature = "tokio", feature = "tcp", feature = "tls", feature = "yamux"))]
+ fn tcp_yamux_mplex() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ libp2p_tls::Config::new,
+ (
+ libp2p_yamux::Config::default,
+ libp2p_mplex::MplexConfig::default,
+ ),
+ )
+ .unwrap()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux"
+ ))]
+ fn tcp_tls_noise() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ (
+ libp2p_yamux::Config::default,
+ libp2p_mplex::MplexConfig::default,
+ ),
+ )
+ .unwrap()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "quic"
+ ))]
+ fn tcp_quic() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_quic()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(
+ feature = "async-std",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "quic"
+ ))]
+ fn async_std_tcp_quic() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_quic()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "quic"
+ ))]
+ fn tcp_quic_config() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_quic_config(|config| config)
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(
+ feature = "async-std",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "quic"
+ ))]
+ fn async_std_tcp_quic_config() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_quic_config(|config| config)
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "relay"
+ ))]
+ fn tcp_relay() {
+ #[derive(libp2p_swarm::NetworkBehaviour)]
+ #[behaviour(prelude = "libp2p_swarm::derive_prelude")]
+ struct Behaviour {
+ dummy: libp2p_swarm::dummy::Behaviour,
+ relay: libp2p_relay::client::Behaviour,
+ }
+
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ libp2p_tls::Config::new,
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_relay_client(libp2p_tls::Config::new, libp2p_yamux::Config::default)
+ .unwrap()
+ .with_behaviour(|_, relay| Behaviour {
+ dummy: libp2p_swarm::dummy::Behaviour,
+ relay,
+ })
+ .unwrap()
+ .build();
+ }
+
+ #[tokio::test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "dns"
+ ))]
+ async fn tcp_dns() {
+ SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_dns()
+ .unwrap()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[tokio::test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "noise",
+ feature = "yamux",
+ feature = "dns"
+ ))]
+ async fn tcp_dns_config() {
+ SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_dns_config(
+ libp2p_dns::ResolverConfig::default(),
+ libp2p_dns::ResolverOpts::default(),
+ )
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[tokio::test]
+ #[cfg(all(feature = "tokio", feature = "quic", feature = "dns"))]
+ async fn quic_dns_config() {
+ SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_quic()
+ .with_dns_config(
+ libp2p_dns::ResolverConfig::default(),
+ libp2p_dns::ResolverOpts::default(),
+ )
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[tokio::test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "noise",
+ feature = "yamux",
+ feature = "quic",
+ feature = "dns"
+ ))]
+ async fn tcp_quic_dns_config() {
+ SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_quic()
+ .with_dns_config(
+ libp2p_dns::ResolverConfig::default(),
+ libp2p_dns::ResolverOpts::default(),
+ )
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[tokio::test]
+ #[cfg(all(
+ feature = "async-std",
+ feature = "tcp",
+ feature = "noise",
+ feature = "yamux",
+ feature = "quic",
+ feature = "dns"
+ ))]
+ async fn async_std_tcp_quic_dns_config() {
+ SwarmBuilder::with_new_identity()
+ .with_async_std()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_quic()
+ .with_dns_config(
+ libp2p_dns::ResolverConfig::default(),
+ libp2p_dns::ResolverOpts::default(),
+ )
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ /// Showcases how to provide custom transports unknown to the libp2p crate, e.g. WebRTC.
+ #[test]
+ #[cfg(feature = "tokio")]
+ fn other_transport() -> Result<(), Box> {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ // Closure can either return a Transport directly.
+ .with_other_transport(|_| DummyTransport::<(PeerId, StreamMuxerBox)>::new())?
+ // Or a Result containing a Transport.
+ .with_other_transport(|_| {
+ if true {
+ Ok(DummyTransport::<(PeerId, StreamMuxerBox)>::new())
+ } else {
+ Err(Box::from("test"))
+ }
+ })?
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+
+ Ok(())
+ }
+
+ #[tokio::test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "dns",
+ feature = "websocket",
+ ))]
+ async fn tcp_websocket() {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_websocket(
+ (libp2p_tls::Config::new, libp2p_noise::Config::new),
+ libp2p_yamux::Config::default,
+ )
+ .await
+ .unwrap()
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+ }
+
+ #[tokio::test]
+ #[cfg(all(
+ feature = "tokio",
+ feature = "tcp",
+ feature = "tls",
+ feature = "noise",
+ feature = "yamux",
+ feature = "quic",
+ feature = "dns",
+ feature = "relay",
+ feature = "websocket",
+ feature = "metrics",
+ ))]
+ async fn all() {
+ #[derive(NetworkBehaviour)]
+ #[behaviour(prelude = "libp2p_swarm::derive_prelude")]
+ struct MyBehaviour {
+ relay: libp2p_relay::client::Behaviour,
+ }
+
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ libp2p_tls::Config::new,
+ libp2p_yamux::Config::default,
+ )
+ .unwrap()
+ .with_quic()
+ .with_dns()
+ .unwrap()
+ .with_websocket(libp2p_tls::Config::new, libp2p_yamux::Config::default)
+ .await
+ .unwrap()
+ .with_relay_client(libp2p_tls::Config::new, libp2p_yamux::Config::default)
+ .unwrap()
+ .with_bandwidth_metrics(&mut libp2p_metrics::Registry::default())
+ .with_behaviour(|_key, relay| MyBehaviour { relay })
+ .unwrap()
+ .build();
+ }
+
+ #[test]
+ #[cfg(all(feature = "tokio", feature = "tcp", feature = "tls", feature = "yamux"))]
+ fn tcp_bandwidth_metrics() -> Result<(), Box> {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_tcp(
+ Default::default(),
+ libp2p_tls::Config::new,
+ libp2p_yamux::Config::default,
+ )?
+ .with_bandwidth_metrics(&mut libp2p_metrics::Registry::default())
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+
+ Ok(())
+ }
+
+ #[test]
+ #[cfg(all(feature = "tokio", feature = "quic"))]
+ fn quic_bandwidth_metrics() -> Result<(), Box> {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_quic()
+ .with_bandwidth_metrics(&mut libp2p_metrics::Registry::default())
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+
+ Ok(())
+ }
+
+ #[test]
+ #[cfg(feature = "tokio")]
+ fn other_transport_bandwidth_metrics() -> Result<(), Box> {
+ let _ = SwarmBuilder::with_new_identity()
+ .with_tokio()
+ .with_other_transport(|_| DummyTransport::<(PeerId, StreamMuxerBox)>::new())?
+ .with_bandwidth_metrics(&mut libp2p_metrics::Registry::default())
+ .with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
+ .unwrap()
+ .build();
+
+ Ok(())
+ }
+}
diff --git a/libp2p/src/builder/phase.rs b/libp2p/src/builder/phase.rs
new file mode 100644
index 000000000000..c9679a467674
--- /dev/null
+++ b/libp2p/src/builder/phase.rs
@@ -0,0 +1,139 @@
+#![allow(unused_imports)]
+
+mod bandwidth_logging;
+mod bandwidth_metrics;
+mod behaviour;
+mod build;
+mod dns;
+mod identity;
+mod other_transport;
+mod provider;
+mod quic;
+mod relay;
+mod swarm;
+mod tcp;
+mod websocket;
+
+use bandwidth_logging::*;
+use bandwidth_metrics::*;
+use behaviour::*;
+use build::*;
+use dns::*;
+use other_transport::*;
+use provider::*;
+use quic::*;
+use relay::*;
+use swarm::*;
+use tcp::*;
+use websocket::*;
+
+use super::select_muxer::SelectMuxerUpgrade;
+use super::select_security::SelectSecurityUpgrade;
+use super::SwarmBuilder;
+
+use libp2p_core::{muxing::StreamMuxerBox, Transport};
+use libp2p_identity::Keypair;
+
+#[allow(unreachable_pub)]
+pub trait IntoSecurityUpgrade {
+ type Upgrade;
+ type Error;
+
+ fn into_security_upgrade(self, keypair: &Keypair) -> Result;
+}
+
+impl IntoSecurityUpgrade for F
+where
+ F: for<'a> FnOnce(&'a Keypair) -> Result,
+{
+ type Upgrade = T;
+ type Error = E;
+
+ fn into_security_upgrade(self, keypair: &Keypair) -> Result {
+ (self)(keypair)
+ }
+}
+
+impl IntoSecurityUpgrade for (F1, F2)
+where
+ F1: IntoSecurityUpgrade,
+ F2: IntoSecurityUpgrade,
+{
+ type Upgrade = SelectSecurityUpgrade;
+ type Error = either::Either;
+
+ fn into_security_upgrade(self, keypair: &Keypair) -> Result {
+ let (f1, f2) = self;
+
+ let u1 = f1
+ .into_security_upgrade(keypair)
+ .map_err(either::Either::Left)?;
+ let u2 = f2
+ .into_security_upgrade(keypair)
+ .map_err(either::Either::Right)?;
+
+ Ok(SelectSecurityUpgrade::new(u1, u2))
+ }
+}
+
+#[allow(unreachable_pub)]
+pub trait IntoMultiplexerUpgrade {
+ type Upgrade;
+
+ fn into_multiplexer_upgrade(self) -> Self::Upgrade;
+}
+
+impl IntoMultiplexerUpgrade for F
+where
+ F: FnOnce() -> U,
+{
+ type Upgrade = U;
+
+ fn into_multiplexer_upgrade(self) -> Self::Upgrade {
+ (self)()
+ }
+}
+
+impl IntoMultiplexerUpgrade for (U1, U2)
+where
+ U1: IntoMultiplexerUpgrade,
+ U2: IntoMultiplexerUpgrade,
+{
+ type Upgrade = SelectMuxerUpgrade;
+
+ fn into_multiplexer_upgrade(self) -> Self::Upgrade {
+ let (f1, f2) = self;
+
+ let u1 = f1.into_multiplexer_upgrade();
+ let u2 = f2.into_multiplexer_upgrade();
+
+ SelectMuxerUpgrade::new(u1, u2)
+ }
+}
+
+pub trait AuthenticatedMultiplexedTransport:
+ Transport<
+ Error = Self::E,
+ Dial = Self::D,
+ ListenerUpgrade = Self::U,
+ Output = (libp2p_identity::PeerId, StreamMuxerBox),
+ > + Send
+ + Unpin
+ + 'static
+{
+ type E: Send + Sync + 'static;
+ type D: Send;
+ type U: Send;
+}
+
+impl AuthenticatedMultiplexedTransport for T
+where
+ T: Transport