Skip to content

Commit

Permalink
Merge branch 'master' into feat-identify-hide-listen-addrs
Browse files Browse the repository at this point in the history
  • Loading branch information
b-zee authored Sep 5, 2024
2 parents 1eb27f2 + 5137e4e commit e892844
Show file tree
Hide file tree
Showing 20 changed files with 320 additions and 328 deletions.
9 changes: 3 additions & 6 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ asynchronous-codec = { version = "0.7.0" }
futures-bounded = { version = "0.2.4" }
futures-rustls = { version = "0.26.0", default-features = false }
libp2p = { version = "0.54.1", path = "libp2p" }
libp2p-allow-block-list = { version = "0.4.0", path = "misc/allow-block-list" }
libp2p-allow-block-list = { version = "0.4.1", path = "misc/allow-block-list" }
libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" }
libp2p-connection-limits = { version = "0.4.0", path = "misc/connection-limits" }
libp2p-core = { version = "0.42.0", path = "core" }
libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" }
libp2p-dns = { version = "0.42.0", path = "transports/dns" }
libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" }
libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" }
libp2p-gossipsub = { version = "0.47.1", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.45.1", path = "protocols/identify" }
libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.47.0", path = "protocols/kad" }
Expand Down
5 changes: 5 additions & 0 deletions FUNDING.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"opRetro": {
"projectId": "0xdf1bb03d08808e2d789f5eac8462bdc560f1bb5b0877f0cf8c66ab53a0bc2f5c"
}
}
5 changes: 2 additions & 3 deletions examples/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ license = "MIT"
release = false

[dependencies]
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
tokio = { version = "1.37.0", features = ["full"] }
futures = { workspace = true }
libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] }
libp2p = { path = "../../libp2p", features = ["identify", "noise", "tcp", "tokio", "yamux"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

Expand Down
4 changes: 2 additions & 2 deletions examples/identify/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ use libp2p::{core::multiaddr::Multiaddr, identify, noise, swarm::SwarmEvent, tcp
use std::{error::Error, time::Duration};
use tracing_subscriber::EnvFilter;

#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let _ = tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.try_init();

let mut swarm = libp2p::SwarmBuilder::with_new_identity()
.with_async_std()
.with_tokio()
.with_tcp(
tcp::Config::default(),
noise::Config::new,
Expand Down
4 changes: 1 addition & 3 deletions examples/rendezvous/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ license = "MIT"
release = false

[dependencies]
async-std = { version = "1.12", features = ["attributes"] }
async-trait = "0.1"
futures = { workspace = true }
libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] }
libp2p = { path = "../../libp2p", features = ["identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "time"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
Expand Down
5 changes: 0 additions & 5 deletions funding.json

This file was deleted.

6 changes: 6 additions & 0 deletions misc/allow-block-list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.4.1

- Add getters & setters for the allowed/blocked peers.
Return a `bool` for every "insert/remove" function, informing if a change was performed.
See [PR 5572](https://github.com/libp2p/rust-libp2p/pull/5572).

## 0.4.0

<!-- Update to libp2p-swarm v0.45.0 -->
Expand Down
2 changes: 1 addition & 1 deletion misc/allow-block-list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-allow-block-list"
edition = "2021"
rust-version = { workspace = true }
description = "Allow/block list connection management for libp2p."
version = "0.4.0"
version = "0.4.1"
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
Expand Down
66 changes: 48 additions & 18 deletions misc/allow-block-list/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,44 +94,74 @@ pub struct BlockedPeers {
}

impl Behaviour<AllowedPeers> {
/// Peers that are currently allowed.
pub fn allowed_peers(&self) -> &HashSet<PeerId> {
&self.state.peers
}

/// Allow connections to the given peer.
pub fn allow_peer(&mut self, peer: PeerId) {
self.state.peers.insert(peer);
if let Some(waker) = self.waker.take() {
waker.wake()
///
/// Returns whether the peer was newly inserted. Does nothing if the peer was already present in the set.
pub fn allow_peer(&mut self, peer: PeerId) -> bool {
let inserted = self.state.peers.insert(peer);
if inserted {
if let Some(waker) = self.waker.take() {
waker.wake()
}
}
inserted
}

/// Disallow connections to the given peer.
///
/// All active connections to this peer will be closed immediately.
pub fn disallow_peer(&mut self, peer: PeerId) {
self.state.peers.remove(&peer);
self.close_connections.push_back(peer);
if let Some(waker) = self.waker.take() {
waker.wake()
///
/// Returns whether the peer was present in the set. Does nothing if the peer was not present in the set.
pub fn disallow_peer(&mut self, peer: PeerId) -> bool {
let removed = self.state.peers.remove(&peer);
if removed {
self.close_connections.push_back(peer);
if let Some(waker) = self.waker.take() {
waker.wake()
}
}
removed
}
}

impl Behaviour<BlockedPeers> {
/// Peers that are currently blocked.
pub fn blocked_peers(&self) -> &HashSet<PeerId> {
&self.state.peers
}

/// Block connections to a given peer.
///
/// All active connections to this peer will be closed immediately.
pub fn block_peer(&mut self, peer: PeerId) {
self.state.peers.insert(peer);
self.close_connections.push_back(peer);
if let Some(waker) = self.waker.take() {
waker.wake()
///
/// Returns whether the peer was newly inserted. Does nothing if the peer was already present in the set.
pub fn block_peer(&mut self, peer: PeerId) -> bool {
let inserted = self.state.peers.insert(peer);
if inserted {
self.close_connections.push_back(peer);
if let Some(waker) = self.waker.take() {
waker.wake()
}
}
inserted
}

/// Unblock connections to a given peer.
pub fn unblock_peer(&mut self, peer: PeerId) {
self.state.peers.remove(&peer);
if let Some(waker) = self.waker.take() {
waker.wake()
///
/// Returns whether the peer was present in the set. Does nothing if the peer was not present in the set.
pub fn unblock_peer(&mut self, peer: PeerId) -> bool {
let removed = self.state.peers.remove(&peer);
if removed {
if let Some(waker) = self.waker.take() {
waker.wake()
}
}
removed
}
}

Expand Down
2 changes: 1 addition & 1 deletion misc/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.5-labs
FROM rust:1.73.0 as chef
FROM rust:1.75.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
RUN cargo install --locked --root /usr/local libp2p-lookup --version 0.6.4
WORKDIR /app
Expand Down
5 changes: 5 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.47.1

- Attempt to publish to at least mesh_n peers when flood publish is disabled.
See [PR 5578](https://github.com/libp2p/rust-libp2p/pull/5578).

## 0.47.0

<!-- Update to libp2p-swarm v0.45.0 -->
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-gossipsub"
edition = "2021"
rust-version = { workspace = true }
description = "Gossipsub protocol for libp2p"
version = "0.47.0"
version = "0.47.1"
authors = ["Age Manning <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
Loading

0 comments on commit e892844

Please sign in to comment.