diff --git a/Cargo.lock b/Cargo.lock index 421ae65f53f..cf9c09a3138 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3161,7 +3161,7 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.43.0" +version = "0.43.1" dependencies = [ "futures", "libp2p-core", diff --git a/Cargo.toml b/Cargo.toml index 36c148cffee..6557a33b025 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-s libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" } libp2p-tcp = { version = "0.44.0", path = "transports/tcp" } libp2p-tls = { version = "0.6.2", path = "transports/tls" } -libp2p-uds = { version = "0.43.0", path = "transports/uds" } +libp2p-uds = { version = "0.43.1", path = "transports/uds" } libp2p-upnp = { version = "0.6.0", path = "protocols/upnp" } libp2p-webrtc = { version = "0.9.0-alpha.2", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" } diff --git a/transports/uds/CHANGELOG.md b/transports/uds/CHANGELOG.md index 92d2f9a4c76..911dab70eca 100644 --- a/transports/uds/CHANGELOG.md +++ b/transports/uds/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.43.1 + +- Rename Config to match naming convention in [discussion 2174](https://github.com/libp2p/rust-libp2p/discussions/2174). + See [PR 6190](https://github.com/libp2p/rust-libp2p/pull/6190). + ## 0.43.0 - Remove `async-std` support. diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index c5f748d933a..82356512f8f 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-uds" edition.workspace = true rust-version = { workspace = true } description = "Unix domain sockets transport for libp2p" -version = "0.43.0" +version = "0.43.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/uds/src/lib.rs b/transports/uds/src/lib.rs index b69aa9d6243..082bc831bc9 100644 --- a/transports/uds/src/lib.rs +++ b/transports/uds/src/lib.rs @@ -26,9 +26,9 @@ //! //! # Usage //! -//! The `UdsConfig` transport supports multiaddresses of the form `/unix//tmp/foo`. +//! The `Config` transport supports multiaddresses of the form `/unix//tmp/foo`. //! -//! The `UdsConfig` structs implements the `Transport` trait of the `core` library. See the +//! The `Config` structs implements the `Transport` trait of the `core` library. See the //! documentation of `core` and of libp2p in general to learn how to use the `Transport` trait. #![cfg(all(unix, not(target_os = "emscripten"), feature = "tokio"))] @@ -62,28 +62,28 @@ pub type Listener = BoxStream< >; macro_rules! codegen { - ($feature_name:expr, $uds_config:ident, $build_listener:expr, $unix_stream:ty, $($mut_or_not:tt)*) => { + ($feature_name:expr, $config:ident, $build_listener:expr, $unix_stream:ty, $($mut_or_not:tt)*) => { /// Represents the configuration for a Unix domain sockets transport capability for libp2p. - pub struct $uds_config { + pub struct $config { listeners: VecDeque<(ListenerId, Listener)>, } - impl $uds_config { + impl $config { /// Creates a new configuration object for Unix domain sockets. - pub fn new() -> $uds_config { - $uds_config { + pub fn new() -> $config { + $config { listeners: VecDeque::new(), } } } - impl Default for $uds_config { + impl Default for $config { fn default() -> Self { Self::new() } } - impl Transport for $uds_config { + impl Transport for $config { type Output = $unix_stream; type Error = io::Error; type ListenerUpgrade = Ready>; @@ -204,11 +204,16 @@ macro_rules! codegen { #[cfg(feature = "tokio")] codegen!( "tokio", - TokioUdsConfig, + Config, |addr| async move { tokio::net::UnixListener::bind(&addr) }, tokio::net::UnixStream, ); +// Deprecated type alias for backward compatibility +#[cfg(feature = "tokio")] +#[deprecated(since = "0.43.1", note = "Use `libp2p::uds::Config` instead")] +pub type TokioUdsConfig = Config; + /// Turns a `Multiaddr` containing a single `Unix` component into a path. /// /// Also returns an error if the path is not absolute, as we don't want to dial/listen on relative @@ -243,7 +248,8 @@ mod tests { }; use tokio::io::{AsyncReadExt, AsyncWriteExt}; - use super::{multiaddr_to_path, TokioUdsConfig}; + use super::multiaddr_to_path; + use crate::Config; #[test] fn multiaddr_to_path_conversion() { @@ -272,7 +278,7 @@ mod tests { let (tx, rx) = oneshot::channel(); let listener = async move { - let mut transport = TokioUdsConfig::new().boxed(); + let mut transport = Config::new().boxed(); transport.listen_on(ListenerId::next(), addr).unwrap(); let listen_addr = transport @@ -296,7 +302,7 @@ mod tests { }; let dialer = async move { - let mut uds = TokioUdsConfig::new(); + let mut uds = Config::new(); let addr = rx.await.unwrap(); let mut socket = uds .dial( @@ -318,7 +324,7 @@ mod tests { #[test] #[ignore] // TODO: for the moment unix addresses fail to parse fn larger_addr_denied() { - let mut uds = TokioUdsConfig::new(); + let mut uds = Config::new(); let addr = "/unix//foo/bar".parse::().unwrap(); assert!(uds.listen_on(ListenerId::next(), addr).is_err());