Skip to content

Commit 858a4cd

Browse files
authored
chore: identify::Config fields private (#5663)
## Description Closes #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
1 parent 5179d78 commit 858a4cd

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" }
8484
libp2p-dns = { version = "0.42.0", path = "transports/dns" }
8585
libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" }
8686
libp2p-gossipsub = { version = "0.48.0", path = "protocols/gossipsub" }
87-
libp2p-identify = { version = "0.45.1", path = "protocols/identify" }
87+
libp2p-identify = { version = "0.46.0", path = "protocols/identify" }
8888
libp2p-identity = { version = "0.2.9" }
8989
libp2p-kad = { version = "0.47.0", path = "protocols/kad" }
9090
libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" }

protocols/identify/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.46.0
2+
3+
- Make `identify::Config` fields private and add getter functions.
4+
See [PR 5663](https://github.com/libp2p/rust-libp2p/pull/5663).
5+
16
## 0.45.1
27

38
- Add `hide_listen_addrs` option to prevent leaking (local) listen addresses.

protocols/identify/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-identify"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "Nodes identification protocol for libp2p"
6-
version = "0.45.1"
6+
version = "0.46.0"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

protocols/identify/src/behaviour.rs

+42-7
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,20 @@ pub struct Behaviour {
117117
pub struct Config {
118118
/// Application-specific version of the protocol family used by the peer,
119119
/// e.g. `ipfs/1.0.0` or `polkadot/1.0.0`.
120-
pub protocol_version: String,
120+
protocol_version: String,
121121
/// The public key of the local node. To report on the wire.
122-
pub local_public_key: PublicKey,
122+
local_public_key: PublicKey,
123123
/// Name and version of the local peer implementation, similar to the
124124
/// `User-Agent` header in the HTTP protocol.
125125
///
126126
/// Defaults to `rust-libp2p/<libp2p-identify-version>`.
127-
pub agent_version: String,
127+
agent_version: String,
128128
/// The interval at which identification requests are sent to
129129
/// the remote on established connections after the first request,
130130
/// i.e. the delay between identification requests.
131131
///
132132
/// Defaults to 5 minutes.
133-
pub interval: Duration,
133+
interval: Duration,
134134

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

145145
/// How many entries of discovered peers to keep before we discard
146146
/// the least-recently used one.
147147
///
148148
/// Disabled by default.
149-
pub cache_size: usize,
149+
cache_size: usize,
150150

151151
/// Whether to include our listen addresses in our responses. If enabled,
152152
/// we will effectively only share our external addresses.
153153
///
154154
/// Disabled by default.
155-
pub hide_listen_addrs: bool,
155+
hide_listen_addrs: bool,
156156
}
157157

158158
impl Config {
@@ -202,6 +202,41 @@ impl Config {
202202
self.hide_listen_addrs = b;
203203
self
204204
}
205+
206+
/// Get the protocol version of the Config.
207+
pub fn protocol_version(&self) -> &str {
208+
&self.protocol_version
209+
}
210+
211+
/// Get the local public key of the Config.
212+
pub fn local_public_key(&self) -> &PublicKey {
213+
&self.local_public_key
214+
}
215+
216+
/// Get the agent version of the Config.
217+
pub fn agent_version(&self) -> &str {
218+
&self.agent_version
219+
}
220+
221+
/// Get the interval of the Config.
222+
pub fn interval(&self) -> Duration {
223+
self.interval
224+
}
225+
226+
/// Get the push listen address updates boolean value of the Config.
227+
pub fn push_listen_addr_updates(&self) -> bool {
228+
self.push_listen_addr_updates
229+
}
230+
231+
/// Get the cache size of the Config.
232+
pub fn cache_size(&self) -> usize {
233+
self.cache_size
234+
}
235+
236+
/// Get the hide listen address boolean value of the Config.
237+
pub fn hide_listen_addrs(&self) -> bool {
238+
self.hide_listen_addrs
239+
}
205240
}
206241

207242
impl Behaviour {

0 commit comments

Comments
 (0)