diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b058f9b..382aa5fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## secio 0.6.2 tentacle 0.6.0 + +### Features +- upgrade dependences +- impl Display for PeerId + ## secio 0.6.1 ### Features diff --git a/multiaddr/Cargo.toml b/multiaddr/Cargo.toml index ab0e64d2..8337c37a 100644 --- a/multiaddr/Cargo.toml +++ b/multiaddr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tentacle-multiaddr" -version = "0.3.3" +version = "0.3.4" authors = ["driftluo "] edition = "2021" license = "MIT" @@ -9,9 +9,9 @@ description = "Mini Implementation of multiaddr" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -unsigned-varint = "0.7" +unsigned-varint = "0.8" bytes = "1.0" -bs58 = "0.4.0" +bs58 = "0.5.0" sha2 = "0.10.0" serde = "1" diff --git a/secio/Cargo.toml b/secio/Cargo.toml index 67a23605..ab20856c 100644 --- a/secio/Cargo.toml +++ b/secio/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tentacle-secio" -version = "0.6.1" +version = "0.6.2" license = "MIT" description = "Secio encryption protocol for p2p" authors = ["piaoliu ", "Nervos Core Dev "] @@ -23,28 +23,30 @@ tokio-util = { version = "0.7.0", features = ["codec"] } log = "0.4.1" async-trait = { version = "0.1", optional = true } -molecule = "0.7.0" +molecule = "0.8.0" -unsigned-varint = "0.7" -bs58 = "0.4.0" -secp256k1 = "0.24" +unsigned-varint = "0.8" +bs58 = "0.5.0" +secp256k1 = "0.29" +rand = "0.8" [target.'cfg(unix)'.dependencies] openssl = "0.10.25" openssl-sys = "0.9" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -rand = "0.8" -ring = "0.16.5" +ring = "0.17" [target.'cfg(target_arch = "wasm32")'.dependencies] -# wait x25519-dalek upgrade rand core -rand_core = { version = "0.5" } -rand = { version = "0.7", features = ["wasm-bindgen"] } +rand_core = { version = "0.6" } +getrandom = { version = "0.2", features = ["js"] } sha2 = "0.10.0" hmac = "0.12.0" -x25519-dalek = "1.1" -chacha20poly1305 = { version = "0.10", default-features = false, features = ["alloc", "rand_core"]} +x25519-dalek = { version = "2" } +chacha20poly1305 = { version = "0.10", default-features = false, features = [ + "alloc", + "rand_core", +] } [features] openssl-vendored = ["openssl/vendored"] @@ -55,9 +57,9 @@ criterion = "0.3" tokio = { version = "1.0.0", features = ["net", "rt", "rt-multi-thread"] } sha2 = "0.10.0" hmac = "0.12.0" -x25519-dalek = "1.1" +x25519-dalek = "2" chacha20poly1305 = "0.10" -rand_core = { version = "0.5" } +rand_core = { version = "0.6" } once_cell = "1.8.0" proptest = "1" diff --git a/secio/src/codec/hmac_compat/ring_impl.rs b/secio/src/codec/hmac_compat/ring_impl.rs index 12b26ddd..dc33004c 100644 --- a/secio/src/codec/hmac_compat/ring_impl.rs +++ b/secio/src/codec/hmac_compat/ring_impl.rs @@ -9,7 +9,7 @@ impl Hmac { #[cfg(test)] #[inline] pub fn num_bytes(&self) -> usize { - self.0.algorithm().digest_algorithm().output_len + self.0.algorithm().digest_algorithm().output_len() } /// Builds a `Hmac` from an algorithm and key. diff --git a/secio/src/dh_compat/ring_impl.rs b/secio/src/dh_compat/ring_impl.rs index 49776704..431122ef 100644 --- a/secio/src/dh_compat/ring_impl.rs +++ b/secio/src/dh_compat/ring_impl.rs @@ -6,6 +6,7 @@ use ring::rand as ring_rand; use super::KeyAgreement; use crate::error::SecioError; +#[allow(unused_imports)] pub use ring::agreement::EphemeralPrivateKey; impl From for &'static agreement::Algorithm { @@ -50,7 +51,7 @@ pub fn agree( agreement::agree_ephemeral( my_private_key, &agreement::UnparsedPublicKey::new(algorithm.into(), other_public_key), - SecioError::SecretGenerationFailed, - |key_material| Ok(key_material.to_vec()), + |key_material| key_material.to_vec(), ) + .map_err(|_| SecioError::SecretGenerationFailed) } diff --git a/secio/src/dh_compat/wasm_compat.rs b/secio/src/dh_compat/wasm_compat.rs index c7161d6b..95b16649 100644 --- a/secio/src/dh_compat/wasm_compat.rs +++ b/secio/src/dh_compat/wasm_compat.rs @@ -12,7 +12,7 @@ pub fn generate_agreement( ) -> Result<(EphemeralPrivateKey, Vec), SecioError> { match algorithm { KeyAgreement::X25519 => { - let key = EphemeralPrivateKey::new(OsRng); + let key = EphemeralPrivateKey::random_from_rng(OsRng); let pubkey = PublicKey::from(&key); Ok((key, pubkey.to_bytes().to_vec())) } diff --git a/secio/src/secp256k1_compat/mod.rs b/secio/src/secp256k1_compat/mod.rs index 65a52f19..23389893 100644 --- a/secio/src/secp256k1_compat/mod.rs +++ b/secio/src/secp256k1_compat/mod.rs @@ -33,7 +33,7 @@ pub fn pubkey_from_slice(key: &[u8]) -> Result { } pub fn message_from_slice(msg: &[u8]) -> Result { - Message::from_slice(msg) + Message::from_digest_slice(msg) } pub fn signature_from_der(data: &[u8]) -> Result { diff --git a/simple_wasm/src/simple.rs b/simple_wasm/src/simple.rs index 50a68625..83b8cf42 100644 --- a/simple_wasm/src/simple.rs +++ b/simple_wasm/src/simple.rs @@ -108,12 +108,12 @@ impl ServiceHandle for SHandle { /// Proto 2 open failure /// /// Because server only supports 0,1 -fn create_client() -> Service { +fn create_client() -> Service { ServiceBuilder::default() .insert_protocol(create_meta(0.into())) .insert_protocol(create_meta(1.into())) .insert_protocol(create_meta(2.into())) - .key_pair(SecioKeyPair::secp256k1_generated()) + .handshake_type(SecioKeyPair::secp256k1_generated().into()) .build(SHandle) } diff --git a/tentacle/Cargo.toml b/tentacle/Cargo.toml index 7620f3e9..4a41769f 100644 --- a/tentacle/Cargo.toml +++ b/tentacle/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tentacle" -version = "0.5.0-alpha.1" +version = "0.6.0" license = "MIT" description = "Minimal implementation for a multiplexed p2p network framework." authors = ["piaoliu ", "Nervos Core Dev "] @@ -11,14 +11,14 @@ categories = ["network-programming", "asynchronous"] edition = "2021" [package.metadata.docs.rs] -features = [ "tokio-runtime", "tokio-timer", "upnp", "ws", "unstable", "tls" ] +features = ["tokio-runtime", "tokio-timer", "upnp", "ws", "unstable", "tls"] all-features = false no-default-features = true rustc-args = ["--cfg", "docsrs"] [dependencies] -yamux = { path = "../yamux", version = "0.3.0", default-features = false, package = "tokio-yamux"} -secio = { path = "../secio", version = "0.6.0", package = "tentacle-secio" } +yamux = { path = "../yamux", version = "0.3.0", default-features = false, package = "tokio-yamux" } +secio = { path = "../secio", version = "0.6.2", package = "tentacle-secio" } futures = { version = "0.3.0" } tokio = { version = "1.0.0", features = ["macros"] } @@ -31,13 +31,13 @@ once_cell = "1.0" nohash-hasher = "0.2" parking_lot = { version = "0.12", optional = true } -tokio-tungstenite = { version = "0.16", optional = true } +tokio-tungstenite = { version = "0.21", optional = true } futures-timer = { version = "3.0.2", optional = true } async-std = { version = "1", features = ["unstable"], optional = true } async-io = { version = "1", optional = true } -multiaddr = { path = "../multiaddr", package = "tentacle-multiaddr", version = "0.3.0" } -molecule = "0.7.0" +multiaddr = { path = "../multiaddr", package = "tentacle-multiaddr", version = "0.3.4" } +molecule = "0.8.0" # upnp igd = { version = "0.12", optional = true } @@ -48,7 +48,7 @@ tokio-rustls = { version = "0.24.0", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] # rand 0.8 not support wasm32 rand = "0.8" -socket2 = { version = "0.4.0", features = ["all"] } +socket2 = { version = "0.5.0", features = ["all"] } [target.'cfg(target_arch = "wasm32")'.dependencies] js-sys = "0.3" @@ -59,7 +59,12 @@ wasm-bindgen-futures = "0.4" libc = "0.2" [target.'cfg(windows)'.dependencies] -winapi = { version = "0.3.7", features = ["minwindef", "ws2def", "winerror", "heapapi"]} +winapi = { version = "0.3.7", features = [ + "minwindef", + "ws2def", + "winerror", + "heapapi", +] } [dev-dependencies] env_logger = "0.6.0" diff --git a/tentacle/src/channel/mod.rs b/tentacle/src/channel/mod.rs index e3d951b3..4ce7b588 100644 --- a/tentacle/src/channel/mod.rs +++ b/tentacle/src/channel/mod.rs @@ -11,6 +11,7 @@ mod sink_impl; mod tests; mod unbound; +#[allow(unused_imports)] pub(crate) mod mpsc { pub use super::bound::{channel, Receiver, Sender}; pub use super::unbound::{unbounded, UnboundedReceiver, UnboundedSender}; diff --git a/tentacle/src/lock/mod.rs b/tentacle/src/lock/mod.rs index e50076f3..5ca0a318 100644 --- a/tentacle/src/lock/mod.rs +++ b/tentacle/src/lock/mod.rs @@ -5,5 +5,6 @@ pub use parking_lot::{const_fair_mutex, const_mutex, const_rwlock, FairMutex, Mu #[cfg(not(feature = "parking_lot"))] pub mod native; +#[allow(unused_imports)] #[cfg(not(feature = "parking_lot"))] pub use native::{Mutex, RwLock}; diff --git a/tentacle/src/transports/ws.rs b/tentacle/src/transports/ws.rs index 2603d192..d0c18194 100644 --- a/tentacle/src/transports/ws.rs +++ b/tentacle/src/transports/ws.rs @@ -322,6 +322,8 @@ impl AsyncRead for WsStream { } Message::Pong(_) => Vec::new(), Message::Text(_) => Vec::new(), + // never reach this branch + Message::Frame(_) => Vec::new(), }; if data.is_empty() {