Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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" }
Expand Down
5 changes: 5 additions & 0 deletions transports/uds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion transports/uds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
34 changes: 20 additions & 14 deletions transports/uds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -62,28 +62,28 @@ pub type Listener<T> = 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<Self>)>,
}

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<Result<Self::Output, Self::Error>>;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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::<Multiaddr>().unwrap();
assert!(uds.listen_on(ListenerId::next(), addr).is_err());
Expand Down
Loading