mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-15 11:01:21 +00:00
Extend feature-flags to allow choosing runtime for libp2p-tcp (#1471)
* Extend feature-flags to allow choosing runtime for libp2p-tcp * Added CHANGELOG entry Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
@ -40,6 +40,11 @@
|
|||||||
an event.
|
an event.
|
||||||
[PR 1567](https://github.com/libp2p/rust-libp2p/pull/1567)
|
[PR 1567](https://github.com/libp2p/rust-libp2p/pull/1567)
|
||||||
|
|
||||||
|
- `libp2p-tcp`, `libp2p`: Made the `libp2p-tcp/async-std` feature flag
|
||||||
|
disabled by default, and split the `libp2p/tcp` feature in two:
|
||||||
|
`tcp-async-std` and `tcp-tokio`. `tcp-async-std` is still enabled by default.
|
||||||
|
[PR 1471](https://github.com/libp2p/rust-libp2p/pull/1471)
|
||||||
|
|
||||||
- `libp2p-tcp`: On listeners started with an IPv6 multi-address the socket
|
- `libp2p-tcp`: On listeners started with an IPv6 multi-address the socket
|
||||||
option `IPV6_V6ONLY` is set to true. Instead of relying on IPv4-mapped IPv6
|
option `IPV6_V6ONLY` is set to true. Instead of relying on IPv4-mapped IPv6
|
||||||
address support, two listeners can be started if IPv4 and IPv6 should both
|
address support, two listeners can be started if IPv4 and IPv6 should both
|
||||||
|
@ -25,7 +25,7 @@ default = [
|
|||||||
"pnet",
|
"pnet",
|
||||||
"secio",
|
"secio",
|
||||||
"secp256k1",
|
"secp256k1",
|
||||||
"tcp",
|
"tcp-async-std",
|
||||||
"uds",
|
"uds",
|
||||||
"wasm-ext",
|
"wasm-ext",
|
||||||
"websocket",
|
"websocket",
|
||||||
@ -44,7 +44,8 @@ ping = ["libp2p-ping"]
|
|||||||
plaintext = ["libp2p-plaintext"]
|
plaintext = ["libp2p-plaintext"]
|
||||||
pnet = ["libp2p-pnet"]
|
pnet = ["libp2p-pnet"]
|
||||||
secio = ["libp2p-secio"]
|
secio = ["libp2p-secio"]
|
||||||
tcp = ["libp2p-tcp"]
|
tcp-async-std = ["libp2p-tcp", "libp2p-tcp/async-std"]
|
||||||
|
tcp-tokio = ["libp2p-tcp", "libp2p-tcp/tokio"]
|
||||||
uds = ["libp2p-uds"]
|
uds = ["libp2p-uds"]
|
||||||
wasm-ext = ["libp2p-wasm-ext"]
|
wasm-ext = ["libp2p-wasm-ext"]
|
||||||
websocket = ["libp2p-websocket"]
|
websocket = ["libp2p-websocket"]
|
||||||
|
18
src/lib.rs
18
src/lib.rs
@ -85,7 +85,7 @@
|
|||||||
//! Example ([`secio`] + [`yamux`] Protocol Upgrade):
|
//! Example ([`secio`] + [`yamux`] Protocol Upgrade):
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # #[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp", feature = "secio", feature = "yamux"))] {
|
//! # #[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp-async-std", feature = "secio", feature = "yamux"))] {
|
||||||
//! use libp2p::{Transport, core::upgrade, tcp::TcpConfig, secio::SecioConfig, identity::Keypair, yamux};
|
//! use libp2p::{Transport, core::upgrade, tcp::TcpConfig, secio::SecioConfig, identity::Keypair, yamux};
|
||||||
//! let tcp = TcpConfig::new();
|
//! let tcp = TcpConfig::new();
|
||||||
//! let secio = SecioConfig::new(Keypair::generate_ed25519());
|
//! let secio = SecioConfig::new(Keypair::generate_ed25519());
|
||||||
@ -217,8 +217,8 @@ pub use libp2p_plaintext as plaintext;
|
|||||||
pub use libp2p_secio as secio;
|
pub use libp2p_secio as secio;
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use libp2p_swarm as swarm;
|
pub use libp2p_swarm as swarm;
|
||||||
#[cfg(feature = "tcp")]
|
#[cfg(any(feature = "tcp-async-std", feature = "tcp-tokio-std"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "tcp-async-std", feature = "tcp-tokio-std"))))]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use libp2p_tcp as tcp;
|
pub use libp2p_tcp as tcp;
|
||||||
@ -266,8 +266,8 @@ pub use self::transport_ext::TransportExt;
|
|||||||
///
|
///
|
||||||
/// > **Note**: This `Transport` is not suitable for production usage, as its implementation
|
/// > **Note**: This `Transport` is not suitable for production usage, as its implementation
|
||||||
/// > reserves the right to support additional protocols or remove deprecated protocols.
|
/// > reserves the right to support additional protocols or remove deprecated protocols.
|
||||||
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp-async-std", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))))]
|
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp-async-std", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))))]
|
||||||
pub fn build_development_transport(keypair: identity::Keypair)
|
pub fn build_development_transport(keypair: identity::Keypair)
|
||||||
-> std::io::Result<impl Transport<Output = (PeerId, impl core::muxing::StreamMuxer<OutboundSubstream = impl Send, Substream = impl Send, Error = impl Into<std::io::Error>> + Send + Sync), Error = impl std::error::Error + Send, Listener = impl Send, Dial = impl Send, ListenerUpgrade = impl Send> + Clone>
|
-> std::io::Result<impl Transport<Output = (PeerId, impl core::muxing::StreamMuxer<OutboundSubstream = impl Send, Substream = impl Send, Error = impl Into<std::io::Error>> + Send + Sync), Error = impl std::error::Error + Send, Listener = impl Send, Dial = impl Send, ListenerUpgrade = impl Send> + Clone>
|
||||||
{
|
{
|
||||||
@ -280,8 +280,8 @@ pub fn build_development_transport(keypair: identity::Keypair)
|
|||||||
/// and mplex or yamux as the multiplexing layer.
|
/// and mplex or yamux as the multiplexing layer.
|
||||||
///
|
///
|
||||||
/// > **Note**: If you ever need to express the type of this `Transport`.
|
/// > **Note**: If you ever need to express the type of this `Transport`.
|
||||||
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp-async-std", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))))]
|
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp-async-std", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))))]
|
||||||
pub fn build_tcp_ws_secio_mplex_yamux(keypair: identity::Keypair)
|
pub fn build_tcp_ws_secio_mplex_yamux(keypair: identity::Keypair)
|
||||||
-> std::io::Result<impl Transport<Output = (PeerId, impl core::muxing::StreamMuxer<OutboundSubstream = impl Send, Substream = impl Send, Error = impl Into<std::io::Error>> + Send + Sync), Error = impl std::error::Error + Send, Listener = impl Send, Dial = impl Send, ListenerUpgrade = impl Send> + Clone>
|
-> std::io::Result<impl Transport<Output = (PeerId, impl core::muxing::StreamMuxer<OutboundSubstream = impl Send, Substream = impl Send, Error = impl Into<std::io::Error>> + Send + Sync), Error = impl std::error::Error + Send, Listener = impl Send, Dial = impl Send, ListenerUpgrade = impl Send> + Clone>
|
||||||
{
|
{
|
||||||
@ -306,8 +306,8 @@ pub fn build_tcp_ws_secio_mplex_yamux(keypair: identity::Keypair)
|
|||||||
/// and mplex or yamux as the multiplexing layer.
|
/// and mplex or yamux as the multiplexing layer.
|
||||||
///
|
///
|
||||||
/// > **Note**: If you ever need to express the type of this `Transport`.
|
/// > **Note**: If you ever need to express the type of this `Transport`.
|
||||||
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux", feature = "pnet"))]
|
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp-async-std", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux", feature = "pnet"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux", feature = "pnet"))))]
|
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "tcp-async-std", feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux", feature = "pnet"))))]
|
||||||
pub fn build_tcp_ws_pnet_secio_mplex_yamux(keypair: identity::Keypair, psk: PreSharedKey)
|
pub fn build_tcp_ws_pnet_secio_mplex_yamux(keypair: identity::Keypair, psk: PreSharedKey)
|
||||||
-> std::io::Result<impl Transport<Output = (PeerId, impl core::muxing::StreamMuxer<OutboundSubstream = impl Send, Substream = impl Send, Error = impl Into<std::io::Error>> + Send + Sync), Error = impl std::error::Error + Send, Listener = impl Send, Dial = impl Send, ListenerUpgrade = impl Send> + Clone>
|
-> std::io::Result<impl Transport<Output = (PeerId, impl core::muxing::StreamMuxer<OutboundSubstream = impl Send, Substream = impl Send, Error = impl Into<std::io::Error>> + Send + Sync), Error = impl std::error::Error + Send, Listener = impl Send, Dial = impl Send, ListenerUpgrade = impl Send> + Clone>
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,3 @@ libp2p-core = { version = "0.18.0", path = "../../core" }
|
|||||||
log = "0.4.1"
|
log = "0.4.1"
|
||||||
socket2 = "0.3.12"
|
socket2 = "0.3.12"
|
||||||
tokio = { version = "0.2", default-features = false, features = ["tcp"], optional = true }
|
tokio = { version = "0.2", default-features = false, features = ["tcp"], optional = true }
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["async-std"]
|
|
||||||
|
Reference in New Issue
Block a user