Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: identify::Config fields private #5663

Merged
merged 6 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.45.2", 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.45.2

- Make `identify::Config` fields private and added 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.45.2"
authors = ["Parity Technologies <[email protected]>"]
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) -> String {
kamuik16 marked this conversation as resolved.
Show resolved Hide resolved
self.protocol_version.clone()
}

/// Get the local public key of the Config.
pub fn local_public_key(&self) -> PublicKey {
kamuik16 marked this conversation as resolved.
Show resolved Hide resolved
self.local_public_key.clone()
}

/// Get the agent version of the Config.
pub fn agent_version(&self) -> String {
kamuik16 marked this conversation as resolved.
Show resolved Hide resolved
self.agent_version.clone()
}

/// 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
Loading