Skip to content

Commit

Permalink
feat: introduce libp2p-allow-block-list connection management module
Browse files Browse the repository at this point in the history
Currently, banning peers is a first-class feature of `Swarm`. With the new connection management capabilities of `NetworkBehaviour`, we can now implement allow and block lists as a separate module.

We introduce a new crate `libp2p-allow-block-list` and deprecate `Swarm::ban_peer_id` in favor of that.

Related #2824.

Pull-Request: #3590.
  • Loading branch information
thomaseizinger committed Mar 21, 2023
1 parent 3fa10be commit f641870
Show file tree
Hide file tree
Showing 12 changed files with 532 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"examples/rendezvous",
"identity",
"interop-tests",
"misc/allow-block-list",
"misc/connection-limits",
"misc/keygen",
"misc/metrics",
Expand Down
4 changes: 4 additions & 0 deletions libp2p/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
To properly communicate this to users, we want them to add the dependency directly which makes the `alpha` version visible.
See [PR 3580].

- Introduce `libp2p::allow_block_list` module and deprecate `libp2p::Swarm::ban_peer_id`.
See [PR 3590].

[PR 3386]: https://github.com/libp2p/rust-libp2p/pull/3386
[PR 3580]: https://github.com/libp2p/rust-libp2p/pull/3580
[PR 3590]: https://github.com/libp2p/rust-libp2p/pull/3590

# 0.51.1

Expand Down
1 change: 1 addition & 0 deletions libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` featu
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature

libp2p-allow-block-list = { version = "0.1.0", path = "../misc/allow-block-list" }
libp2p-autonat = { version = "0.10.0", path = "../protocols/autonat", optional = true }
libp2p-connection-limits = { version = "0.1.0", path = "../misc/connection-limits" }
libp2p-core = { version = "0.39.0", path = "../core" }
Expand Down
2 changes: 2 additions & 0 deletions libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub use libp2p_core::multihash;
#[doc(inline)]
pub use multiaddr;

#[doc(inline)]
pub use libp2p_allow_block_list as allow_block_list;
#[cfg(feature = "autonat")]
#[doc(inline)]
pub use libp2p_autonat as autonat;
Expand Down
3 changes: 3 additions & 0 deletions misc/allow-block-list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.1.0 - unreleased

- Initial release.
21 changes: 21 additions & 0 deletions misc/allow-block-list/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "libp2p-allow-block-list"
edition = "2021"
rust-version = "1.62.0"
description = "Allow/block list connection management for libp2p."
version = "0.1.0"
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[dependencies]
libp2p-core = { version = "0.39.0", path = "../../core" }
libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
libp2p-identity = { version = "0.1.0", path = "../../identity", features = ["peerid"] }
void = "1"

[dev-dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }
libp2p-swarm-derive = { path = "../../swarm-derive" }
libp2p-swarm-test = { path = "../../swarm-test" }

0 comments on commit f641870

Please sign in to comment.