mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 11:02:12 +00:00
Some fixes to #[cfg] regarding Wasi (#1633)
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
This commit is contained in:
parent
826f5130cd
commit
79ff1e4d31
@ -82,7 +82,7 @@ pin-project = "0.4.17"
|
|||||||
smallvec = "1.0"
|
smallvec = "1.0"
|
||||||
wasm-timer = "0.2.4"
|
wasm-timer = "0.2.4"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
|
[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
|
||||||
libp2p-deflate = { version = "0.19.2", path = "protocols/deflate", optional = true }
|
libp2p-deflate = { version = "0.19.2", path = "protocols/deflate", optional = true }
|
||||||
libp2p-dns = { version = "0.19.0", path = "transports/dns", optional = true }
|
libp2p-dns = { version = "0.19.0", path = "transports/dns", optional = true }
|
||||||
libp2p-mdns = { version = "0.19.2", path = "protocols/mdns", optional = true }
|
libp2p-mdns = { version = "0.19.2", path = "protocols/mdns", optional = true }
|
||||||
|
@ -35,7 +35,7 @@ unsigned-varint = "0.4"
|
|||||||
void = "1"
|
void = "1"
|
||||||
zeroize = "1"
|
zeroize = "1"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
ring = { version = "0.16.9", features = ["alloc", "std"], default-features = false }
|
ring = { version = "0.16.9", features = ["alloc", "std"], default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
//! A node's network identity keys.
|
//! A node's network identity keys.
|
||||||
|
|
||||||
pub mod ed25519;
|
pub mod ed25519;
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub mod rsa;
|
pub mod rsa;
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
pub mod secp256k1;
|
pub mod secp256k1;
|
||||||
@ -52,7 +52,7 @@ use crate::{PeerId, keys_proto};
|
|||||||
pub enum Keypair {
|
pub enum Keypair {
|
||||||
/// An Ed25519 keypair.
|
/// An Ed25519 keypair.
|
||||||
Ed25519(ed25519::Keypair),
|
Ed25519(ed25519::Keypair),
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
/// An RSA keypair.
|
/// An RSA keypair.
|
||||||
Rsa(rsa::Keypair),
|
Rsa(rsa::Keypair),
|
||||||
/// A Secp256k1 keypair.
|
/// A Secp256k1 keypair.
|
||||||
@ -76,7 +76,7 @@ impl Keypair {
|
|||||||
/// format (i.e. unencrypted) as defined in [RFC5208].
|
/// format (i.e. unencrypted) as defined in [RFC5208].
|
||||||
///
|
///
|
||||||
/// [RFC5208]: https://tools.ietf.org/html/rfc5208#section-5
|
/// [RFC5208]: https://tools.ietf.org/html/rfc5208#section-5
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub fn rsa_from_pkcs8(pkcs8_der: &mut [u8]) -> Result<Keypair, DecodingError> {
|
pub fn rsa_from_pkcs8(pkcs8_der: &mut [u8]) -> Result<Keypair, DecodingError> {
|
||||||
rsa::Keypair::from_pkcs8(pkcs8_der).map(Keypair::Rsa)
|
rsa::Keypair::from_pkcs8(pkcs8_der).map(Keypair::Rsa)
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ impl Keypair {
|
|||||||
use Keypair::*;
|
use Keypair::*;
|
||||||
match self {
|
match self {
|
||||||
Ed25519(ref pair) => Ok(pair.sign(msg)),
|
Ed25519(ref pair) => Ok(pair.sign(msg)),
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
Rsa(ref pair) => pair.sign(msg),
|
Rsa(ref pair) => pair.sign(msg),
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
Secp256k1(ref pair) => pair.secret().sign(msg)
|
Secp256k1(ref pair) => pair.secret().sign(msg)
|
||||||
@ -109,7 +109,7 @@ impl Keypair {
|
|||||||
use Keypair::*;
|
use Keypair::*;
|
||||||
match self {
|
match self {
|
||||||
Ed25519(pair) => PublicKey::Ed25519(pair.public()),
|
Ed25519(pair) => PublicKey::Ed25519(pair.public()),
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
Rsa(pair) => PublicKey::Rsa(pair.public()),
|
Rsa(pair) => PublicKey::Rsa(pair.public()),
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
Secp256k1(pair) => PublicKey::Secp256k1(pair.public().clone()),
|
Secp256k1(pair) => PublicKey::Secp256k1(pair.public().clone()),
|
||||||
@ -122,7 +122,7 @@ impl Keypair {
|
|||||||
pub enum PublicKey {
|
pub enum PublicKey {
|
||||||
/// A public Ed25519 key.
|
/// A public Ed25519 key.
|
||||||
Ed25519(ed25519::PublicKey),
|
Ed25519(ed25519::PublicKey),
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
/// A public RSA key.
|
/// A public RSA key.
|
||||||
Rsa(rsa::PublicKey),
|
Rsa(rsa::PublicKey),
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
@ -139,7 +139,7 @@ impl PublicKey {
|
|||||||
use PublicKey::*;
|
use PublicKey::*;
|
||||||
match self {
|
match self {
|
||||||
Ed25519(pk) => pk.verify(msg, sig),
|
Ed25519(pk) => pk.verify(msg, sig),
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
Rsa(pk) => pk.verify(msg, sig),
|
Rsa(pk) => pk.verify(msg, sig),
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
Secp256k1(pk) => pk.verify(msg, sig)
|
Secp256k1(pk) => pk.verify(msg, sig)
|
||||||
@ -157,7 +157,7 @@ impl PublicKey {
|
|||||||
r#type: keys_proto::KeyType::Ed25519 as i32,
|
r#type: keys_proto::KeyType::Ed25519 as i32,
|
||||||
data: key.encode().to_vec()
|
data: key.encode().to_vec()
|
||||||
},
|
},
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
PublicKey::Rsa(key) =>
|
PublicKey::Rsa(key) =>
|
||||||
keys_proto::PublicKey {
|
keys_proto::PublicKey {
|
||||||
r#type: keys_proto::KeyType::Rsa as i32,
|
r#type: keys_proto::KeyType::Rsa as i32,
|
||||||
@ -192,11 +192,11 @@ impl PublicKey {
|
|||||||
keys_proto::KeyType::Ed25519 => {
|
keys_proto::KeyType::Ed25519 => {
|
||||||
ed25519::PublicKey::decode(&pubkey.data).map(PublicKey::Ed25519)
|
ed25519::PublicKey::decode(&pubkey.data).map(PublicKey::Ed25519)
|
||||||
},
|
},
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
keys_proto::KeyType::Rsa => {
|
keys_proto::KeyType::Rsa => {
|
||||||
rsa::PublicKey::decode_x509(&pubkey.data).map(PublicKey::Rsa)
|
rsa::PublicKey::decode_x509(&pubkey.data).map(PublicKey::Rsa)
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "emscripten", target_os = "unknown"))]
|
#[cfg(target_arch = "wasm32")]
|
||||||
keys_proto::KeyType::Rsa => {
|
keys_proto::KeyType::Rsa => {
|
||||||
log::debug!("support for RSA was disabled at compile-time");
|
log::debug!("support for RSA was disabled at compile-time");
|
||||||
Err(DecodingError::new("Unsupported"))
|
Err(DecodingError::new("Unsupported"))
|
||||||
|
@ -20,10 +20,10 @@ static_assertions = "1"
|
|||||||
x25519-dalek = "0.6.0"
|
x25519-dalek = "0.6.0"
|
||||||
zeroize = "1"
|
zeroize = "1"
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
snow = { version = "0.7.0", features = ["ring-resolver"], default-features = false }
|
snow = { version = "0.7.0", features = ["ring-resolver"], default-features = false }
|
||||||
|
|
||||||
[target.'cfg(target_os = "unknown")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
snow = { version = "0.7.0", features = ["default-resolver"], default-features = false }
|
snow = { version = "0.7.0", features = ["default-resolver"], default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -229,22 +229,22 @@ impl snow::resolvers::CryptoResolver for Resolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_hash(&self, choice: &snow::params::HashChoice) -> Option<Box<dyn snow::types::Hash>> {
|
fn resolve_hash(&self, choice: &snow::params::HashChoice) -> Option<Box<dyn snow::types::Hash>> {
|
||||||
#[cfg(target_os = "unknown")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
{
|
{
|
||||||
snow::resolvers::DefaultResolver.resolve_hash(choice)
|
snow::resolvers::DefaultResolver.resolve_hash(choice)
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "unknown"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
{
|
{
|
||||||
snow::resolvers::RingResolver.resolve_hash(choice)
|
snow::resolvers::RingResolver.resolve_hash(choice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_cipher(&self, choice: &snow::params::CipherChoice) -> Option<Box<dyn snow::types::Cipher>> {
|
fn resolve_cipher(&self, choice: &snow::params::CipherChoice) -> Option<Box<dyn snow::types::Cipher>> {
|
||||||
#[cfg(target_os = "unknown")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
{
|
{
|
||||||
snow::resolvers::DefaultResolver.resolve_cipher(choice)
|
snow::resolvers::DefaultResolver.resolve_cipher(choice)
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "unknown"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
{
|
{
|
||||||
snow::resolvers::RingResolver.resolve_cipher(choice)
|
snow::resolvers::RingResolver.resolve_cipher(choice)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
//! helps you with.
|
//! helps you with.
|
||||||
|
|
||||||
use crate::error::SecioError;
|
use crate::error::SecioError;
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
use ring::digest;
|
use ring::digest;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use crate::stream_cipher::Cipher;
|
use crate::stream_cipher::Cipher;
|
||||||
@ -204,7 +204,7 @@ pub fn select_digest(r: Ordering, ours: &str, theirs: &str) -> Result<Digest, Se
|
|||||||
Err(SecioError::NoSupportIntersection)
|
Err(SecioError::NoSupportIntersection)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
impl Into<&'static digest::Algorithm> for Digest {
|
impl Into<&'static digest::Algorithm> for Digest {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> &'static digest::Algorithm {
|
fn into(self) -> &'static digest::Algorithm {
|
||||||
|
@ -24,10 +24,10 @@ use futures::prelude::*;
|
|||||||
use crate::SecioError;
|
use crate::SecioError;
|
||||||
|
|
||||||
#[path = "exchange/impl_ring.rs"]
|
#[path = "exchange/impl_ring.rs"]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
mod platform;
|
mod platform;
|
||||||
#[path = "exchange/impl_webcrypto.rs"]
|
#[path = "exchange/impl_webcrypto.rs"]
|
||||||
#[cfg(any(target_os = "emscripten", target_os = "unknown"))]
|
#[cfg(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown"))]
|
||||||
mod platform;
|
mod platform;
|
||||||
|
|
||||||
/// Possible key agreement algorithms.
|
/// Possible key agreement algorithms.
|
||||||
|
@ -371,7 +371,7 @@ mod tests {
|
|||||||
use futures::{prelude::*, channel::oneshot};
|
use futures::{prelude::*, channel::oneshot};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
fn handshake_with_self_succeeds_rsa() {
|
fn handshake_with_self_succeeds_rsa() {
|
||||||
let key1 = {
|
let key1 = {
|
||||||
let mut private = include_bytes!("../tests/test-rsa-private-key.pk8").to_vec();
|
let mut private = include_bytes!("../tests/test-rsa-private-key.pk8").to_vec();
|
||||||
|
24
src/lib.rs
24
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-async-std", feature = "secio", feature = "yamux"))] {
|
//! # #[cfg(all(not(any(target_os = "emscripten", target_os = "wasi", 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());
|
||||||
@ -166,12 +166,12 @@ pub use multihash;
|
|||||||
pub use libp2p_core as core;
|
pub use libp2p_core as core;
|
||||||
#[cfg(feature = "deflate")]
|
#[cfg(feature = "deflate")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "deflate")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "deflate")))]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use libp2p_deflate as deflate;
|
pub use libp2p_deflate as deflate;
|
||||||
#[cfg(feature = "dns")]
|
#[cfg(feature = "dns")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use libp2p_dns as dns;
|
pub use libp2p_dns as dns;
|
||||||
#[cfg(feature = "identify")]
|
#[cfg(feature = "identify")]
|
||||||
@ -196,7 +196,7 @@ pub use libp2p_gossipsub as gossipsub;
|
|||||||
pub use libp2p_mplex as mplex;
|
pub use libp2p_mplex as mplex;
|
||||||
#[cfg(feature = "mdns")]
|
#[cfg(feature = "mdns")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "mdns")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "mdns")))]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use libp2p_mdns as mdns;
|
pub use libp2p_mdns as mdns;
|
||||||
#[cfg(feature = "noise")]
|
#[cfg(feature = "noise")]
|
||||||
@ -219,7 +219,7 @@ pub use libp2p_secio as secio;
|
|||||||
pub use libp2p_swarm as swarm;
|
pub use libp2p_swarm as swarm;
|
||||||
#[cfg(any(feature = "tcp-async-std", feature = "tcp-tokio"))]
|
#[cfg(any(feature = "tcp-async-std", feature = "tcp-tokio"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "tcp-async-std", feature = "tcp-tokio"))))]
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "tcp-async-std", feature = "tcp-tokio"))))]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use libp2p_tcp as tcp;
|
pub use libp2p_tcp as tcp;
|
||||||
#[cfg(feature = "uds")]
|
#[cfg(feature = "uds")]
|
||||||
@ -232,7 +232,7 @@ pub use libp2p_uds as uds;
|
|||||||
pub use libp2p_wasm_ext as wasm_ext;
|
pub use libp2p_wasm_ext as wasm_ext;
|
||||||
#[cfg(feature = "websocket")]
|
#[cfg(feature = "websocket")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "websocket")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "websocket")))]
|
||||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))]
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use libp2p_websocket as websocket;
|
pub use libp2p_websocket as websocket;
|
||||||
#[cfg(feature = "yamux")]
|
#[cfg(feature = "yamux")]
|
||||||
@ -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")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
#[cfg(all(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))))]
|
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), 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")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
#[cfg(all(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux"))))]
|
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), 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>
|
||||||
{
|
{
|
||||||
@ -309,8 +309,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")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux", feature = "pnet"))]
|
#[cfg(all(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux", feature = "pnet"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), feature = "websocket", feature = "secio", feature = "mplex", feature = "yamux", feature = "pnet"))))]
|
#[cfg_attr(docsrs, doc(cfg(all(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")), any(feature = "tcp-async-std", feature = "tcp-tokio"), 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>
|
||||||
{
|
{
|
||||||
|
@ -9,14 +9,14 @@ repository = "https://github.com/libp2p/rust-libp2p"
|
|||||||
keywords = ["peer-to-peer", "libp2p", "networking"]
|
keywords = ["peer-to-peer", "libp2p", "networking"]
|
||||||
categories = ["network-programming", "asynchronous"]
|
categories = ["network-programming", "asynchronous"]
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(any(target_os = "emscripten", target_os = "unknown"))))'.dependencies]
|
[target.'cfg(all(unix, not(target_os = "emscripten")))'.dependencies]
|
||||||
async-std = { version = "1.6.2", optional = true }
|
async-std = { version = "1.6.2", optional = true }
|
||||||
libp2p-core = { version = "0.19.2", path = "../../core" }
|
libp2p-core = { version = "0.19.2", path = "../../core" }
|
||||||
log = "0.4.1"
|
log = "0.4.1"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
tokio = { version = "0.2", default-features = false, features = ["uds"], optional = true }
|
tokio = { version = "0.2", default-features = false, features = ["uds"], optional = true }
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(any(target_os = "emscripten", target_os = "unknown"))))'.dev-dependencies]
|
[target.'cfg(all(unix, not(target_os = "emscripten")))'.dev-dependencies]
|
||||||
tempfile = "3.0"
|
tempfile = "3.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
//! The `UdsConfig` structs implements the `Transport` trait of the `core` library. See the
|
//! The `UdsConfig` 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.
|
//! documentation of `core` and of libp2p in general to learn how to use the `Transport` trait.
|
||||||
|
|
||||||
#![cfg(all(unix, not(any(target_os = "emscripten", target_os = "unknown"))))]
|
#![cfg(all(unix, not(target_os = "emscripten")))]
|
||||||
#![cfg_attr(docsrs, doc(cfg(all(unix, not(any(target_os = "emscripten", target_os = "unknown"))))))]
|
#![cfg_attr(docsrs, doc(cfg(all(unix, not(target_os = "emscripten")))))]
|
||||||
|
|
||||||
use futures::{prelude::*, future::{BoxFuture, Ready}};
|
use futures::{prelude::*, future::{BoxFuture, Ready}};
|
||||||
use futures::stream::BoxStream;
|
use futures::stream::BoxStream;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user