Skip to content

Commit f641870

Browse files
feat: introduce libp2p-allow-block-list connection management module
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.
1 parent 3fa10be commit f641870

File tree

12 files changed

+532
-2
lines changed

12 files changed

+532
-2
lines changed

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"examples/rendezvous",
1313
"identity",
1414
"interop-tests",
15+
"misc/allow-block-list",
1516
"misc/connection-limits",
1617
"misc/keygen",
1718
"misc/metrics",

libp2p/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
To properly communicate this to users, we want them to add the dependency directly which makes the `alpha` version visible.
99
See [PR 3580].
1010

11+
- Introduce `libp2p::allow_block_list` module and deprecate `libp2p::Swarm::ban_peer_id`.
12+
See [PR 3590].
13+
1114
[PR 3386]: https://github.com/libp2p/rust-libp2p/pull/3386
1215
[PR 3580]: https://github.com/libp2p/rust-libp2p/pull/3580
16+
[PR 3590]: https://github.com/libp2p/rust-libp2p/pull/3590
1317

1418
# 0.51.1
1519

libp2p/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` featu
9696
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
9797
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
9898

99+
libp2p-allow-block-list = { version = "0.1.0", path = "../misc/allow-block-list" }
99100
libp2p-autonat = { version = "0.10.0", path = "../protocols/autonat", optional = true }
100101
libp2p-connection-limits = { version = "0.1.0", path = "../misc/connection-limits" }
101102
libp2p-core = { version = "0.39.0", path = "../core" }

libp2p/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub use libp2p_core::multihash;
4040
#[doc(inline)]
4141
pub use multiaddr;
4242

43+
#[doc(inline)]
44+
pub use libp2p_allow_block_list as allow_block_list;
4345
#[cfg(feature = "autonat")]
4446
#[doc(inline)]
4547
pub use libp2p_autonat as autonat;

misc/allow-block-list/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 0.1.0 - unreleased
2+
3+
- Initial release.

misc/allow-block-list/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "libp2p-allow-block-list"
3+
edition = "2021"
4+
rust-version = "1.62.0"
5+
description = "Allow/block list connection management for libp2p."
6+
version = "0.1.0"
7+
license = "MIT"
8+
repository = "https://github.com/libp2p/rust-libp2p"
9+
keywords = ["peer-to-peer", "libp2p", "networking"]
10+
categories = ["network-programming", "asynchronous"]
11+
12+
[dependencies]
13+
libp2p-core = { version = "0.39.0", path = "../../core" }
14+
libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
15+
libp2p-identity = { version = "0.1.0", path = "../../identity", features = ["peerid"] }
16+
void = "1"
17+
18+
[dev-dependencies]
19+
async-std = { version = "1.12.0", features = ["attributes"] }
20+
libp2p-swarm-derive = { path = "../../swarm-derive" }
21+
libp2p-swarm-test = { path = "../../swarm-test" }

0 commit comments

Comments
 (0)