From 5da59ebec5f3072d0b6c3b1ffc90eb8923c50ad9 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 22 Jul 2022 13:06:10 +0200 Subject: Move things around and fix error bit --- src/endpoint.rs | 1 - src/lib.rs | 1 - src/netapp.rs | 8 +++++++- src/recv.rs | 2 +- src/util.rs | 7 +------ 5 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/endpoint.rs b/src/endpoint.rs index d8dc6c4..7088879 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -7,7 +7,6 @@ use async_trait::async_trait; use crate::error::Error; use crate::message::*; use crate::netapp::*; -use crate::util::*; /// This trait should be implemented by an object of your application /// that can handle a message of type `M`, if it wishes to handle diff --git a/src/lib.rs b/src/lib.rs index ce94682..bd41048 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,6 @@ pub mod netapp; pub mod peering; pub use crate::netapp::*; -pub use util::{NetworkKey, NodeID, NodeKey}; #[cfg(test)] mod test; diff --git a/src/netapp.rs b/src/netapp.rs index 166f560..29df3b9 100644 --- a/src/netapp.rs +++ b/src/netapp.rs @@ -22,7 +22,13 @@ use crate::endpoint::*; use crate::error::*; use crate::message::*; use crate::server::*; -use crate::util::*; + +/// A node's identifier, which is also its public cryptographic key +pub type NodeID = sodiumoxide::crypto::sign::ed25519::PublicKey; +/// A node's secret key +pub type NodeKey = sodiumoxide::crypto::sign::ed25519::SecretKey; +/// A network key +pub type NetworkKey = sodiumoxide::crypto::auth::Key; /// Tag which is exchanged between client and server upon connection establishment /// to check that they are running compatible versions of Netapp, diff --git a/src/recv.rs b/src/recv.rs index b2f5530..2be8728 100644 --- a/src/recv.rs +++ b/src/recv.rs @@ -75,7 +75,7 @@ pub(crate) trait RecvLoop: Sync + 'static { let has_cont = (size & CHUNK_HAS_CONTINUATION) != 0; let is_error = (size & ERROR_MARKER) != 0; let packet = if is_error { - Err(size as u8) + Err((size & !ERROR_MARKER) as u8) } else { let size = size & !CHUNK_HAS_CONTINUATION; let mut next_slice = vec![0; size as usize]; diff --git a/src/util.rs b/src/util.rs index 13cccb9..425d26f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -6,12 +6,7 @@ use serde::Serialize; use tokio::sync::watch; -/// A node's identifier, which is also its public cryptographic key -pub type NodeID = sodiumoxide::crypto::sign::ed25519::PublicKey; -/// A node's secret key -pub type NodeKey = sodiumoxide::crypto::sign::ed25519::SecretKey; -/// A network key -pub type NetworkKey = sodiumoxide::crypto::auth::Key; +use crate::netapp::*; /// Utility function: encodes any serializable value in MessagePack binary format /// using the RMP library. -- cgit v1.2.3