Skip to content

Commit

Permalink
chore: identify::Config fields private (libp2p#5663)
Browse files Browse the repository at this point in the history
## Description

Closes libp2p#5660 

## Change checklist

- [x] I have performed a self-review of my own code
- [x] I have made corresponding changes to the documentation
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] A changelog entry has been made in the appropriate crates
  • Loading branch information
kamuik16 authored Nov 6, 2024
1 parent 5179d78 commit 858a4cd
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ 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.48.0", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.45.1", path = "protocols/identify" }
libp2p-identify = { version = "0.46.0", path = "protocols/identify" }
libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.47.0", path = "protocols/kad" }
libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" }
Expand Down
5 changes: 5 additions & 0 deletions protocols/identify/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.46.0

- Make `identify::Config` fields private and add getter functions.
See [PR 5663](https://github.com/libp2p/rust-libp2p/pull/5663).

## 0.45.1

- Add `hide_listen_addrs` option to prevent leaking (local) listen addresses.
Expand Down
2 changes: 1 addition & 1 deletion protocols/identify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-identify"
edition = "2021"
rust-version = { workspace = true }
description = "Nodes identification protocol for libp2p"
version = "0.45.1"
version = "0.46.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
49 changes: 42 additions & 7 deletions protocols/identify/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ pub struct Behaviour {
pub struct Config {
/// Application-specific version of the protocol family used by the peer,
/// e.g. `ipfs/1.0.0` or `polkadot/1.0.0`.
pub protocol_version: String,
protocol_version: String,
/// The public key of the local node. To report on the wire.
pub local_public_key: PublicKey,
local_public_key: PublicKey,
/// Name and version of the local peer implementation, similar to the
/// `User-Agent` header in the HTTP protocol.
///
/// Defaults to `rust-libp2p/<libp2p-identify-version>`.
pub agent_version: String,
agent_version: String,
/// The interval at which identification requests are sent to
/// the remote on established connections after the first request,
/// i.e. the delay between identification requests.
///
/// Defaults to 5 minutes.
pub interval: Duration,
interval: Duration,

/// Whether new or expired listen addresses of the local node should
/// trigger an active push of an identify message to all connected peers.
Expand All @@ -140,19 +140,19 @@ pub struct Config {
/// i.e. before the next periodic identify request with each peer.
///
/// Disabled by default.
pub push_listen_addr_updates: bool,
push_listen_addr_updates: bool,

/// How many entries of discovered peers to keep before we discard
/// the least-recently used one.
///
/// Disabled by default.
pub cache_size: usize,
cache_size: usize,

/// Whether to include our listen addresses in our responses. If enabled,
/// we will effectively only share our external addresses.
///
/// Disabled by default.
pub hide_listen_addrs: bool,
hide_listen_addrs: bool,
}

impl Config {
Expand Down Expand Up @@ -202,6 +202,41 @@ impl Config {
self.hide_listen_addrs = b;
self
}

/// Get the protocol version of the Config.
pub fn protocol_version(&self) -> &str {
&self.protocol_version
}

/// Get the local public key of the Config.
pub fn local_public_key(&self) -> &PublicKey {
&self.local_public_key
}

/// Get the agent version of the Config.
pub fn agent_version(&self) -> &str {
&self.agent_version
}

/// Get the interval of the Config.
pub fn interval(&self) -> Duration {
self.interval
}

/// Get the push listen address updates boolean value of the Config.
pub fn push_listen_addr_updates(&self) -> bool {
self.push_listen_addr_updates
}

/// Get the cache size of the Config.
pub fn cache_size(&self) -> usize {
self.cache_size
}

/// Get the hide listen address boolean value of the Config.
pub fn hide_listen_addrs(&self) -> bool {
self.hide_listen_addrs
}
}

impl Behaviour {
Expand Down

0 comments on commit 858a4cd

Please sign in to comment.