Skip to content

Commit 19d5dd4

Browse files
feat(transports/unix-stream): add
Ripped 100% off transports/tcp Uses proposed encoding from multiformats/multiaddr#174 (comment)
1 parent 00e0d29 commit 19d5dd4

File tree

12 files changed

+1071
-6
lines changed

12 files changed

+1071
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [`libp2p-pnet` CHANGELOG](transports/pnet/CHANGELOG.md)
3232
- [`libp2p-quic` CHANGELOG](transports/quic/CHANGELOG.md)
3333
- [`libp2p-tcp` CHANGELOG](transports/tcp/CHANGELOG.md)
34+
- [`libp2p-unix-stream` CHANGELOG](transports/unix-stream/CHANGELOG.md)
3435
- [`libp2p-tls` CHANGELOG](transports/tls/CHANGELOG.md)
3536
- [`libp2p-uds` CHANGELOG](transports/uds/CHANGELOG.md)
3637
- [`libp2p-wasm-ext` CHANGELOG](transports/wasm-ext/CHANGELOG.md)

Cargo.lock

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ members = [
5858
"transports/pnet",
5959
"transports/quic",
6060
"transports/tcp",
61+
"transports/unix-stream",
6162
"transports/tls",
6263
"transports/uds",
6364
"transports/webrtc-websys",

libp2p/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ full = [
4141
"secp256k1",
4242
"serde",
4343
"tcp",
44+
"unix-stream",
4445
"tls",
4546
"tokio",
4647
"uds",
@@ -53,7 +54,7 @@ full = [
5354
"upnp",
5455
]
5556

56-
async-std = ["libp2p-swarm/async-std", "libp2p-tcp?/async-io", "libp2p-dns?/async-std"]
57+
async-std = ["libp2p-swarm/async-std", "libp2p-tcp?/async-io", "libp2p-unix-stream?/async-io", "libp2p-dns?/async-std"]
5758
autonat = ["dep:libp2p-autonat"]
5859
cbor = ["libp2p-request-response?/cbor"]
5960
dcutr = ["dep:libp2p-dcutr", "libp2p-metrics?/dcutr"]
@@ -82,8 +83,9 @@ rsa = ["libp2p-identity/rsa"]
8283
secp256k1 = ["libp2p-identity/secp256k1"]
8384
serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"]
8485
tcp = ["dep:libp2p-tcp"]
86+
unix-stream = ["dep:libp2p-unix-stream"]
8587
tls = ["dep:libp2p-tls"]
86-
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"]
88+
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-unix-stream?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"]
8789
uds = ["dep:libp2p-uds"]
8890
wasm-bindgen = ["futures-timer/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
8991
webrtc-websys = ['dep:libp2p-webrtc-websys']
@@ -137,6 +139,7 @@ libp2p-mdns = { workspace = true, optional = true }
137139
libp2p-memory-connection-limits = { workspace = true, optional = true }
138140
libp2p-quic = { workspace = true, optional = true }
139141
libp2p-tcp = { workspace = true, optional = true }
142+
libp2p-unix-stream = { workspace = true, optional = true }
140143
libp2p-tls = { workspace = true, optional = true }
141144
libp2p-uds = { workspace = true, optional = true }
142145
libp2p-upnp = { workspace = true, optional = true }

libp2p/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ pub use libp2p_swarm as swarm;
112112
#[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
113113
#[doc(inline)]
114114
pub use libp2p_tcp as tcp;
115+
#[cfg(feature = "unix-stream")]
116+
#[cfg(unix)]
117+
#[cfg_attr(docsrs, doc(cfg(feature = "unix-stream")))]
118+
#[doc(inline)]
119+
pub use libp2p_unix_stream as unix_stream;
115120
#[cfg(feature = "tls")]
116121
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
117122
#[cfg(not(target_arch = "wasm32"))]

transports/tcp/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ where
402402
(Err(err), _) => return Err(err),
403403
};
404404

405-
let stream = T::new_stream(socket.into()).await?;
406-
Ok(stream)
405+
T::new_stream(socket.into()).await
407406
}
408407
.boxed())
409408
}

transports/unix-stream/CHANGELOG.md

Whitespace-only changes.

transports/unix-stream/Cargo.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[package]
2+
name = "libp2p-unix-stream"
3+
edition.workspace = true
4+
rust-version = { workspace = true }
5+
description = "UNIX-domain stream socket transport protocol for libp2p"
6+
version = "0.43.0"
7+
authors = ["Parity Technologies <[email protected]>"]
8+
license = "MIT"
9+
repository = "https://github.com/libp2p/rust-libp2p"
10+
keywords = ["peer-to-peer", "libp2p", "networking"]
11+
categories = ["network-programming", "asynchronous"]
12+
13+
[dependencies]
14+
async-io = { version = "2.3.3", optional = true }
15+
futures = { workspace = true }
16+
futures-timer = "3.0"
17+
libp2p-core = { workspace = true }
18+
percent-encoding-rfc3986 = "0.1"
19+
tokio = { workspace = true, default-features = false, features = ["net"], optional = true }
20+
tracing = { workspace = true }
21+
22+
[features]
23+
tokio = ["dep:tokio"]
24+
async-io = ["dep:async-io"]
25+
26+
[dev-dependencies]
27+
async-std = { version = "1.6.5", features = ["attributes"] }
28+
tokio = { workspace = true, features = ["full"] }
29+
tracing-subscriber = { workspace = true, features = ["env-filter"] }
30+
31+
# Passing arguments to the docsrs builder in order to properly document cfg's.
32+
# More information: https://docs.rs/about/builds#cross-compiling
33+
[package.metadata.docs.rs]
34+
all-features = true
35+
36+
37+
[lints]
38+
workspace = true

0 commit comments

Comments
 (0)